]> Git — Sourcephile - haskell/symantic.git/blob - Language/Symantic/Type/Bool.hs
init
[haskell/symantic.git] / Language / Symantic / Type / Bool.hs
1 {-# LANGUAGE FlexibleContexts #-}
2 {-# LANGUAGE GADTs #-}
3 {-# LANGUAGE MultiParamTypeClasses #-}
4 {-# LANGUAGE OverloadedStrings #-}
5 {-# LANGUAGE ScopedTypeVariables #-}
6 {-# LANGUAGE TypeFamilies #-}
7 module Language.Symantic.Type.Bool 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.Var
15
16 -- * Type 'Type_Bool'
17 -- | The 'Bool' type.
18 data Type_Bool (root:: * -> *) h where
19 Type_Bool :: Type_Bool root Bool
20 type instance Root_of_Type (Type_Bool root) = root
21 type instance Error_of_Type ast (Type_Bool root) = ()
22
23 instance -- Type_Eq
24 Type_Eq (Type_Bool root) where
25 type_eq Type_Bool Type_Bool = Just Refl
26 instance -- Eq
27 Eq (Type_Bool root h) where
28 x == y = isJust $ x `type_eq` y
29 instance -- String_from_Type
30 String_from_Type (Type_Bool root) where
31 string_from_type Type_Bool = "Bool"
32 instance -- Show
33 Show (Type_Bool root h) where
34 show = string_from_type
35 instance Type_Constraint Eq (Type_Bool root) where
36 type_constraint _c Type_Bool = Just Dict
37 instance Type_Constraint Ord (Type_Bool root) where
38 type_constraint _c Type_Bool = Just Dict
39
40 -- | Convenient alias to include a 'Type_Bool' within a type.
41 type_bool :: Type_Root_Lift Type_Bool root => root Bool
42 type_bool = type_root_lift Type_Bool
43
44 -- * Type 'Type_Fun_Bool'
45 -- | Convenient alias.
46 type Type_Fun_Bool lam
47 = Type_Root (Type_Alt Type_Var
48 (Type_Alt (Type_Fun lam)
49 Type_Bool))