]> Git — Sourcephile - haskell/symantic.git/blob - Language/LOL/Symantic/Type/Int.hs
init
[haskell/symantic.git] / Language / LOL / Symantic / Type / Int.hs
1 {-# LANGUAGE FlexibleContexts #-}
2 {-# LANGUAGE GADTs #-}
3 {-# LANGUAGE MultiParamTypeClasses #-}
4 {-# LANGUAGE OverloadedStrings #-}
5 {-# LANGUAGE ScopedTypeVariables #-}
6 {-# LANGUAGE TypeFamilies #-}
7 {-# LANGUAGE UndecidableInstances #-}
8 module Language.LOL.Symantic.Type.Int where
9
10 import Data.Maybe (isJust)
11 import Data.Type.Equality ((:~:)(Refl))
12
13 import Language.LOL.Symantic.Type.Common
14 import Language.LOL.Symantic.Type.Fun
15 import Language.LOL.Symantic.Type.Bool
16 import Language.LOL.Symantic.Type.Var
17
18 -- * Type 'Type_Int'
19 -- | The 'Int' type.
20 data Type_Int (root:: * -> *) h where
21 Type_Int :: Type_Int root Int
22 type instance Root_of_Type (Type_Int root) = root
23 type instance Error_of_Type ast (Type_Int root) = ()
24
25 instance -- Type_Eq
26 Type_Eq (Type_Int root) where
27 type_eq Type_Int Type_Int = Just Refl
28 instance -- Eq
29 Eq (Type_Int root h) where
30 x == y = isJust $ x `type_eq` y
31 instance -- String_from_Type
32 String_from_Type (Type_Int root) where
33 string_from_type Type_Int = "Int"
34 instance -- Show
35 Show (Type_Int root h) where
36 show = string_from_type
37 instance Type_Constraint Eq (Type_Int root) where
38 type_constraint _c Type_Int = Just Dict
39 instance Type_Constraint Ord (Type_Int root) where
40 type_constraint _c Type_Int = Just Dict
41
42 -- | Convenient alias to include a 'Type_Int' within a type.
43 type_int :: Type_Root_Lift Type_Int root => root Int
44 type_int = type_root_lift Type_Int
45
46 -- * Type 'Type_Fun_Int'
47 -- | Convenient alias.
48 type Type_Fun_Int lam
49 = Type_Root (Type_Alt Type_Var
50 (Type_Alt (Type_Fun lam)
51 Type_Int))
52
53 -- * Type 'Type_Fun_Bool_Int'
54 -- | Convenient alias.
55 type Type_Fun_Bool_Int lam
56 = Type_Root (Type_Alt Type_Var
57 (Type_Alt (Type_Fun lam)
58 (Type_Alt Type_Bool
59 Type_Int)))