[Haskell-cafe] Another point-free question (>>=, join, ap)

Andrew Wagner wagner.andrew at gmail.com
Thu Feb 12 18:39:33 EST 2009


Check out liftM2. It's almost what you want.

On Thu, Feb 12, 2009 at 6:36 PM, Edsko de Vries <devriese at cs.tcd.ie> wrote:

> Hi,
>
> I can desugar
>
>  do x' <- x
>     f x'
>
> as
>
>  x >>= \x -> f x'
>
> which is clearly the same as
>
>  x >>= f
>
> However, now consider
>
>  do x' <- x
>     y' <- y
>     f x' y'
>
> desugared, this is
>
>  x >>= \x -> y >>= \y' -> f x' y'
>
> I can simplify the second half to
>
>  x >>= \x -> y >>= f x'
>
> but now we are stuck. I feel it should be possible to write something like
>
>  x ... y ... f
>
> or perhaps
>
>  f ... x ... y
>
> the best I could come up with was
>
>  join $ return f `ap` x `ap` y
>
> which is not terrible but quite as easy as I feel this should be. Any
> hints?
>
> Edsko
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090212/a8bbf213/attachment.htm


More information about the Haskell-Cafe mailing list