summaryrefslogtreecommitdiff
path: root/testsuite/tests/unboxedsums/unboxedsums7.hs
blob: d64dabb13a8002c8820f0bc999629105fb6e3a30 (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
{-# LANGUAGE UnboxedSums, UnboxedTuples, MagicHash #-}

module Main where

import GHC.Prim
import GHC.Types

type Either1 a b c = (# a | (# b, c #) #)

-- The bug disappears when this is inlined
{-# NOINLINE showEither1 #-}

showEither1 :: Either1 String Int Bool -> String
showEither1 (# left | #) = "Left " ++ show left
showEither1 (# | (# right1, right2 #) #) = "Right " ++ show right1 ++ " " ++ show right2

main :: IO ()
main = do
    -- This line used to print "Right -4611686018427359531 False"
    putStrLn (showEither1 e1_2)
  where
    -- boxed types only
    e1_2 :: Either1 String Int Bool
    e1_2 = (# | (# 10, True #) #)