]> Git — Sourcephile - haskell/symantic.git/blob - Language/Symantic/Type/Int.hs
init
[haskell/symantic.git] / Language / Symantic / Type / Int.hs
1 {-# LANGUAGE FlexibleContexts #-}
2 {-# LANGUAGE GADTs #-}
3 {-# LANGUAGE MultiParamTypeClasses #-}
4 {-# LANGUAGE OverloadedStrings #-}
5 {-# LANGUAGE ScopedTypeVariables #-}
6 {-# LANGUAGE TypeFamilies #-}
7 {-# LANGUAGE TypeOperators #-}
8 module Language.Symantic.Type.Int where
9
10 import Data.Maybe (isJust)
11 import Data.Type.Equality ((:~:)(Refl))
12
13 import Language.Symantic.Type.Common
14
15 -- * Type 'Type_Int'
16 -- | The 'Int' type.
17 data Type_Int (root:: * -> *) h where
18 Type_Int :: Type_Int root Int
19 type instance Root_of_Type (Type_Int root) = root
20 type instance Error_of_Type ast (Type_Int root) = No_Error_Type
21
22 instance -- Eq_Type
23 Eq_Type (Type_Int root) where
24 eq_type Type_Int Type_Int = Just Refl
25 instance -- Eq
26 Eq (Type_Int root h) where
27 x == y = isJust $ x `eq_type` y
28 instance -- String_from_Type
29 String_from_Type (Type_Int root) where
30 string_from_type Type_Int = "Int"
31 instance -- Show
32 Show (Type_Int root h) where
33 show = string_from_type
34 instance Constraint_Type Eq (Type_Int root) where
35 constraint_type _c Type_Int = Just Dict
36 instance Constraint_Type Ord (Type_Int root) where
37 constraint_type _c Type_Int = Just Dict
38
39 -- | Convenient alias to include a 'Type_Int' within a type.
40 type_int :: Type_Root_Lift Type_Int root => root Int
41 type_int = type_root_lift Type_Int