Change template-haskell API to allow NOUNPACK, lazy annotations
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
:
data Strict
= IsStrict
| NotStrict
| Unpacked
But it appears that there are actually nine different combinations of packedness and strictness annotations:
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:
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.