{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} module Language.LOL.Symantic.Type.Bool where import Data.Maybe (isJust) import Data.Type.Equality ((:~:)(Refl)) import Language.LOL.Symantic.AST import Language.LOL.Symantic.Type.Common import Language.LOL.Symantic.Type.Fun import Language.LOL.Symantic.Type.Var -- * Type 'Type_Bool' -- | The 'Bool' type. data Type_Bool (root:: * -> *) h where Type_Bool :: Type_Bool root Bool type instance Root_of_Type (Type_Bool root) = root type instance Error_of_Type ast (Type_Bool root) = () instance -- Type_Eq Type_Eq (Type_Bool root) where type_eq Type_Bool Type_Bool = Just Refl instance -- Eq Eq (Type_Bool root h) where x == y = isJust $ x `type_eq` y instance -- Type_from AST ( Type_Root_Lift Type_Bool root , Error_Type_Lift (Error_Type AST) (Error_of_Type AST root) , Implicit_HBool (Is_Last_Type (Type_Bool root) root) ) => Type_from AST (Type_Bool root) where type_from px_ty ast k = case ast of AST "Bool" asts -> case asts of [] -> k $ type_root_lift Type_Bool _ -> Left $ error_type_lift $ Error_Type_Wrong_number_of_arguments ast 0 _ -> Left $ error_type_unsupported px_ty ast instance -- String_from_Type String_from_Type (Type_Bool root) where string_from_type Type_Bool = "Bool" instance -- Show Show (Type_Bool root h) where show = string_from_type -- | Convenient alias to include a 'Type_Bool' within a type. type_bool :: Type_Root_Lift Type_Bool root => root Bool type_bool = type_root_lift Type_Bool -- * Type 'Type_Fun_Bool' -- | Convenient alias. type Type_Fun_Bool lam = Type_Root (Type_Alt Type_Var (Type_Alt (Type_Fun lam) Type_Bool))