{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Language.Symantic.Type.Either where import Data.Proxy import Language.Symantic.Type.Root import Language.Symantic.Type.Type0 import Language.Symantic.Type.Type2 -- * Type 'Type_Either' -- | The 'Either' type. type Type_Either = Type_Type2 (Proxy Either) type instance Constraint2_of (Proxy Either) = Constraint2_Empty pattern Type_Either :: root a -> root b -> Type_Either root (Either a b) pattern Type_Either a b = Type_Type2 Proxy a b instance -- String_from_Type String_from_Type root => String_from_Type (Type_Either root) where string_from_type (Type_Type2 _ a b) = "Either" ++ " (" ++ string_from_type a ++ ")" ++ " (" ++ string_from_type b ++ ")" -- | Inject 'Type_Either' within a root type. type_either :: forall root h_a h_b. Lift_Type_Root Type_Either root => root h_a -> root h_b -> root (Either h_a h_b) type_either a b = lift_type_root (Type_Either a b ::Type_Either root (Either h_a h_b))