Embrace -XTypeInType, add -XStarIsType
[ghc.git] / testsuite / tests / polykinds / T12055.hs
1 {-# LANGUAGE ConstraintKinds #-}
2 {-# LANGUAGE MultiParamTypeClasses #-}
3 {-# LANGUAGE NoImplicitPrelude #-}
4 {-# LANGUAGE RankNTypes #-}
5 {-# LANGUAGE TypeFamilies #-}
6 {-# LANGUAGE TypeOperators #-}
7 {-# LANGUAGE DataKinds #-}
8 {-# LANGUAGE PolyKinds #-}
9
10 -- The code from the ticket lacked these extensions,
11 -- but crashed the compiler with "GHC internal error"
12 -- It doesn't crash now; and in this test case I've added
13 -- the extensions, which makes it compile cleanly
14 {-# LANGUAGE FlexibleContexts, FlexibleInstances, UndecidableInstances, FunctionalDependencies #-}
15
16
17 module T12055 where
18
19 import GHC.Base ( Constraint, Type )
20 import GHC.Exts ( type (~~) )
21
22 type Cat k = k -> k -> Type
23
24 class Category (p :: Cat k) where
25 type Ob p :: k -> Constraint
26
27 class (Category (Dom f), Category (Cod f)) => Functor (f :: j -> k) where
28 type Dom f :: Cat j
29 type Cod f :: Cat k
30 functor :: forall a b.
31 Iso Constraint (:-) (:-)
32 (Ob (Dom f) a) (Ob (Dom f) b)
33 (Ob (Cod f) (f a)) (Ob (Cod f) (f b))
34
35 class (Functor f , Dom f ~ p, Cod f ~ q) =>
36 Fun (p :: Cat j) (q :: Cat k) (f :: j -> k) | f -> p q
37 instance (Functor f , Dom f ~ p, Cod f ~ q) =>
38 Fun (p :: Cat j) (q :: Cat k) (f :: j -> k)
39
40 data Nat (p :: Cat j) (q :: Cat k) (f :: j -> k) (g :: j -> k)
41
42 type Iso k (c :: Cat k) (d :: Cat k) s t a b =
43 forall p. (Cod p ~~ Nat d (->)) => p a b -> p s t
44
45 data (p :: Constraint) :- (q :: Constraint)