Type inferrence problem
| Newsgroups | gmane.comp.lang.haskell.hugs.bugs |
|---|---|
| Message-ID | <oprn9ek3v88x7giz@localhost> |
Hugs (Version Nov 2002) cannot handle the following function definition:
Â
f :: Ord a => Int -> [a] -> [a]
f 0 xs = xs
f _ [] = []
f n (x:y:zs) | x > y = y : (f (n - 1) x:zs)
| otherwise = x : (f (n - 1) y:zs)
Â
Â
Hugs generates the message:
Â
ERROR "C:\Program Files\Hugs98\Henk-Jan\error.hs":2 - Inferred type is not general enough
*** Expression : f
*** Expected type : Ord a => Int -> [a] -> [a]
*** Inferred type : Ord [a] => Int -> [[a]] -> [[a]]
Â
It seems to me that this is a bug in the inferrence mechanism.
Â
Henk-Jan.
Â
--