1 {-# LANGUAGE FlexibleContexts #-}
3 {-# LANGUAGE MultiParamTypeClasses #-}
4 {-# LANGUAGE TypeFamilies #-}
5 {-# OPTIONS_GHC -fno-warn-missing-methods #-}
7 module Language.Symantic.Type.Var
8 ( module Language.Symantic.Type.Var
9 , module Language.Symantic.Lib.Data.Peano
12 import Data.Maybe (isJust)
14 import Language.Symantic.Type.Common
15 import Language.Symantic.Lib.Data.Peano
18 -- | The variable type.
19 data Type_Var (root:: * -> *) p where
20 Type_Var :: SPeano p -> Type_Var root p
21 type instance Root_of_Type (Type_Var root) = root
22 type instance Error_of_Type ast (Type_Var root) = No_Error_Type
25 Eq_Type (Type_Var root) where
26 eq_type (Type_Var x) (Type_Var y) = x `peano_eq` y
28 Eq (Type_Var root h) where
29 x == y = isJust $ x `eq_type` y
30 instance -- String_from_Type
31 String_from_Type (Type_Var root) where
32 string_from_type (Type_Var p) =
33 "t" ++ show (integral_from_peano p::Integer)
35 Show (Type_Var root h) where
36 show = string_from_type
37 instance Constraint_Type Eq (Type_Var root)
38 instance Constraint_Type Ord (Type_Var root)
39 instance Unlift_Type1 Type_Var
40 instance Eq_Type1 (Type_Var root)
42 -- | Convenient alias to include a 'Type_Var' within a type.
43 type_var :: Type_Root_Lift Type_Var root => SPeano p -> root p
44 type_var = type_root_lift . Type_Var