Ambiguous types

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


At 2002-01-21 00:25, Janis Voigtlaender wrote:

>Hope that helps and doesn't just make the story more obscure ;-)

I'm not convinced. Here's a simplified case...

This compiles fine:

  emptyList :: [a]
  emptyList = []

  isempty :: Bool
  isempty = null emptyList

But this gives an error:

  emptyList :: (Ord a) => [a]
  emptyList = []

  isempty :: Bool
  isempty = null emptyList

ghci says:

    Ambiguous type variable(s) `a' in the constraint `Ord a'
    arising from use of `emptyList' at ActorTest.hs:7
    In the first argument of `null', namely `emptyList'
    In the definition of `isempty': null emptyList

Hugs says:

ERROR "ActorTest.hs" (line 7): Cannot justify constraints in explicitly 
typed binding
*** Expression    : isempty
*** Type          : Bool
*** Given context : ()
*** Constraints   : Ord a


-- 
Ashley Yakeley, Seattle WA