>>Steve Frampton <[EMAIL PROTECTED]> wrote:
>>> foo x = ['1'] ++ foo(x div 10)
>>> *** term : foo
>>> *** type : ((a -> a -> a) -> b -> Int) -> [Char]
>>> *** does not match : Int -> [Char]
>Can someone please explain how to decipher the type line in this error
>message in such a way that we come to div being used incorrectly?
The x on the right hand side is viewed as a function whose first argument is
div and second argument is 10. Since the specified type of foo is
Int -> [Char]
the return type of the function x must be Int.
Now since div has the type
Integral a => a -> a -> a
and 10 has the type
Num b => b
the inferred type of x is
((a -> a -> a) -> b -> Int)
But x is the argument to foo and is supposed to have type Int.
Dan Russell
Kingston University