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