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">&lt;<a href="mailto:stefan@vectorfabrics.com" target="_blank">stefan@vectorfabrics.com</a>&gt;</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>
&gt; I could write the (Functor ExprF) instance:<br>
&gt;<br>
&gt;  instance Functor ExprF where<br>
&gt;    fmap f expr = case expr of<br>
&gt;                    Num n -&gt; Num n<br>
&gt;                    Var v -&gt; Var v<br>
&gt;                    Bin op x y -&gt; Bin op (f x) (f y)<br>
<br>
</div>Yes, excellent. That&#39;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>