summaryrefslogtreecommitdiff
path: root/testsuite/tests/unboxedsums/unboxedsums9.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/unboxedsums/unboxedsums9.hs')
-rw-r--r--testsuite/tests/unboxedsums/unboxedsums9.hs26
1 files changed, 26 insertions, 0 deletions
diff --git a/testsuite/tests/unboxedsums/unboxedsums9.hs b/testsuite/tests/unboxedsums/unboxedsums9.hs
new file mode 100644
index 0000000000..79927fc58b
--- /dev/null
+++ b/testsuite/tests/unboxedsums/unboxedsums9.hs
@@ -0,0 +1,26 @@
+{-# LANGUAGE UnboxedSums, UnboxedTuples, MagicHash #-}
+
+module Main where
+
+type UbxBool = (# (# #) | (# #) #)
+
+{-# NOINLINE packBool #-}
+packBool :: UbxBool -> Bool
+packBool (# _ | #) = True
+packBool (# | _ #) = False
+
+{-# NOINLINE unpackBool #-}
+unpackBool :: Bool -> UbxBool
+unpackBool True = (# (# #) | #)
+unpackBool False = (# | (# #) #)
+
+{-# NOINLINE showUbxBool #-}
+showUbxBool :: UbxBool -> String
+showUbxBool b = show (packBool b)
+
+main :: IO ()
+main = do
+ putStrLn (showUbxBool (unpackBool True))
+ putStrLn (showUbxBool (unpackBool False))
+ putStrLn (show (packBool (# (# #) | #)))
+ putStrLn (show (packBool (# | (# #) #)))