[GHC] #8177: Roles for type families

GHC ghc-devs at haskell.org
Tue Aug 27 12:55:46 UTC 2013


#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):

 I would argue that, given the declaration for `D` above, the following
 instance should also be rejected:

 {{{
 data instance D (Maybe c) = MkD2 c
 }}}

 Why should that instance be rejected? Because it pattern-matches on its
 argument. Before thinking about implementing this (which I agree should be
 straightforward), we need to agree on the design. Here are a few questions
 to spur discussion:

 * What should the default role be for families? Is it different for data
 and for type families? (I would prefer N for both.)
 * Am I right that the instance above should be rejected?
 * Consider
    {{{
    type family Flip x at R y at R
    type instance Flip x y = (y, x)
    }}}
    Is that accepted? I think "yes".

 Here are some proposed rules:
 * If a parameter is at role N, its use is unrestricted in instances.
 * If a parameter is at role R, it cannot be matched against and it must
 only appear in R (or P) positions in the RHS of instances.
 * If a parameter is at role P, it cannot be matched against and it must
 only appear in P positions in the RHS of instances.

 Thoughts? Let's have the conversation here, and I will put the resolution
 on the wiki along with writing the implementation.

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




More information about the ghc-tickets mailing list