1 {-# LANGUAGE FlexibleInstances #-}
3 {-# LANGUAGE MultiParamTypeClasses #-}
4 {-# LANGUAGE TypeFamilies #-}
5 {-# LANGUAGE UndecidableInstances #-}
6 module Language.Symantic.Type.Type2 where
8 import Data.Maybe (isJust)
10 import Data.Type.Equality ((:~:)(Refl))
11 import GHC.Prim (Constraint)
13 import Language.Symantic.Lib.Data.Peano
14 -- import Language.Symantic.Lib.Data.Bool
15 import Language.Symantic.Type.Root
16 -- import Language.Symantic.Type.Alt
17 import Language.Symantic.Type.Error
18 import Language.Symantic.Type.Type0
19 import Language.Symantic.Type.Type1
21 -- * Type 'Type_Type2'
22 data Type_Type2 px (root:: * -> *) h where
24 :: (Constraint2_of px) a b
25 => px -> root a -> root b
26 -> Type_Type2 px root ((Host2_of px) a b)
27 class Constraint2_Empty a b
28 instance Constraint2_Empty a b
30 type instance Root_of_Type (Type_Type2 px root) = root
31 type instance Error_of_Type ast (Type_Type2 px root) = No_Error_Type
35 Eq_Type (Type_Type2 (Proxy h2) root) where
37 (Type_Type2 _ arg1 res1)
38 (Type_Type2 _ arg2 res2)
39 | Just Refl <- arg1 `eq_type` arg2
40 , Just Refl <- res1 `eq_type` res2
45 Eq_Type (Type_Type2 EPeano root) where
46 eq_type (Type_Type2 p1 arg1 res1)
47 (Type_Type2 p2 arg2 res2)
49 , Just Refl <- arg1 `eq_type` arg2
50 , Just Refl <- res1 `eq_type` res2
55 Eq (Type_Type2 (Proxy h2) root h) where
56 x == y = isJust $ x `eq_type` y
59 Eq (Type_Type2 EPeano root h) where
60 x == y = isJust $ x `eq_type` y
62 ( String_from_Type root
63 , String_from_Type (Type_Type2 px root)
64 ) => Show (Type_Type2 px root h) where
65 show = string_from_type
66 instance Constraint_Type Eq (Type_Type2 px root)
67 instance Constraint_Type Ord (Type_Type2 px root)
68 instance Unlift_Type1 (Type_Type2 px) -- FIXME: should be doable
69 instance Eq_Type1 (Type_Type2 px root) -- FIXME: should be doable
72 type family Host2_of px :: * -> * -> *
73 type instance Host2_of (Proxy h2) = h2
75 -- ** Type 'Constraint2_of'
76 type family Constraint2_of px :: (* -> * -> Constraint)