Flipped function application

David Menendez dave
Thu Oct 10 15:16:47 UTC 2013


On Thu, Oct 10, 2013 at 10:13 AM, Dan Doel <dan.doel at gmail.com> wrote:

> On Thu, Oct 10, 2013 at 4:46 AM, Simon Peyton-Jones
> <simonpj at microsoft.com> wrote:
> > F# uses (|>).   Maybe (#) is good.    To me (&) looks too commutative
> > because it?s usually used for conjunction.
>
> I mentioned this on the core list, but I'll mention it here, too:
>
> I don't like (|>), because once you have this operator, you also might
> as well have the functorial version. We have ($) and (<$>), and lens
> has (&) and (<&>). The latter is useful for functorial 'for blocks':
>
>     myFunctorValue <&> \x ->
>       ...complex expression...
>
> I actually think it's (significantly) more useful than (&). But, I
> think (<|>>) is a pretty awful name for it, so I'd prefer a name that
> makes both palatable.


I'm still not convinced we need flipped application in general[1], and I'm
sure we don't need new name suggestions at this point, but:

Consider <**> :: f a -> f (a -> b) -> f b.

That suggests <$$> :: f a -> (a -> b) -> f b by analogy, so maybe $$ :: a
-> (a -> b) -> b? This avoids the downsides of & while maybe being less
ugly to combine with things than |>. Also, it looks like $, suggesting
they're related.


[1]: Although it's certainly convenient for some idioms, like working with
lenses.


-- 
Dave Menendez <dave at zednenem.com>
<http://www.eyrie.org/~zednenem/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20131010/2235d85b/attachment-0001.html>




More information about the Libraries mailing list