[GHC] #8177: Roles for type families

GHC ghc-devs at haskell.org
Thu May 15 01:54:41 UTC 2014


#8177: Roles for type families
-------------------------------------+------------------------------------
        Reporter:  simonpj           |            Owner:  goldfire
            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 jwlato):

 I agree that the `vector` issue is related to this feature.  In summary,
 we would like the following to work (greatly simplified from vector WLOG):

 {{{
 class MVectorClass (v :: * -> * -> *) a where
     basicLength :: v s a -> Int

 data family MVector s a

 data instance MVector s Int -- implementation not important

 newtype Age = Age Int deriving (MVectorClass MVector) -- rejected
 }}}

 The deriving is rejected because it generates

 {{{
 basicLength =
     coerce (basicLength :: MVector s Int -> Int) :: MVector s Age -> Int
 }}}

 If my understanding of role inference is correct, allowing
 {{{
 type role instance MVector nominal representational
 }}}
 would allow for this coerce to take place.

 This means that we can't currently derive Unbox instances for vectors of
 newtypes (see https://github.com/haskell/vector/issues/16), which is
 rather unfortunate.

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


More information about the ghc-tickets mailing list