Embrace -XTypeInType, add -XStarIsType
[ghc.git] / testsuite / tests / determinism / determ014 / A.hs
1 {-# LANGUAGE
2 ScopedTypeVariables
3 , DataKinds
4 , GADTs
5 , RankNTypes
6 , TypeOperators
7 , PolyKinds -- Comment out PolyKinds and the bug goes away.
8 #-}
9 {-# OPTIONS_GHC -O #-}
10 -- The bug is in SimplUtils.abstractFloats, so we need -O to trigger it
11
12 module KeyValue where
13
14 import Data.Kind
15
16 data AccValidation err a = AccFailure err | AccSuccess a
17
18 data KeyValueError = MissingValue
19
20 type WithKeyValueError = AccValidation [KeyValueError]
21
22 missing :: forall f rs. RecApplicative rs => Rec (WithKeyValueError :. f) rs
23 missing = rpure missingField
24 where
25 missingField :: forall x. (WithKeyValueError :. f) x
26 missingField = Compose $ AccFailure [MissingValue]
27
28 data Rec :: (u -> Type) -> [u] -> Type where
29 RNil :: Rec f '[]
30 (:&) :: !(f r) -> !(Rec f rs) -> Rec f (r ': rs)
31
32 newtype Compose (f :: l -> Type) (g :: k -> l) (x :: k)
33 = Compose { getCompose :: f (g x) }
34
35 type (:.) f g = Compose f g
36
37 class RecApplicative rs where
38 rpure
39 :: (forall x. f x)
40 -> Rec f rs