[GHC] #13929: GHC panic with levity polymorphism

GHC ghc-devs at haskell.org
Thu Jul 6 19:03:50 UTC 2017


#13929: GHC panic with levity polymorphism
-------------------------------------+-------------------------------------
        Reporter:  vagarenko         |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.2.1
       Component:  Compiler          |              Version:  8.2.1-rc2
      Resolution:                    |             Keywords:  TypeInType,
                                     |  LevityPolymorphism
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by vagarenko):

 Replying to [comment:7 bgamari]:
 > To be clear, I don't think (although could be wrong) this program should
 compile; afterall, the type of `gunbox` requires that we represent a
 levity polymorphic result, which we cannot do. Hence, the real bug here is
 the panic instead of a proper type error.

 I think levity polymorphism paper says you can't have functions with
 levity-polymorphic parameters, levity-polymorphic results are OK.


 This compiles fine:
 {{{#!hs
 instance (GUnbox f r) => GUnbox (M1 i t f) r where
     type GUnboxed (M1 i t f) r = GUnboxed f r
     gunbox (M1 x) = gunbox x
 }}}

 But unboxed sum also fails to compile:


 {{{#!hs
 instance (GUnbox f rf, GUnbox g rg) => GUnbox (f :+: g) ('SumRep '[rf,
 rg]) where
     type GUnboxed (f :+: g) ('SumRep '[rf, rg]) = (# GUnboxed f rf |
 GUnboxed g rg #)
     gunbox (L1 l) = (# gunbox l | #)
     gunbox (R1 r) = (# | gunbox r #)
 }}}
 with the same message.

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


More information about the ghc-tickets mailing list