Re: [Haskell-cafe] foild function for expressions

2007-12-05 Thread Pablo Nogueira
I believe the exercise is about understanding folds. There are two references that are related to the exercise: A tutorial on the universality and expressiveness of fold, by Graham Hutton. Dealing with large bananas, by Ralf Lammel, etc. The last paper motivates well the need to gather all

Re: [Haskell-cafe] foild function for expressions

2007-12-04 Thread Kalman Noel
Ryan Ingram wrote: On 12/3/07, Kalman Noel [EMAIL PROTECTED] wrote: You're confusing sum and product types. I'm not so sure; it looks like they already have that type (Exp) and wants to use AlgExp to hold the folding functions used. Ah, I didn't catch that on the first read. I suppose Carlo

Re: [Haskell-cafe] foild function for expressions

2007-12-04 Thread Carlo Vivari
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

Re: [Haskell-cafe] foild function for expressions

2007-12-04 Thread David Menendez
On Dec 3, 2007 12:18 PM, Carlo Vivari [EMAIL PROTECTED] wrote: Hi! I'm a begginer in haskell and I have a problem with an exercise, I expect someone could help me: In one hand I have a declaration of an algebra data, like this: data AlgExp a = AlgExp { litI :: Int - a, litB :: Bool -

Re: [Haskell-cafe] foild function for expressions

2007-12-04 Thread Carlo Vivari
Yes,as I said before to other of you the exp data type was also declared in the exercise (my fault not to say it), and look as this: data Exp = LitI Int |LitB Bool |Add Exp Exp |And Exp Exp |If Exp Exp Exp -- View this message

[Haskell-cafe] foild function for expressions

2007-12-03 Thread Carlo Vivari
Hi! I'm a begginer in haskell and I have a problem with an exercise, I expect someone could help me: In one hand I have a declaration of an algebra data, like this: data AlgExp a = AlgExp { litI :: Int - a, litB :: Bool - a, add :: a - a - a, and :: a - a - a, ifte :: a - a - a -

Re: [Haskell-cafe] foild function for expressions

2007-12-03 Thread Kalman Noel
Carlo Vivari wrote: data AlgExp a = AlgExp { litI :: Int - a, litB :: Bool - a, add :: a - a - a, and :: a - a - a, ifte :: a - a - a - a} You're confusing sum and product types. That is, you're using a product type, but you probably need a sum type, like this: data Exp1 =

Re: [Haskell-cafe] foild function for expressions

2007-12-03 Thread Brent Yorgey
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

Re: [Haskell-cafe] foild function for expressions

2007-12-03 Thread Ryan Ingram
On 12/3/07, Kalman Noel [EMAIL PROTECTED] wrote: You're confusing sum and product types. That is, you're using a product type, but you probably need a sum type, like this: I'm not so sure; it looks like they already have that type (Exp) and wants to use AlgExp to hold the folding functions

Re: [Haskell-cafe] foild function for expressions

2007-12-03 Thread Stefan O'Rear
On Mon, Dec 03, 2007 at 09:27:45PM -0600, Derek Elkins wrote: On Mon, 2007-12-03 at 19:13 -0800, Stefan O'Rear wrote: On Mon, Dec 03, 2007 at 09:18:18AM -0800, Carlo Vivari wrote: Hi! I'm a begginer in haskell and I have a problem with an exercise, I expect someone could help me:

Re: [Haskell-cafe] foild function for expressions

2007-12-03 Thread Stefan O'Rear
On Mon, Dec 03, 2007 at 09:18:18AM -0800, Carlo Vivari wrote: Hi! I'm a begginer in haskell and I have a problem with an exercise, I expect someone could help me: In one hand I have a declaration of an algebra data, like this: data AlgExp a = AlgExp { litI :: Int - a, litB :: Bool

Re: [Haskell-cafe] foild function for expressions

2007-12-03 Thread Derek Elkins
On Mon, 2007-12-03 at 19:13 -0800, Stefan O'Rear wrote: On Mon, Dec 03, 2007 at 09:18:18AM -0800, Carlo Vivari wrote: Hi! I'm a begginer in haskell and I have a problem with an exercise, I expect someone could help me: In one hand I have a declaration of an algebra data, like this: