]> 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
38 -- | Convenient alias to include a 'Type_Int' within a type.
39 type_int :: Type_Root_Lift Type_Int root => root Int
40 type_int = type_root_lift Type_Int
41
42 -- * Type 'Type_Fun_Int'
43 -- | Convenient alias.
44 type Type_Fun_Int lam
45 = Type_Root (Type_Alt Type_Var
46 (Type_Alt (Type_Fun lam)
47 Type_Int))
48
49 -- * Type 'Type_Fun_Bool_Int'
50 -- | Convenient alias.
51 type Type_Fun_Bool_Int lam
52 = Type_Root (Type_Alt Type_Var
53 (Type_Alt (Type_Fun lam)
54 (Type_Alt Type_Bool
55 Type_Int)))