
27 Apr
2012
27 Apr
'12
8:40 a.m.
Romildo,
How should an instance of (Functor ExprF) be defined? It is not shown in the thesis.
It's actually quite straigtforward: instance Functor ExprF where fmap _ (Num n) = Num n fmap _ (Var x) = Var x fmap f (Bin op l r) = Bin op (f l) (f r) As expected you get:
cata exprEval (runExpr (1+2*3)) 7.0
HTH, Stefan