1 {-# LANGUAGE FlexibleContexts #-}
3 {-# LANGUAGE MultiParamTypeClasses #-}
4 {-# LANGUAGE TypeFamilies #-}
5 module Language.Symantic.Type.Unit where
7 import Data.Maybe (isJust)
8 import Data.Type.Equality ((:~:)(Refl))
10 import Language.Symantic.Type.Common
14 data Type_Unit (root:: * -> *) h where
15 Type_Unit :: Type_Unit root ()
16 type instance Root_of_Type (Type_Unit root) = root
17 type instance Error_of_Type ast (Type_Unit root) = No_Error_Type
20 Eq_Type (Type_Unit root) where
21 eq_type Type_Unit Type_Unit = Just Refl
23 Eq (Type_Unit root h) where
24 x == y = isJust $ x `eq_type` y
25 instance -- String_from_Type
26 String_from_Type (Type_Unit root) where
27 string_from_type Type_Unit = "Unit"
29 Show (Type_Unit root h) where
30 show = string_from_type
31 instance Constraint_Type Eq (Type_Unit root) where
32 constraint_type _c Type_Unit = Just Dict
33 instance Constraint_Type Ord (Type_Unit root) where
34 constraint_type _c Type_Unit = Just Dict
36 -- | Convenient alias to include a 'Type_Unit' within a type.
37 type_unit :: Type_Root_Lift Type_Unit root => root ()
38 type_unit = type_root_lift Type_Unit