>
> foldExp :: AlgExp a -> Exp -> a
> foldExp alg (LitI i) = litI alg i
> foldExp alg (LitB i) = litB alg i
> foldExp alg (add exp1 exp2) = ¿¿¿???
> foldExp alg (and exp1 exp2) = ¿¿¿???
> foldExp alg (ifte exp1 exp2 exp3) = ¿¿¿???
>

One comment: it looks like (add exp1 exp2), (and exp1 exp2) and so on above
are not correct.  The second argument of foldExp is a value of type Exp, so
you are pattern-matching on the constructors of Exp, and constructors are
always uppercase.  Perhaps Exp has constructors named Add, And, and so on?
Then you would want to do something like

foldExp alg (Add exp1 exp2) = ???

and so on.  For the ??? part, you want to pull out an appropriate function
from your alg record and apply it to exp1 and exp2.

-Brent
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to