1 {-# LANGUAGE FlexibleContexts #-}
2 {-# LANGUAGE FlexibleInstances #-}
4 {-# LANGUAGE MultiParamTypeClasses #-}
5 {-# LANGUAGE PatternSynonyms #-}
6 {-# LANGUAGE TypeFamilies #-}
7 {-# LANGUAGE ScopedTypeVariables #-}
8 {-# LANGUAGE UndecidableInstances #-}
9 {-# OPTIONS_GHC -fno-warn-missing-methods #-}
10 {-# OPTIONS_GHC -fno-warn-orphans #-}
12 module Language.Symantic.Type.Var
13 ( module Language.Symantic.Type.Var
14 , module Language.Symantic.Lib.Data.Peano
17 import Data.Type.Equality ((:~:)(Refl))
18 import Language.Symantic.Lib.Data.Peano
19 import Language.Symantic.Type.Root
20 import Language.Symantic.Type.Type0
21 import Language.Symantic.Type.Type1
24 newtype Var0 = Var0 EPeano
25 type instance Host0_of EPeano = Var0
27 -- | Undefined instance required to build errors.
29 -- | Undefined instance required to build errors.
31 -- | Undefined instance required to build errors.
35 newtype Var1 a = Var1 EPeano
36 type instance Host1_of EPeano = Var1
39 -- | The variable type of kind @*@.
40 type Type_Var0 = Type_Type0 EPeano
42 pattern Type_Var0 :: SPeano p -> Type_Var0 root Var0
43 pattern Type_Var0 p = Type_Type0 (EPeano p)
45 instance Eq_Type1 (Type_Var0 root) where
46 instance -- String_from_Type
47 String_from_Type (Type_Var0 root) where
48 string_from_type (Type_Type0 (EPeano p)) =
49 "t" ++ show (integral_from_peano p::Integer)
51 -- | Inject 'Type_Var0' within a root type.
52 type_var0 :: Lift_Type_Root Type_Var0 root => SPeano p -> root Var0
53 type_var0 = lift_type_root . Type_Type0 . EPeano
56 -- | The variable type of kind @* -> *@.
57 type Type_Var1 = Type_Type1 EPeano
59 pattern Type_Var1 :: SPeano p -> root a -> Type_Var1 root (Var1 a)
60 pattern Type_Var1 p a = Type_Type1 (EPeano p) a
62 instance Eq_Type1 (Type_Var1 root) where
63 eq_type1 (Type_Type1 p1 _) (Type_Type1 p2 _)
66 eq_type1 _ _ = Nothing
67 instance -- String_from_Type
68 String_from_Type root =>
69 String_from_Type (Type_Var1 root) where
70 string_from_type (Type_Type1 (EPeano p) a) =
71 "t_" ++ show (integral_from_peano p::Integer) ++
72 " " ++ string_from_type a
74 -- | Inject 'Type_Var1' within a root type.
75 type_var1 :: Lift_Type_Root Type_Var1 root => SPeano p -> root a -> root (Var1 a)
76 type_var1 p = lift_type_root . Type_Var1 p