summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghci/should_run/T19628a.hs
blob: ccecf4e4f6b8ca867bdc8acfc8efaa3c5cff56d2 (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
{- test GHCi support for unlifted types -}

{-# LANGUAGE UnliftedDatatypes #-}
{-# OPTIONS_GHC -fobject-code #-}

module T19628a where

import GHC.Exts
import GHC.Arr

import Data.Kind
import Control.Exception

-- unlifted but boxed datatypes
type Strict :: Type -> TYPE ('BoxedRep 'Unlifted)
data Strict a = Force a

type Strict2 :: Type -> TYPE ('BoxedRep 'Unlifted)
data Strict2 a = Force2 a a

{-# NOINLINE addStrict #-}
addStrict :: Strict Int -> Strict Int -> Strict Int
addStrict (Force x) (Force y) = Force (x+y)

{-# NOINLINE unStrict #-}
unStrict :: Strict a -> a
unStrict (Force x) = x

{-# NOINLINE toStrict #-}
toStrict :: a -> Strict a
toStrict x = Force x