Novice question

Fergus Henderson fjh@cs.mu.oz.au
Tue, 24 Apr 2001 03:43:44 +1000


On 22-Apr-2001, Mark Carroll <mark@chaos.x-philes.com> wrote:
> greaterthan 0 _ _ = False
> greaterthan _ (x:xs) (y:ys) = x > y
...
> Main> greaterthan 0 [] []
> ERROR: Unresolved overloading
> *** Type       : Ord a => Bool
> *** Expression : greaterthan 0 [] []
> 
> ...I don't understand what the problem is. I'm guessing that the problem
> is with the use of > and it not knowing which 'version' of > to use,

Yes.

> but it doesn't need to know because we're not matching with that line anyway.

The type checker doesn't know that.
The type checker only takes into account the types of the arguments,
not their values, so it can't tell when an ambiguity like this
doesn't matter because the ambiguous code won't be executed.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.