[GHC] #10836: Better error reporting for closed type families
GHC
ghc-devs at haskell.org
Fri Sep 11 19:59:56 UTC 2015
#10836: Better error reporting for closed type families
-------------------------------------+-------------------------------------
Reporter: jstolarek | Owner:
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Compiler | Version: 7.11
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Incorrect | Test Case:
warning at compile-time | typecheck/should_fail/T10836
Blocked By: | Blocking:
Related Tickets: | Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by jstolarek):
Simon, this change is a huge improvement over the previous situation, but
not everything is yet perfect. Consider this:
{{{#!hs
type family FClosed a b c = (result :: *) | result -> a b c where
FClosed Int Char Bool = Bool
FClosed Char Bool Int = Int
FClosed Bool Int Char = Int
type family Bar a = r | r -> a where
Bar Int = Bool
Bar Bool = Int
Bar Bool = Char
bar :: Bar a -> Bar a
bar x = x
barapp :: Char
barapp = bar 'c'
}}}
I would expect to get two errors:
{{{
T6018.hs:8:5: error:
Type family equations violate injectivity annotation:
FClosed Char Bool Int = Int
FClosed Bool Int Char = Int
In the equations for closed type family ‘FClosed’
In the type family declaration for ‘FClosed’
T6018.hs:20:14: error:
Couldn't match expected type ‘Bar a0’ with actual type ‘Char’
The type variable ‘a0’ is ambiguous
In the first argument of ‘bar’, namely ‘'c'’
In the expression: bar 'c'
In an equation for ‘barapp’: barapp = bar 'c'
}}}
But I only get the first one. Is this expected?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10836#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list