]> Git — Sourcephile - haskell/symantic.git/blob - Language/Symantic/Type/Unit.hs
init
[haskell/symantic.git] / Language / Symantic / Type / Unit.hs
1 {-# LANGUAGE FlexibleContexts #-}
2 {-# LANGUAGE GADTs #-}
3 {-# LANGUAGE MultiParamTypeClasses #-}
4 {-# LANGUAGE TypeFamilies #-}
5 {-# OPTIONS_GHC -fno-warn-missing-methods #-}
6 module Language.Symantic.Type.Unit where
7
8 import Data.Maybe (isJust)
9 import Data.Type.Equality ((:~:)(Refl))
10
11 import Language.Symantic.Type.Common
12
13 -- * Type 'Type_Unit'
14 -- | The unit type.
15 data Type_Unit (root:: * -> *) h where
16 Type_Unit :: Type_Unit root ()
17 type instance Root_of_Type (Type_Unit root) = root
18 type instance Error_of_Type ast (Type_Unit root) = No_Error_Type
19
20 instance -- Eq_Type
21 Eq_Type (Type_Unit root) where
22 eq_type Type_Unit Type_Unit = Just Refl
23 instance -- Eq
24 Eq (Type_Unit root h) where
25 x == y = isJust $ x `eq_type` y
26 instance -- String_from_Type
27 String_from_Type (Type_Unit root) where
28 string_from_type Type_Unit = "Unit"
29 instance -- Show
30 Show (Type_Unit root h) where
31 show = string_from_type
32 instance Constraint_Type Eq (Type_Unit root) where
33 constraint_type _c Type_Unit = Just Dict
34 instance Constraint_Type Ord (Type_Unit root) where
35 constraint_type _c Type_Unit = Just Dict
36 instance Unlift_Type1 Type_Unit
37 instance Eq_Type1 (Type_Unit root)
38
39 -- | Convenient alias to include a 'Type_Unit' within a type.
40 type_unit :: Type_Root_Lift Type_Unit root => root ()
41 type_unit = type_root_lift Type_Unit