I am learning Haskell using Learn You a Haskell. On page 54 is animplementation of take like so:take' :: (Num i, Ord i) => i -> [a] -> [a]take' n _| n <= 0 = []take' _ [] = []take' n (x:xs) = x : take' (n-1) xsI understand all the code apart from the first line.The :: part I understand as meaning this is a type definition?(Num i, Ord i) is a tuple. The first element of the tuple has to benumeric, fair enough. the second param has to be able to be ordered.The parameter is the same - both are i. This means that the typeshave to be the same?Why is it not (Num i, Ord j)? Isn't the 2nd tuple elementreferring to the list? Which could be of any type?What does => signify?i -> [a] -> [a] means first parameter is numeric? 2nd param is anytype list, 3rd param is any type list. So this is saying first paramnumeric, 2nd param a list of any type and it returns a list of anytype. Well that is understandable I suppose.
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners