[Haskell-beginners] if statements

Roel van Dijk vandijk.roel at gmail.com
Sat Jan 23 14:13:09 EST 2010

Hi John,

The @ in a pattern is called an 'as-pattern'. They are explained in
this tutorial: http://www.haskell.org/tutorial/patterns.html

Very briefly they assign a name to a pattern.

I'm not sure why you get a type error. I could load the code into GHCI
without problems. When the compiler complains about missing instanced
for Num than it usually means you did something like (x + y) where x
and y are of type E without E having an instance for Num. For example
(Val 3) + (Val 4) would result in such an error.

On Sat, Jan 23, 2010 at 7:32 PM, John Moore <john.moore54 at gmail.com> wrote:
> Hi Roel,
>              This isn't working, what does @ stand for in
> evalStep (Add x@(Val _) y) = Add x (evalStep y)
> Maybe this is a mistype
> It's asking me for a instance declaration for (num expression)
> John

More information about the Beginners mailing list