]> 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 module Language.Symantic.Type.Int where
8
9 import Data.Maybe (isJust)
10 import Data.Type.Equality ((:~:)(Refl))
11
12 import Language.Symantic.Type.Common
13 import Language.Symantic.Type.Fun
14 import Language.Symantic.Type.Bool
15 import Language.Symantic.Type.Var
16
17 -- * Type 'Type_Int'
18 -- | The 'Int' type.
19 data Type_Int (root:: * -> *) h where
20 Type_Int :: Type_Int root Int
21 type instance Root_of_Type (Type_Int root) = root
22 type instance Error_of_Type ast (Type_Int root) = ()
23
24 instance -- Type_Eq
25 Type_Eq (Type_Int root) where
26 type_eq Type_Int Type_Int = Just Refl
27 instance -- Eq
28 Eq (Type_Int root h) where
29 x == y = isJust $ x `type_eq` y
30 instance -- String_from_Type
31 String_from_Type (Type_Int root) where
32 string_from_type Type_Int = "Int"
33 instance -- Show
34 Show (Type_Int root h) where
35 show = string_from_type
36 instance Type_Constraint Eq (Type_Int root) where
37 type_constraint _c Type_Int = Just Dict
38 instance Type_Constraint Ord (Type_Int root) where
39 type_constraint _c Type_Int = Just Dict
40
41 -- | Convenient alias to include a 'Type_Int' within a type.
42 type_int :: Type_Root_Lift Type_Int root => root Int
43 type_int = type_root_lift Type_Int
44
45 -- * Type 'Type_Fun_Int'
46 -- | Convenient alias.
47 type Type_Fun_Int lam
48 = Type_Root (Type_Alt Type_Var
49 (Type_Alt (Type_Fun lam)
50 Type_Int))
51
52 -- * Type 'Type_Fun_Bool_Int'
53 -- | Convenient alias.
54 type Type_Fun_Bool_Int lam
55 = Type_Root (Type_Alt Type_Var
56 (Type_Alt (Type_Fun lam)
57 (Type_Alt Type_Bool
58 Type_Int)))