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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With