Ambiguous types

Ashley Yakeley ashley@semantic.org
Mon, 21 Jan 2002 02:19:01 -0800


At 2002-01-21 02:04, Koen Claessen wrote:

>But from the type you give the function `emptyList':
>
>  emptyList :: Ord a => [a]
>
>we cannot derive that the type of the function `emptyList'
>does not matter for its result. So, the type checker will
>complain.

That's it! Consider:

--
class C a where
	emptyList :: [a]

instance C Int where
	emptyList = []

instance C Char where
	emptyList = "Hello"
--

Clearly emptyList has type "(C a) => [a]"...

So in the original example, (validActions actor) cannot be compared to 
the empty list because its value may depend on the type of u. This would 
not be possible if there were no (Action u) context.

-- 
Ashley Yakeley, Seattle WA