[Haskell-beginners] if statements

Marc Weber marco-oweber at gmx.de
Sat Jan 23 13:31:48 EST 2010


Sorry I missed something:

> evalStep (Add x y) =
>   let (Val xEvaled) = evalStep x
>       (Val yEvaled) = evalStep y
>   in Val (xEvaled + yEvaled)

should work. So you either have to use this let binding or you have to
add a getVal function. And this is why I love Haskell. By thinking about
the code you notice that you really want

evalStep :: Expression -> result

where result is Float, Int or Ratianal or such. Then you can use the
code I wrote in my previous mail.

Marc Weber


More information about the Beginners mailing list