1 {-# LANGUAGE FlexibleContexts #-}
3 {-# LANGUAGE MultiParamTypeClasses #-}
4 {-# LANGUAGE TypeFamilies #-}
5 module TFHOE.Type.Bool where
7 import Data.Maybe (isJust)
8 import Data.Type.Equality ((:~:)(Refl))
11 import TFHOE.Type.Common
16 -- | GADT for integer type:
18 -- * singleton (bijective mapping between Haskell type @h@ and the GADT's terms),
19 -- * and extensible (through @next@).
20 data Type_Bool (next:: * -> *) h where
21 Type_Bool :: Type_Bool next Bool -- Introduce an 'Bool' type.
22 Type_Bool_Next :: next h -> Type_Bool next h -- Introduce a type extension @next@.
24 type Type_Fun_Bool fun next = Type_Fun fun (Type_Bool next)
25 type Type_Fun_Bool_End fun = Type_Fun_Bool fun Type_End
29 Type_Eq (Type_Bool next) where
30 type_eq Type_Bool Type_Bool = Just Refl
31 type_eq (Type_Bool_Next x) (Type_Bool_Next y) = x `type_eq` y
35 Eq (Type_Bool next h) where
36 x == y = isJust $ type_eq x y
37 instance -- Type_from Raw
39 Type_from Raw (Type_Bool next) where
40 type_from (Raw "Bool" []) k = k Type_Bool
41 type_from raw k = type_from raw $ k . Type_Bool_Next
42 instance -- String_from_Type
43 String_from_Type next =>
44 String_from_Type (Type_Bool next) where
45 string_from_type Type_Bool = "Bool"
46 string_from_type (Type_Bool_Next t) = string_from_type t
48 String_from_Type next =>
49 Show (Type_Bool next h) where
50 show = string_from_type