Re: Type inferrence problem

Mark Tullsen <[email protected]>
Newsgroups gmane.comp.lang.haskell.hugs.bugs
Organization Oregon Graduate Institute
Message-ID <[email protected]>
You should check your code before you accuse the type checker!
Maybe you're missing some parentheses ...  :-).  Juxtaposition
binds tighter than ":" in Haskell.

- Mark

[email protected] wrote:

>
> 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.
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.