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
Ashley Yakeley wrote:
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
...
Ok, it seems that the type error in Daniel's program occured for a simpler reason than I suspected. But my objection to the program persists: to have a polymorphic (==) that compares lists with the same element types is different from having a (==) that compares polymorphic lists. -- Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de
participants (2)
-
Ashley Yakeley -
Janis Voigtlaender