1 {-# LANGUAGE FlexibleContexts #-}
3 {-# LANGUAGE MultiParamTypeClasses #-}
4 {-# LANGUAGE TypeFamilies #-}
6 module Language.Symantic.Type.Var
7 ( module Language.Symantic.Type.Var
8 , module Language.Symantic.Lib.Data.Peano
11 import Data.Maybe (isJust)
13 import Language.Symantic.Type.Common
14 import Language.Symantic.Lib.Data.Peano
17 -- | The variable type.
18 data Type_Var (root:: * -> *) p where
19 Type_Var :: SPeano p -> Type_Var root p
20 type instance Root_of_Type (Type_Var root) = root
21 type instance Error_of_Type ast (Type_Var root) = No_Error_Type
24 Type_Eq (Type_Var root) where
25 type_eq (Type_Var x) (Type_Var y) = x `peano_eq` y
27 Eq (Type_Var root h) where
28 x == y = isJust $ x `type_eq` y
29 instance -- String_from_Type
30 String_from_Type (Type_Var root) where
31 string_from_type (Type_Var p) =
32 "t" ++ show (integral_from_peano p::Integer)
34 Show (Type_Var root h) where
35 show = string_from_type
36 instance Type_Constraint Eq (Type_Var root)
37 instance Type_Constraint Ord (Type_Var root)
39 -- | Convenient alias to include a 'Type_Var' within a type.
40 type_var :: Type_Root_Lift Type_Var root => SPeano p -> root p
41 type_var = type_root_lift . Type_Var