summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_compile/T18023.hs
blob: 9961c95b2470cb1ceac7a0981f4b50a220a15b75 (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
39
40
41
42
43
44
45
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneKindSignatures #-}
module T18023 where

import Data.Kind
import Data.Proxy

newtype N :: Type -> Type -> Type where
  MkN :: forall b a. { unN :: Either a b } -> N a b

toN :: Either Int Bool -> N Int Bool
toN = MkN @Bool @Int

fromN :: N Int Bool -> Either Int Bool
fromN = unN @Bool @Int

newtype P a = MkP { unP :: Proxy a }

toPTrue :: Proxy True -> P True
toPTrue = MkP @True

fromPTrue :: P True -> Proxy True
fromPTrue = unP @True

newtype P2 a b = MkP2 { unP2 :: (Proxy a, Proxy b) }

toP2True :: (Proxy True, Proxy True) -> P2 True True
toP2True = MkP2 @True @True

fromP2True :: P2 True True -> (Proxy True, Proxy True)
fromP2True = unP2 @True @True

type    P3 :: forall {k}. k -> Type
newtype P3 a = MkP3 { unP3 :: Proxy a }

toP3True :: Proxy True -> P3 True
toP3True = MkP3 @True

fromP3True :: P3 True -> Proxy True
fromP3True = unP3 @True