]> Git — Sourcephile - haskell/symantic.git/blob - Language/LOL/Symantic/Type/Unit.hs
init
[haskell/symantic.git] / Language / LOL / Symantic / Type / Unit.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.Unit where
9
10 import Data.Maybe (isJust)
11 import Data.Type.Equality ((:~:)(Refl))
12
13 import Language.LOL.Symantic.Type.Common
14
15 -- * Type 'Type_Unit'
16 -- | The unit type.
17 data Type_Unit (root:: * -> *) h where
18 Type_Unit :: Type_Unit root ()
19 type instance Root_of_Type (Type_Unit root) = root
20 type instance Error_of_Type ast (Type_Unit root) = ()
21
22 instance -- Type_Eq
23 Type_Eq (Type_Unit root) where
24 type_eq Type_Unit Type_Unit = Just Refl
25 instance -- Eq
26 Eq (Type_Unit root h) where
27 x == y = isJust $ x `type_eq` y
28 instance -- String_from_Type
29 String_from_Type (Type_Unit root) where
30 string_from_type Type_Unit = "Unit"
31 instance -- Show
32 Show (Type_Unit root h) where
33 show = string_from_type
34 instance Type_Constraint Eq (Type_Unit root) where
35 type_constraint _c Type_Unit = Just Dict
36 instance Type_Constraint Ord (Type_Unit root) where
37 type_constraint _c Type_Unit = Just Dict
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