Coder Social home page Coder Social logo

Some functions I'm usin about extra HOT 4 CLOSED

ndmitchell avatar ndmitchell commented on May 3, 2024
Some functions I'm usin

from extra.

Comments (4)

ndmitchell avatar ndmitchell commented on May 3, 2024

While composeMany might be useful in certain situations, it doesn't seem a good fit for extra - there's nothing quite like it already, and nothing that even depends on alternative or category. In addition, I have almost no intuition of what it does.

For the second, I think you can generalise from Monad to Applicative, and generalise from a -> a to a -> b. Once you've done that you end up with something like liftA but the other way around, or even the dual of fmap in some sense. For that, I'd be curious to know what the operator should be called - I don't think $^ is necessarily the right intuition. FWIW, I have defined this function before, several times, but I tend to define a family of operators, which are the types:

Applicative m => m (a -> b) -> a -> m b
Applicative m => (a -> b) -> m a -> m b
Applicative m => m (a -> b) -> m a -> m b

The last two are <$> and <*>, but I define them with names like ^$ and ^$^ to have full symmetry. That said, because they don't fit in with the existing operators, I've never been a fan.

from extra.

marcosdumay avatar marcosdumay commented on May 3, 2024

On a second thought, I should have though composeMany for Monoid instead of Category anyway. It would be much easier to deal with.

I see your point about the operator. I'm left wondering if the ^$ set isn't better than the current <$> set, but yes, it's not something anybody would want to change now. On the <$> set, the $> operator seems to be unused, but because of the way <$ is defined, it may not be a good choice.

Well, I don't think I have anything valuable to add on this subject anymore. Thanks for the interaction.

from extra.

andreasabel avatar andreasabel commented on May 3, 2024

Considering ($^), writing mf <*> pure (a r g) instead of mf $^ a r g does not seem that much extra to write. Of course with $^ you can save some parentheses.
Unfortunately, there is no good name available, as <* is taken for something else.

from extra.

ndmitchell avatar ndmitchell commented on May 3, 2024

I disagree about the extra syntactic-overhead of using pure - often the code is littered with $^ in many places, so you go from being mostly about your functions to just having a lot of pure. That said, without a good name, it isn't worth it.

from extra.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.