#2544: Improve "Can't unify" error messages from type functions
----------------------------------------+-----------------------------------
Reporter: simonpj | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 6.12 branch
Component: Compiler (Type checker) | Version: 6.8.3
Severity: normal | Keywords:
Difficulty: Unknown | Testcase:
Architecture: Unknown | Os: Unknown
----------------------------------------+-----------------------------------
Consider this example from a Haskell Cafe thread:
{{{
data (:|:) a b = Inl a | Inr b
class Ix i where
type IxMap i :: * -> *
empty :: IxMap i [Int]
data BiApp a b c = BiApp (a c) (b c)
instance (Ix l, Ix r) => Ix (l :|: r) where
type IxMap (l :|: r) = BiApp (IxMap l) (IxMap r)
empty = BiApp empty empty
}}}
This elicits the following confusing error message:
{{{
Couldn't match expected type `IxMap l'
against inferred type `IxMap i'
Expected type: IxMap (l :|: r) [Int]
Inferred type: BiApp (IxMap i) (IxMap i1) [Int]
In the expression: BiApp empty empty
In the definition of `empty': empty = BiApp empty empty
}}}
As Alexander Dunlap responds, the error message is correct, but I can't
help feeling that we should try harder to give a better error message.
Something like "Since `IxMap` is a type function, knowing that `IxMap l` =
`IxMap i` does not require that `l` = `i`". Or something.
This ticket is just to make sure we don't forget. The thread is here
http://www.haskell.org/pipermail/haskell-cafe/2008-August/046371.html
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2544>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs