[GHC] #8177: Roles for type families

GHC ghc-devs at haskell.org
Mon Aug 15 14:03:42 UTC 2016


#8177: Roles for type families
-------------------------------------+-------------------------------------
        Reporter:  simonpj           |                Owner:  goldfire
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  ⊥
       Component:  Compiler          |              Version:  7.6.3
      Resolution:                    |             Keywords:  TypeFamilies
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by RyanGlScott):

 * cc: RyanGlScott (added)


Comment:

 goldfire, I do have a need for this in order to do "real work"... at some
 point in the future after #9123 is fixed :)

 My use case is laid out in
 [https://ghc.haskell.org/trac/ghc/ticket/8516#comment:7 this comment] in
 #8516. I'm interested in using higher-kinded roles to increase the number
 of datatypes for which you can derive `Generic1` instances by replacing
 `Functor` constraints with `Representational` constraints (where
 `Representational` is the typeclass proposed
 [https://ghc.haskell.org/trac/ghc/ticket/9123#comment:5 here]).
 Unfortunately, at the moment, my proposed plan would actually //decrease//
 that number, because there are datatypes defined in terms of type families
 for which you can declare `Functor` instances. However, type families
 always default to `nominal` roles for its type arguments, which means they
 can't be `Representational`! Ack!

 It definitely seems like //some// type families should be able to have
 `Representational` (or even `Phantom`!) roles for its arguments. A prime
 example is from [https://ghc.haskell.org/trac/ghc/ticket/8516#comment:7
 this comment]:

 {{{#!hs
 type family Id a where
   Id a = a
 }}}

 I have a strong hunch that `a` should be have a `representational` role.
 Unfortunately, I have no way to inform GHC of this.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8177#comment:31>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list