Mike Thomas <[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?
In fact "div" is not used incorrectly in the above example; expression
"x div 10" is correct when considered apart from the rest of the program.
Error comes from the fact that foo was declared as "Int -> Char" and
in definition "foo x = foo (x div 10)" foo can't have this type.
>I'm afraid that my mind doesn't immediately jump to the conclusion that div
>without quotes is not an infix operator when I see the error message.
>Surely minor syntactical errors can be reported in a more meaningful manner?
As I've written "x div 10" it's not syntactical error. We can write:
x :: (Int -> Int -> Int) -> Int -> Int
x function argument = function 42 argument
and then
x div 10
is correct expression of type Int (equal to 42 `div` 10).
--
Tomasz Lukaszewicz o ___ | "I have no idea
mailto:[EMAIL PROTECTED] o /o \/| | what to write here."
http://www.tomasz.w.pl/english/ \___/\| | -- Me --