Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to understand "(Num b) => length :: [a] -> b" in Haskell?

Tags:

haskell

I am reading Learn You a Haskell for Great Good!, and come across the following word:

For instance, the length function has a type declaration of length :: [a] -> Int instead of having a more general type of (Num b) => length :: [a] -> b.

How to understand "(Num b) => length :: [a] -> b" here? Shouldn't it be "length :: (Num b) => [a] -> b"?

like image 268
Nan Xiao Avatar asked Jan 07 '16 01:01

Nan Xiao


1 Answers

You're right: it's an error in the book and should read as you suggest.

like image 195
amalloy Avatar answered Nov 22 '22 07:11

amalloy