[Haskell-cafe] Re: Seeking advice about monadic traversal
djreid at aapt.net.au
Sat Apr 3 00:29:24 EDT 2010
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.
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
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe