Embrace -XTypeInType, add -XStarIsType
[ghc.git] / testsuite / tests / polykinds / T14846.hs
1 {-# LANGUAGE AllowAmbiguousTypes #-}
2 {-# LANGUAGE ConstraintKinds #-}
3 {-# LANGUAGE EmptyCase #-}
4 {-# LANGUAGE FlexibleInstances #-}
5 {-# LANGUAGE GADTs #-}
6 {-# LANGUAGE InstanceSigs #-}
7 {-# LANGUAGE MultiParamTypeClasses #-}
8 {-# LANGUAGE ScopedTypeVariables #-}
9 {-# LANGUAGE DataKinds, PolyKinds #-}
10 module T14846 where
11
12 import Data.Kind
13 import Data.Proxy
14
15 type Cat ob = ob -> ob -> Type
16
17 data Struct :: (k -> Constraint) -> Type where
18 S :: Proxy (a::k) -> Struct (cls::k -> Constraint)
19
20 type Structured a cls = (S ('Proxy :: Proxy a)::Struct cls)
21
22 data AStruct :: Struct cls -> Type where
23 AStruct :: cls a => AStruct (Structured a cls)
24
25 class StructI xx (structured::Struct (cls :: k -> Constraint)) where
26 struct :: AStruct structured
27
28 instance (Structured xx cls ~ structured, cls xx) => StructI xx structured where
29 struct :: AStruct (Structured xx cls)
30 struct = AStruct
31
32 data Hom :: Cat k -> Cat (Struct cls) where
33
34 class Category (cat::Cat ob) where
35 i :: StructI xx a => rĂ­ki a a
36
37 instance Category riki => Category (Hom riki :: Cat (Struct cls)) where
38 i :: forall xx a. StructI xx a => Hom riki a a
39 i = case struct :: AStruct (Structured a cls) of