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@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to