
27 Apr
2012
27 Apr
'12
5:06 p.m.
For simple datatypes like this, GHC can derive the Functor implementation
for you:
{-# LANGUAGE DeriveFunctor #-}
data ExprF r = ....
deriving (..., Functor)
See http://www.haskell.org/ghc/docs/7.0.4/html/users_guide/deriving.html
-- ryan
On Fri, Apr 27, 2012 at 5:40 AM, Stefan Holdermans wrote: Romildo, I could write the (Functor ExprF) instance: instance Functor ExprF where
fmap f expr = case expr of
Num n -> Num n
Var v -> Var v
Bin op x y -> Bin op (f x) (f y) Yes, excellent. That'll do. Cheers, Stefan _______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe