summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_compile/UnliftedNewtypesUnassociatedFamily.hs
blob: dd7890d33c0395f1425f05e4d018c438b3eabed6 (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
36
37
38
{-# LANGUAGE UnliftedNewtypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeApplications #-}

module UnliftedNewtypesUnassociatedFamily where

import GHC.Int (Int(I#))
import GHC.Word (Word(W#))
import GHC.Exts (Int#,Word#)
import GHC.Exts (TYPE,Levity(Lifted))
import GHC.Exts (RuntimeRep(BoxedRep,IntRep,WordRep,TupleRep))

data family DFT (r :: RuntimeRep) :: TYPE r
newtype instance DFT 'IntRep = MkDFT1 Int#
newtype instance DFT 'WordRep = MkDFT2 Word#
newtype instance DFT ('TupleRep '[ 'IntRep, 'WordRep])
  = MkDFT3 (# Int#, Word# #)
data instance DFT ('BoxedRep 'Lifted) = MkDFT4 | MkDFT5

data family DF :: TYPE (r :: RuntimeRep)

-- Use a type application
newtype instance DF @IntRep = MkDF1 Int#

-- Use a kind signature
newtype instance DF :: TYPE 'WordRep where
  MkDF2 :: Word# -> DF

-- Also uses a kind signature
newtype instance DF :: TYPE ('TupleRep '[ 'IntRep, 'WordRep ]) where
  MkDF3 :: (# Int#, Word# #) -> DF

data instance DF = MkDF4 | MkDF5