Forked from
Glasgow Haskell Compiler / GHC
5433 commits behind the upstream repository.
-
This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types].
This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types].
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
unpack_sums_8.hs 514 B
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE UnboxedSums #-}
module Main where
data Void
data WithVoid = LV Void | RV
data EnumT = L | R
deriving Show
data BoxEnum = BoxEnum {-# UNPACK #-} !EnumT
deriving Show
l = BoxEnum L
r = BoxEnum R
main = do
print l
print r
data BoxWithVoid = BoxWithVoid {-# UNPACK #-} !WithVoid
wv = BoxWithVoid (LV undefined)
data BoxVoid = BoxVoid {-# UNPACK #-} Void
bv = BoxVoid undefined
data BoxSum = BoxS {-# UNPACK #-} !(# Int | Char #)
bs = BoxS (# 1 | #)