Ambiguous types

Janis Voigtlaender voigt@orchid.inf.tu-dresden.de
Mon, 21 Jan 2002 11:19:39 +0100


Ashley Yakeley wrote:
> ...
> gives type error:
> 
>   ordnull :: (forall a. (Ord a) => [a]) -> Bool
>   ordnull = null

null is able to take a list and look whether its empty. The argument
(say l) of ordnull with the given type, however, is a polymorphic list,
i.e., for every instance a of Ord, l is a list of a's. The problem is
that for some instance A1 of Ord, l might be an empty list, whereas for
some other instance A2 of Ord, l might be nonempty. null is not defined
to work on such strange objects (how could it? should it try all
instances a of Ord?). The question whether such A1, A2 and l as above
can be given (which I doubt) is not relevant as far as the type checker
cannot know that they do not.

--
Janis Voigtlaender
http://wwwtcs.inf.tu-dresden.de/~voigt/
mailto:voigt@tcs.inf.tu-dresden.de