[Haskell-cafe] Re: Seeking advice about monadic traversal
functions
Darryn Reid
djreid at aapt.net.au
Sat Apr 3 00:29:24 EDT 2010
Martijn,
Thanks for your comment and advice. Could you explain a little further
your thinking? Specifically, what advantage do you find in the
applicative notation, and when would you advise using it and when would
you advise not using it?
Thanks again, I appreciate your help.
Darryn.
On Fri, 2010-04-02 at 20:26 +0200, Martijn van Steenbergen wrote:
> On 3/31/10 12:44, Heinrich Apfelmus wrote:
> > go Next (Single x t1) = liftM (Single x) (rewrite f t1)
> > go Next (Fork t1 t2 ) = liftM2 Fork (rewrite f t1)
> > (rewrite f t2)
> >
> > In particular, liftM and liftM2 make it apparent that we're just
> > wrapping the result in a constructor.
>
> A small remark: I prefer using applicative notation for this:
>
> > go Next (Single x t1) = Single x <$> rewrite f t1
> > go Next (Fork t1 t2 ) = Fork <$> rewrite f t1 <*> rewrite f t2
>
> Martijn.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe
mailing list