[GHC] #10697: Change template-haskell API to allow NOUNPACK, lazy annotations

GHC ghc-devs at haskell.org
Tue Jul 28 03:49:59 UTC 2015


#10697: Change template-haskell API to allow NOUNPACK, lazy annotations
-------------------------------------+-------------------------------------
              Reporter:              |             Owner:
  RyanGlScott                        |
                  Type:  feature     |            Status:  new
  request                            |
              Priority:  normal      |         Milestone:
             Component:  Template    |           Version:  7.10.1
  Haskell                            |
              Keywords:              |  Operating System:  Unknown/Multiple
          Architecture:              |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
             Test Case:              |        Blocked By:
              Blocking:              |   Related Tickets:  #8347
Differential Revisions:              |
-------------------------------------+-------------------------------------
 Currently, the {{{template-haskell}}} API is lagging behind what is
 possible with GHC's strictness annotations in data types, especially since
 the advent of {{{StrictData}}}. Currently, {{{template-haskell}}} has
 {{{Strict}}}:

 {{{#!hs
 data Strict
   = IsStrict
   | NotStrict
   | Unpacked
 }}}

 But it appears that there are actually nine different combinations of
 packedness and strictness annotations:

 {{{#!hs
 data A = A                     Int -- No unpackedness, no strictness
 data A = A                    !Int -- No unpackedness, strict
 data A = A                    ~Int -- No unpackedness, lazy
 data A = A {-# NOUNPACK #-} A  Int -- NOUNPACK, no strictness
 data A = A {-# NOUNPACK #-} A !Int -- NOUNPACK, strict
 data A = A {-# NOUNPACK #-} A ~Int -- NOUNPACK, lazy
 data A = A {-#   UNPACK #-} A  Int -- UNPACK, no strictness
 data A = A {-#   UNPACK #-} A !Int -- UNPACK, strict
 data A = A {-#   UNPACK #-} A ~Int -- UNPACK, lazy
 }}}

 It seems like the most consistent thing to do would be change {{{Strict}}}
 and add {{{Unpack}}} to the {{{template-haskell}}} API:

 {{{#!hs
 data Strict
   = IsStrict
   | NotStrict
   | IsLazy

 data Unpack
   = Unpack
   | NoUnpack
   | NotUnpacked

 type UnpackStrictType = (Unpack, Strict, Type)

 type VarUnpackStrictType = (Name, Unpack, Strict, Type)
 }}}

 And so on.

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


More information about the ghc-tickets mailing list