[GHC] #7123: Dictionary method should be applicable even in existential context
GHC
cvs-ghc at haskell.org
Mon Aug 13 14:10:43 CEST 2012
#7123: Dictionary method should be applicable even in existential context
-------------------------------+--------------------------------------------
Reporter: heisenbug | Owner:
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Compiler | Version: 7.4.1
Resolution: invalid | Keywords:
Os: Unknown/Multiple | Architecture: Unknown/Multiple
Failure: None/Unknown | Difficulty: Unknown
Testcase: | Blockedby:
Blocking: | Related:
-------------------------------+--------------------------------------------
Changes (by simonpj):
* status: new => closed
* resolution: => invalid
Comment:
parcs is right. See
http://www.haskell.org/haskellwiki/Type_families#Injectivity.2C_type_inference.2C_and_ambiguity.
It's actually impossible to call `baz`, ever! Look at its type:
{{{
baz :: Foo a => Bar a -> Int
}}}
Suppose we have a call `(baz x)` where `x::(Int,Int)`. How should we
intantiate `a`? Maybe we can instantiate `a` with `Char`, because `Bar
Char = (Int,Int)` which matches x's type. But suppose we also had
{{{
instance Foo Bool where
type Bar Bool = (Int,Int)
bar (i,_) = i
}}}
Now we could also instantiate `a` to `Bool`!
You can fix this by using a `data` family instead; or (in the future) by
specifing that `Bar` is injective.
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7123#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list