blob: 7ef60b79aed0f9a413bfaf87fe81d4f87b4c3570 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
{-# LANGUAGE StrictData, TemplateHaskell #-}
module T10697_sourceUtil where
import Language.Haskell.TH
makeSimpleDatatype :: Name
-> Name
-> SourceUnpackednessQ
-> SourceStrictnessQ
-> Q Dec
makeSimpleDatatype tyName conName srcUpk srcStr =
dataD (cxt []) tyName [] Nothing [normalC conName
[bangType (bang srcUpk srcStr) (conT ''Int)]] []
checkBang :: Name
-> SourceUnpackednessQ
-> SourceStrictnessQ
-> ExpQ
checkBang n srcUpk1 srcStr1 = do
TyConI (DataD _ _ _ _ [NormalC _ [(Bang srcUpk2 srcStr2, _)]] _) <- reify n
srcUpk1' <- srcUpk1
srcStr1' <- srcStr1
if srcUpk1' == srcUpk2 && srcStr1' == srcStr2
then [| True |]
else [| False |]
data E1 = E1 Int -- No unpackedness, no strictness
data E2 = E2 !Int -- No unpackedness, strict
data E3 = E3 ~Int -- No unpackedness, lazy
data E4 = E4 {-# NOUNPACK #-} Int -- NOUNPACK, no strictness
data E5 = E5 {-# NOUNPACK #-} !Int -- NOUNPACK, strict
data E6 = E6 {-# NOUNPACK #-} ~Int -- NOUNPACK, lazy
data E7 = E7 {-# UNPACK #-} Int -- UNPACK, no strictness
data E8 = E8 {-# UNPACK #-} !Int -- UNPACK, strict
data E9 = E9 {-# UNPACK #-} ~Int -- UNPACK, lazy
|