[GHC] #14101: Type synonyms can make roles too conservative

GHC ghc-devs at haskell.org
Sat Aug 12 08:23:15 UTC 2017


#14101: Type synonyms can make roles too conservative
-------------------------------------+-------------------------------------
        Reporter:  dfeuer            |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:  8.4.1
       Component:  Compiler (Type    |              Version:  8.2.1
  checker)                           |
      Resolution:                    |             Keywords:  roles
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #8234             |  Differential Rev(s):  Phab:D3838
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by ethercrow):

 I'm not sure if it belongs to this ticket. I'm trying to make a
 specialization for leaves in a hashmap when key type is something small,
 e.g. Int:


 {{{
 data LeafInt v = LI !Int v

 data LeafPoly k v = LP !k v

 type family Leaf a where
   Leaf Int = LeafInt
   Leaf k = LeafPoly k
 }}}

 The hashmap


 {{{
 data HashMap k v
   = Leaf !Hash !(Leaf k v)
   ...
 }}}


 itself has a type role annotation:

 {{{
 type role HashMap nominal representational
 }}}

 I get the error

 {{{
         • Role mismatch on variable v:
             Annotation says representational but role nominal is required
         • while checking a role annotation for ‘HashMap’
 }}}

 I tried to express the same using data family and a class with associated
 type, the result is the same.

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


More information about the ghc-tickets mailing list