Why is the type constraint different from signature?

Hi All, can some one explain to me why ghci> let f:: (Ord a, Num b) => a -> b -> a ; f=undefined ghci> :t f 1 2 ghci> f 1 2 :: (Num a, Ord a) => a The initial type signature just required *a* to be a type that is an instance of Ord but after it had the additional constraint of Ord as well??? -- Best Regards, Boon Hui

:t f f :: (Num b, Ord a) => a -> b -> a
a is an instance of Ord b is an instance of Num
:t 1 1 :: Num a => a :t f 1 f 1 :: (Num a, Num b, Ord a) => b -> a
the literal 1 is an instance of Num, therefore
a must be an instance of Ord but now also of Num
What we know about a is that it must be a Num (because we assigned it the
literal 1 which is a Num) and that it must also be an Ord (because your
original type signature specified that it must also be an Ord).
On Mon, Aug 29, 2016 at 10:56 AM, Lai Boon Hui
Hi All,
can some one explain to me why
ghci> let f:: (Ord a, Num b) => a -> b -> a ; f=undefined ghci> :t f 1 2 ghci> f 1 2 :: (Num a, Ord a) => a
The initial type signature just required *a* to be a type that is an instance of Ord but after it had the additional constraint of Ord as well???
-- Best Regards, Boon Hui
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
participants (2)
-
David McBride
-
Lai Boon Hui