[GHC] #8177: Roles for type families

GHC ghc-devs at haskell.org
Sat Jan 18 21:54:29 UTC 2014


#8177: Roles for type families
-------------------------------------+------------------------------------
        Reporter:  simonpj           |            Owner:
            Type:  bug               |           Status:  new
        Priority:  normal            |        Milestone:
       Component:  Compiler          |          Version:  7.6.3
      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 goldfire):

 A post on #8672 seems more relevant here:

 Simon PJ says:
 Richard, two questions. First (Q1), can't a data instance have a
 representational role inferred? Eg this ought to work. The definition of
 `g` is currently rejected.

 {{{
 data family T a
 data instance T [b] = MkT b

 newtype Age = MkAge Int

 g :: T [Age] -> T [Int]
 g x = coerce x
 }}}

 Second question (Q2). Are role annotations allowed on data family
 declarations, where they could indicate which parameters are the indices:

 {{{
 type role T representational nominal  -- Only second param can be an index
 data family T a b

 data instance T a Bool = ...   -- Allowed
 data instance T Bool b = ...   -- Rejected
 }}}

 (And similarly for type families.)

 Similarly are role annotations allowed on data instance declarations,
 where they would be useful in exactly the same way that they are on data
 decls

 {{{
 data family T a

 type role T [a] (a:nominal)
 data instance T [a] = MkT a
 }}}

 Here we are running out of syntax! This isn't supported now because I
 think all parameters are automatically nominal (see Q1 for why they
 shouldn't be).

 Simon

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


More information about the ghc-tickets mailing list