Reputation: 61091
In this tutorial, at the very bottom, the author provides a function type of:
(Num b) => length :: [a] -> b
So you can see that it begins with typeclass "Num b" (at least that's what I think it is). But when I try to define something like:
(Integral a) => lucky :: a -> String
I get an error:
parse error on input `=>'
Who is wrong here?
Upvotes: 7
Views: 135
Reputation: 183918
The tutorial is wrong, the type class has to come after the ::
, the type signature ought to be length :: Num b => [a] -> b
.
The syntax is specified in the language report, section 10.5 context free syntax, the pertinent production is gendecl.
Upvotes: 12