[Haskell-cafe] foild function for expressions

Carlo Vivari thrakatak at hotmail.com
Tue Dec 4 12:19:55 EST 2007




Brent Yorgey wrote:
> 
> 
> 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
> 
> 

Yepp, it's my fault I wasn't too precise in my explanation.
There's a declaration of the data type EXP,  which is not difficult to gess
with the things I've said:

data Exp = LitI Int
               |LitB Bool
               |Add Exp Exp
               |And Exp Exp
               |If Exp Exp Exp

I'm going to read carefully all of your answer now (thanks to all!!!), and
then I'll tell you. ;)


-- 
View this message in context: http://www.nabble.com/foild-function-for-expressions-tf4932877.html#a14155122
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.



More information about the Haskell-Cafe mailing list