[GHC] #9063: Default associated type instances are too general
GHC
ghc-devs at haskell.org
Mon May 5 11:22:54 UTC 2014
#9063: Default associated type instances are too general
-------------------------------------+------------------------------------
Reporter: goldfire | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.8.2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
-------------------------------------+------------------------------------
Comment (by simonpj):
Can you give an example for instances?
There is a design question here. For a start, the associated type should
really mention at least one of the class variables. This should be
prohibited:
{{{
class C a where
type F b :: *
}}}
Second, the default instances should mention the same class variable in
the same position, not some pattern. For example
{{{
class C a where
type F a b :: *
type instance F a Int = Int -- OK
type instance F a Bool = Char -- OK
type instance F Int a = Bool -- Definitely not OK!
type instance F [a] b = Char -- Not OK
}}}
Reason: the default instances are simply templates, from which you can
create the real `type instance` in the instance decl. For example
{{{
instance C Float
-- type instance F Float Int = Int
-- type instance F Float Bool = Char
}}}
How would one instantiate the "not-ok" defaults here??
We are not currently checking any of this, nor is it documented.
[http://www.haskell.org/ghc/docs/7.8.2/html/users_guide/type-families.html
#assoc-decl-defs Current manual entry]
Before moving to fix it, let's just check that we agree.
Simon
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9063#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list