[GHC] #10697: Change template-haskell API to allow NOUNPACK, lazy annotations
GHC
ghc-devs at haskell.org
Tue Dec 8 20:46:49 UTC 2015
#10697: Change template-haskell API to allow NOUNPACK, lazy annotations
-------------------------------------+-------------------------------------
Reporter: RyanGlScott | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Template Haskell | Version: 7.10.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #5290, #8347 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Description changed by RyanGlScott:
Old description:
> 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.
New description:
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 #-} Int -- NOUNPACK, no strictness
data A = A {-# NOUNPACK #-} !Int -- NOUNPACK, strict
data A = A {-# NOUNPACK #-} ~Int -- NOUNPACK, lazy
data A = A {-# UNPACK #-} Int -- UNPACK, no strictness
data A = A {-# UNPACK #-} !Int -- UNPACK, strict
data A = A {-# UNPACK #-} ~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
| IsLazy
| NoStrictAnnot
data Unpack
= Unpack
| NoUnpack
| NoUnpackAnnot
type UnpackStrict = (Unpack, Strict)
type UnpackStrictType = (UnpackStrict, Type)
type VarUnpackStrictType = (Name, UnpackStrict, Type)
type StrictType = UnpackStrictType
type VarStrictType = VarUnpackStrictType
}}}
And so on.
--
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10697#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list