Fix #17334 where NCG did not properly update the CFG.
[ghc.git] / testsuite / tests / typecheck / should_compile / T13848.hs
1 {-# LANGUAGE DataKinds #-}
2 {-# LANGUAGE ExistentialQuantification #-}
3 {-# LANGUAGE GADTs #-}
4 {-# LANGUAGE KindSignatures #-}
5 {-# LANGUAGE ScopedTypeVariables #-}
6 {-# LANGUAGE TypeApplications #-}
7 module T13848 where
8
9 data N = Z | S N
10
11 data Vec1 (n :: N) a where
12 VNil1 :: forall a. Vec1 Z a
13 VCons1 :: forall n a. a -> Vec1 n a -> Vec1 (S n) a
14
15 data Vec2 (n :: N) a where
16 VNil2 :: Vec2 Z a
17 VCons2 :: a -> Vec2 n a -> Vec2 (S n) a
18
19 data Vec3 (n :: N) a
20 = (n ~ Z) => VNil3
21 | forall (n' :: N). (n ~ S n') => VCons3 a (Vec3 n' a)
22
23 vcons1 :: Vec1 (S Z) Int
24 vcons1 = VCons1 @Z @Int 1 (VNil1 @Int)
25
26 vcons2 :: Vec2 (S Z) Int
27 vcons2 = VCons2 @Int @Z 1 (VNil2 @Int)
28
29 vcons3 :: Vec3 (S Z) Int
30 vcons3 = VCons3 @(S Z) @Int @Z 1 (VNil3 @Z @Int)
31
32 newtype Result1 a s = Ok1 s
33
34 newtype Result2 a s where
35 Ok2 :: s -> Result2 a s
36
37 result1 :: Result1 Int Char
38 result1 = Ok1 @Int @Char 'a'
39
40 result2 :: Result2 Int Char
41 result2 = Ok2 @Char @Int 'a'