For simple datatypes like this, GHC can derive the Functor implementation for you:<br><br>{-# LANGUAGE DeriveFunctor #-}<br><br>data ExprF r = ....<br> deriving (..., Functor)<br><br>See <a href="http://www.haskell.org/ghc/docs/7.0.4/html/users_guide/deriving.html">http://www.haskell.org/ghc/docs/7.0.4/html/users_guide/deriving.html</a><br>
<br> -- ryan<br><br><div class="gmail_quote">On Fri, Apr 27, 2012 at 5:40 AM, Stefan Holdermans <span dir="ltr"><<a href="mailto:stefan@vectorfabrics.com" target="_blank">stefan@vectorfabrics.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Romildo,<br>
<div class="im"><br>
> I could write the (Functor ExprF) instance:<br>
><br>
> instance Functor ExprF where<br>
> fmap f expr = case expr of<br>
> Num n -> Num n<br>
> Var v -> Var v<br>
> Bin op x y -> Bin op (f x) (f y)<br>
<br>
</div>Yes, excellent. That'll do.<br>
<br>
Cheers,<br>
<br>
Stefan<br>
<div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br>