-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Open type representations and dynamic types -- -- This package uses Data Types à la Carte to provide open type -- representations and dynamic types/coercions for open type universes. -- -- Example 1 (dynamic types): -- --
-- type MyUniverse = IntType :+: BoolType -- -- hlist :: [Dynamic MyUniverse] -- hlist = [toDyn True, toDyn (1 :: Int)] ---- --
-- *Main> hlist -- [True,1] ---- -- Note that if we were using Data.Dynamic, it would just print -- --
-- [<<Bool>>,<<Int>>] ---- -- Example 2 (dynamically typed addition): -- --
-- addDyn :: (TypeEq ts ts, PWitness Num ts ts) => Dynamic ts -> Dynamic ts -> Maybe (Dynamic ts) -- addDyn (Dyn ta a) (Dyn tb b) = do -- Dict <- typeEq ta tb -- Dict <- pwit pNum ta -- return (Dyn ta (a+b)) ---- -- Data.Dynamic could only do this monomorphically, for one -- Num type at a time. @package open-typerep @version 0.3.3 -- | Open type representations and dynamic types module Data.TypeRep.Internal -- | Full-indexed type representation type TR = AST -- | This class provides reification of type a in a universe -- t. Typeable t a means that a is in -- the type universe represented by t. class Typeable t a typeRep' :: Typeable t a => TR t (Full a) -- | Representation of type a in a type universe t -- -- This type can also be seen as a witness that a is a member of -- t (i.e. Typeable t a); see -- witTypeable. newtype TypeRep t a TypeRep :: TR t (Full a) -> TypeRep t a [unTypeRep] :: TypeRep t a -> TR t (Full a) -- | Reification of type a in a type universe t typeRep :: Typeable t a => TypeRep t a -- | Equality on type representations class Render t => TypeEq t u typeEqSym :: TypeEq t u => (t sig1, Args (AST u) sig1) -> (t sig2, Args (AST u) sig2) -> Either String (Dict (DenResult sig1 ~ DenResult sig2)) -- | Equality on type representations typeEq :: (TypeEq t t, MonadError String m) => TypeRep t a -> TypeRep t b -> m (Dict (a ~ b)) -- | Type constructor matching. This function makes it possible to match on -- type representations without dealing with the underlying AST -- representation. -- -- For example, to check that a TypeRep represents the type a -- -> Int for some a: -- --
-- is_atoi :: (TypeEq t t, IntType :<: t) => TypeRep t a -> Bool -- is_atoi t -- | [E ta, E tb] <- matchCon t -- , Just _ <- typeEq ta intType = True -- | otherwise = False --matchCon :: TypeRep t c -> [E (TypeRep t)] -- | Monadic version of matchCon -- --
-- matchConM = return . matchCon ---- -- matchConM is convenient when matching types in a monad, e.g.: -- --
-- do ... -- [E ta, E tb] <- matchConM t -- Dict <- typeEq ta tb -- ... --matchConM :: Monad m => TypeRep t c -> m [E (TypeRep t)] -- | Show the name of type classes class ShowClass (p :: * -> Constraint) -- | Show the name of a type class showClass :: ShowClass p => Proxy p -> String -- | Witness a type constraint for a reified type class Witness p t u witSym :: Witness p t u => t sig -> Args (AST u) sig -> Dict (p (DenResult sig)) -- | Partially witness a type constraint for a reified type class (ShowClass p, Render t) => PWitness p t u where pwitSym _ _ = throwError "" pwitSym :: PWitness p t u => t sig -> Args (AST u) sig -> Either String (Dict (p (DenResult sig))) -- | Default implementation of pwitSym for types that have a -- Witness instance pwitSymDefault :: Witness p t u => t sig -> Args (AST u) sig -> Either String (Dict (p (DenResult sig))) -- | Witness a type constraint for a reified type wit :: Witness p t t => Proxy p -> TypeRep t a -> Dict (p a) -- | Partially witness a type constraint for a reified type pwit :: (PWitness p t t, MonadError String m) => Proxy p -> TypeRep t a -> m (Dict (p a)) -- | Safe cast (does not use unsafeCoerce) cast :: (Typeable t a, Typeable t b, TypeEq t t) => Proxy t -> a -> Either String b -- | Safe generalized cast (does not use unsafeCoerce) gcast :: (Typeable t a, Typeable t b, TypeEq t t) => Proxy t -> c a -> Either String (c b) -- | Dynamic type parameterized on a type universe data Dynamic t Dyn :: TypeRep t a -> a -> Dynamic t toDyn :: Typeable t a => a -> Dynamic t fromDyn :: (Typeable t a, TypeEq t t) => Dynamic t -> Either String a -- | The universal class class Any a -- | Witness a Typeable constraint for a reified type witTypeable :: Witness (Typeable t) t t => TypeRep t a -> Dict (Typeable t a) -- | Partially witness a Typeable constraint for a reified type pwitTypeable :: PWitness (Typeable t) t t => TypeRep t a -> Either String (Dict (Typeable t a)) pAny :: Proxy Any pEq :: Proxy Eq pOrd :: Proxy Ord pShow :: Proxy Show pNum :: Proxy Num pIntegral :: Proxy Integral data BoolType a BoolType :: BoolType (Full Bool) data CharType a CharType :: CharType (Full Char) data IntType a IntType :: IntType (Full Int) data FloatType a FloatType :: FloatType (Full Float) data ListType a ListType :: ListType (a :-> Full [a]) data FunType a FunType :: FunType (a :-> (b :-> Full (a -> b))) boolType :: (Syntactic a, BoolType :<: Domain a, Internal a ~ Bool) => a charType :: (Syntactic a, CharType :<: Domain a, Internal a ~ Char) => a intType :: (Syntactic a, IntType :<: Domain a, Internal a ~ Int) => a floatType :: (Syntactic a, FloatType :<: Domain a, Internal a ~ Float) => a listType :: (Syntactic list, Syntactic elem, Domain list ~ Domain elem, ListType :<: Domain list, Internal list ~ [Internal elem], elem ~ c e, list ~ c l) => elem -> list funType :: (Syntactic fun, Syntactic a, Syntactic b, Domain fun ~ Domain a, Domain fun ~ Domain b, FunType :<: Domain fun, Internal fun ~ (Internal a -> Internal b), a ~ c x, b ~ c y, fun ~ c z) => a -> b -> fun dynToInteger :: PWitness Integral t t => Dynamic t -> Either String Integer instance Language.Syntactic.Interpretation.Render t => GHC.Show.Show (Data.TypeRep.Internal.TypeRep t a) instance Language.Syntactic.Sugar.Syntactic (Data.TypeRep.Internal.TypeRep t a) instance (Data.TypeRep.Internal.TypeEq t1 t, Data.TypeRep.Internal.TypeEq t2 t) => Data.TypeRep.Internal.TypeEq (t1 Language.Syntactic.Syntax.:+: t2) t instance Data.TypeRep.Internal.TypeEq Language.Syntactic.Syntax.Empty t instance (Data.TypeRep.Internal.Witness p t1 t, Data.TypeRep.Internal.Witness p t2 t) => Data.TypeRep.Internal.Witness p (t1 Language.Syntactic.Syntax.:+: t2) t instance Data.TypeRep.Internal.Witness p t t => Data.TypeRep.Internal.Witness p (Language.Syntactic.Syntax.AST t) t instance (Data.TypeRep.Internal.PWitness p t1 t, Data.TypeRep.Internal.PWitness p t2 t) => Data.TypeRep.Internal.PWitness p (t1 Language.Syntactic.Syntax.:+: t2) t instance (Data.TypeRep.Internal.TypeEq t t, Data.TypeRep.Internal.Witness GHC.Classes.Eq t t) => GHC.Classes.Eq (Data.TypeRep.Internal.Dynamic t) instance Data.TypeRep.Internal.Witness GHC.Show.Show t t => GHC.Show.Show (Data.TypeRep.Internal.Dynamic t) instance Data.TypeRep.Internal.Any a instance Data.TypeRep.Internal.ShowClass Data.TypeRep.Internal.Any instance Data.TypeRep.Internal.ShowClass GHC.Classes.Eq instance Data.TypeRep.Internal.ShowClass GHC.Classes.Ord instance Data.TypeRep.Internal.ShowClass GHC.Show.Show instance Data.TypeRep.Internal.ShowClass GHC.Num.Num instance Data.TypeRep.Internal.ShowClass GHC.Real.Integral instance Data.TypeRep.Internal.ShowClass (Data.TypeRep.Internal.Typeable t) instance Language.Syntactic.Interpretation.Render Data.TypeRep.Internal.BoolType instance Language.Syntactic.Interpretation.Render Data.TypeRep.Internal.CharType instance Language.Syntactic.Interpretation.Render Data.TypeRep.Internal.IntType instance Language.Syntactic.Interpretation.Render Data.TypeRep.Internal.FloatType instance Language.Syntactic.Interpretation.Render Data.TypeRep.Internal.ListType instance Language.Syntactic.Interpretation.Render Data.TypeRep.Internal.FunType instance (Data.TypeRep.Internal.BoolType Language.Syntactic.Syntax.:<: t) => Data.TypeRep.Internal.Typeable t GHC.Types.Bool instance (Data.TypeRep.Internal.CharType Language.Syntactic.Syntax.:<: t) => Data.TypeRep.Internal.Typeable t GHC.Types.Char instance (Data.TypeRep.Internal.IntType Language.Syntactic.Syntax.:<: t) => Data.TypeRep.Internal.Typeable t GHC.Types.Int instance (Data.TypeRep.Internal.FloatType Language.Syntactic.Syntax.:<: t) => Data.TypeRep.Internal.Typeable t GHC.Types.Float instance (Data.TypeRep.Internal.ListType Language.Syntactic.Syntax.:<: t, Data.TypeRep.Internal.Typeable t a) => Data.TypeRep.Internal.Typeable t [a] instance (Data.TypeRep.Internal.FunType Language.Syntactic.Syntax.:<: t, Data.TypeRep.Internal.Typeable t a, Data.TypeRep.Internal.Typeable t b) => Data.TypeRep.Internal.Typeable t (a -> b) instance Data.TypeRep.Internal.TypeEq Data.TypeRep.Internal.BoolType t instance Data.TypeRep.Internal.TypeEq Data.TypeRep.Internal.CharType t instance Data.TypeRep.Internal.TypeEq Data.TypeRep.Internal.IntType t instance Data.TypeRep.Internal.TypeEq Data.TypeRep.Internal.FloatType t instance Data.TypeRep.Internal.TypeEq t t => Data.TypeRep.Internal.TypeEq Data.TypeRep.Internal.ListType t instance Data.TypeRep.Internal.TypeEq t t => Data.TypeRep.Internal.TypeEq Data.TypeRep.Internal.FunType t instance (Data.TypeRep.Internal.BoolType Language.Syntactic.Syntax.:<: t) => Data.TypeRep.Internal.Witness (Data.TypeRep.Internal.Typeable t) Data.TypeRep.Internal.BoolType t instance (Data.TypeRep.Internal.CharType Language.Syntactic.Syntax.:<: t) => Data.TypeRep.Internal.Witness (Data.TypeRep.Internal.Typeable t) Data.TypeRep.Internal.CharType t instance (Data.TypeRep.Internal.IntType Language.Syntactic.Syntax.:<: t) => Data.TypeRep.Internal.Witness (Data.TypeRep.Internal.Typeable t) Data.TypeRep.Internal.IntType t instance (Data.TypeRep.Internal.FloatType Language.Syntactic.Syntax.:<: t) => Data.TypeRep.Internal.Witness (Data.TypeRep.Internal.Typeable t) Data.TypeRep.Internal.FloatType t instance (Data.TypeRep.Internal.ListType Language.Syntactic.Syntax.:<: t, Data.TypeRep.Internal.Witness (Data.TypeRep.Internal.Typeable t) t t) => Data.TypeRep.Internal.Witness (Data.TypeRep.Internal.Typeable t) Data.TypeRep.Internal.ListType t instance (Data.TypeRep.Internal.FunType Language.Syntactic.Syntax.:<: t, Data.TypeRep.Internal.Witness (Data.TypeRep.Internal.Typeable t) t t) => Data.TypeRep.Internal.Witness (Data.TypeRep.Internal.Typeable t) Data.TypeRep.Internal.FunType t instance (Data.TypeRep.Internal.BoolType Language.Syntactic.Syntax.:<: t) => Data.TypeRep.Internal.PWitness (Data.TypeRep.Internal.Typeable t) Data.TypeRep.Internal.BoolType t instance (Data.TypeRep.Internal.CharType Language.Syntactic.Syntax.:<: t) => Data.TypeRep.Internal.PWitness (Data.TypeRep.Internal.Typeable t) Data.TypeRep.Internal.CharType t instance (Data.TypeRep.Internal.IntType Language.Syntactic.Syntax.:<: t) => Data.TypeRep.Internal.PWitness (Data.TypeRep.Internal.Typeable t) Data.TypeRep.Internal.IntType t instance (Data.TypeRep.Internal.FloatType Language.Syntactic.Syntax.:<: t) => Data.TypeRep.Internal.PWitness (Data.TypeRep.Internal.Typeable t) Data.TypeRep.Internal.FloatType t instance (Data.TypeRep.Internal.ListType Language.Syntactic.Syntax.:<: t, Data.TypeRep.Internal.PWitness (Data.TypeRep.Internal.Typeable t) t t) => Data.TypeRep.Internal.PWitness (Data.TypeRep.Internal.Typeable t) Data.TypeRep.Internal.ListType t instance (Data.TypeRep.Internal.FunType Language.Syntactic.Syntax.:<: t, Data.TypeRep.Internal.PWitness (Data.TypeRep.Internal.Typeable t) t t) => Data.TypeRep.Internal.PWitness (Data.TypeRep.Internal.Typeable t) Data.TypeRep.Internal.FunType t instance Data.TypeRep.Internal.Witness Data.TypeRep.Internal.Any Data.TypeRep.Internal.BoolType t instance Data.TypeRep.Internal.Witness Data.TypeRep.Internal.Any Data.TypeRep.Internal.CharType t instance Data.TypeRep.Internal.Witness Data.TypeRep.Internal.Any Data.TypeRep.Internal.IntType t instance Data.TypeRep.Internal.Witness Data.TypeRep.Internal.Any Data.TypeRep.Internal.FloatType t instance Data.TypeRep.Internal.Witness Data.TypeRep.Internal.Any Data.TypeRep.Internal.ListType t instance Data.TypeRep.Internal.Witness Data.TypeRep.Internal.Any Data.TypeRep.Internal.FunType t instance Data.TypeRep.Internal.PWitness Data.TypeRep.Internal.Any Data.TypeRep.Internal.BoolType t instance Data.TypeRep.Internal.PWitness Data.TypeRep.Internal.Any Data.TypeRep.Internal.CharType t instance Data.TypeRep.Internal.PWitness Data.TypeRep.Internal.Any Data.TypeRep.Internal.IntType t instance Data.TypeRep.Internal.PWitness Data.TypeRep.Internal.Any Data.TypeRep.Internal.FloatType t instance Data.TypeRep.Internal.PWitness Data.TypeRep.Internal.Any Data.TypeRep.Internal.ListType t instance Data.TypeRep.Internal.PWitness Data.TypeRep.Internal.Any Data.TypeRep.Internal.FunType t instance Data.TypeRep.Internal.Witness GHC.Classes.Eq Data.TypeRep.Internal.BoolType t instance Data.TypeRep.Internal.Witness GHC.Classes.Eq Data.TypeRep.Internal.CharType t instance Data.TypeRep.Internal.Witness GHC.Classes.Eq Data.TypeRep.Internal.IntType t instance Data.TypeRep.Internal.Witness GHC.Classes.Eq Data.TypeRep.Internal.FloatType t instance Data.TypeRep.Internal.Witness GHC.Classes.Eq t t => Data.TypeRep.Internal.Witness GHC.Classes.Eq Data.TypeRep.Internal.ListType t instance Data.TypeRep.Internal.PWitness GHC.Classes.Eq Data.TypeRep.Internal.BoolType t instance Data.TypeRep.Internal.PWitness GHC.Classes.Eq Data.TypeRep.Internal.CharType t instance Data.TypeRep.Internal.PWitness GHC.Classes.Eq Data.TypeRep.Internal.IntType t instance Data.TypeRep.Internal.PWitness GHC.Classes.Eq Data.TypeRep.Internal.FloatType t instance Data.TypeRep.Internal.PWitness GHC.Classes.Eq t t => Data.TypeRep.Internal.PWitness GHC.Classes.Eq Data.TypeRep.Internal.ListType t instance Data.TypeRep.Internal.PWitness GHC.Classes.Eq Data.TypeRep.Internal.FunType t instance Data.TypeRep.Internal.Witness GHC.Classes.Ord Data.TypeRep.Internal.BoolType t instance Data.TypeRep.Internal.Witness GHC.Classes.Ord Data.TypeRep.Internal.CharType t instance Data.TypeRep.Internal.Witness GHC.Classes.Ord Data.TypeRep.Internal.IntType t instance Data.TypeRep.Internal.Witness GHC.Classes.Ord Data.TypeRep.Internal.FloatType t instance Data.TypeRep.Internal.Witness GHC.Classes.Ord t t => Data.TypeRep.Internal.Witness GHC.Classes.Ord Data.TypeRep.Internal.ListType t instance Data.TypeRep.Internal.PWitness GHC.Classes.Ord Data.TypeRep.Internal.BoolType t instance Data.TypeRep.Internal.PWitness GHC.Classes.Ord Data.TypeRep.Internal.CharType t instance Data.TypeRep.Internal.PWitness GHC.Classes.Ord Data.TypeRep.Internal.IntType t instance Data.TypeRep.Internal.PWitness GHC.Classes.Ord Data.TypeRep.Internal.FloatType t instance Data.TypeRep.Internal.PWitness GHC.Classes.Ord t t => Data.TypeRep.Internal.PWitness GHC.Classes.Ord Data.TypeRep.Internal.ListType t instance Data.TypeRep.Internal.PWitness GHC.Classes.Ord Data.TypeRep.Internal.FunType t instance Data.TypeRep.Internal.Witness GHC.Show.Show Data.TypeRep.Internal.BoolType t instance Data.TypeRep.Internal.Witness GHC.Show.Show Data.TypeRep.Internal.CharType t instance Data.TypeRep.Internal.Witness GHC.Show.Show Data.TypeRep.Internal.IntType t instance Data.TypeRep.Internal.Witness GHC.Show.Show Data.TypeRep.Internal.FloatType t instance Data.TypeRep.Internal.Witness GHC.Show.Show t t => Data.TypeRep.Internal.Witness GHC.Show.Show Data.TypeRep.Internal.ListType t instance Data.TypeRep.Internal.PWitness GHC.Show.Show Data.TypeRep.Internal.BoolType t instance Data.TypeRep.Internal.PWitness GHC.Show.Show Data.TypeRep.Internal.CharType t instance Data.TypeRep.Internal.PWitness GHC.Show.Show Data.TypeRep.Internal.IntType t instance Data.TypeRep.Internal.PWitness GHC.Show.Show Data.TypeRep.Internal.FloatType t instance Data.TypeRep.Internal.PWitness GHC.Show.Show t t => Data.TypeRep.Internal.PWitness GHC.Show.Show Data.TypeRep.Internal.ListType t instance Data.TypeRep.Internal.PWitness GHC.Show.Show Data.TypeRep.Internal.FunType t instance Data.TypeRep.Internal.Witness GHC.Num.Num Data.TypeRep.Internal.IntType t instance Data.TypeRep.Internal.Witness GHC.Num.Num Data.TypeRep.Internal.FloatType t instance Data.TypeRep.Internal.PWitness GHC.Num.Num Data.TypeRep.Internal.BoolType t instance Data.TypeRep.Internal.PWitness GHC.Num.Num Data.TypeRep.Internal.CharType t instance Data.TypeRep.Internal.PWitness GHC.Num.Num Data.TypeRep.Internal.IntType t instance Data.TypeRep.Internal.PWitness GHC.Num.Num Data.TypeRep.Internal.FloatType t instance Data.TypeRep.Internal.PWitness GHC.Num.Num Data.TypeRep.Internal.ListType t instance Data.TypeRep.Internal.PWitness GHC.Num.Num Data.TypeRep.Internal.FunType t instance Data.TypeRep.Internal.Witness GHC.Real.Integral Data.TypeRep.Internal.IntType t instance Data.TypeRep.Internal.PWitness GHC.Real.Integral Data.TypeRep.Internal.BoolType t instance Data.TypeRep.Internal.PWitness GHC.Real.Integral Data.TypeRep.Internal.CharType t instance Data.TypeRep.Internal.PWitness GHC.Real.Integral Data.TypeRep.Internal.IntType t instance Data.TypeRep.Internal.PWitness GHC.Real.Integral Data.TypeRep.Internal.FloatType t instance Data.TypeRep.Internal.PWitness GHC.Real.Integral Data.TypeRep.Internal.ListType t instance Data.TypeRep.Internal.PWitness GHC.Real.Integral Data.TypeRep.Internal.FunType t -- | Open type representations and dynamic types module Data.TypeRep -- | This class provides reification of type a in a universe -- t. Typeable t a means that a is in -- the type universe represented by t. class Typeable t a -- | Representation of type a in a type universe t -- -- This type can also be seen as a witness that a is a member of -- t (i.e. Typeable t a); see -- witTypeable. data TypeRep t a -- | Reification of type a in a type universe t typeRep :: Typeable t a => TypeRep t a -- | Equality on type representations class Render t => TypeEq t u -- | Equality on type representations typeEq :: (TypeEq t t, MonadError String m) => TypeRep t a -> TypeRep t b -> m (Dict (a ~ b)) -- | Type constructor matching. This function makes it possible to match on -- type representations without dealing with the underlying AST -- representation. -- -- For example, to check that a TypeRep represents the type a -- -> Int for some a: -- --
-- is_atoi :: (TypeEq t t, IntType :<: t) => TypeRep t a -> Bool -- is_atoi t -- | [E ta, E tb] <- matchCon t -- , Just _ <- typeEq ta intType = True -- | otherwise = False --matchCon :: TypeRep t c -> [E (TypeRep t)] -- | Monadic version of matchCon -- --
-- matchConM = return . matchCon ---- -- matchConM is convenient when matching types in a monad, e.g.: -- --
-- do ... -- [E ta, E tb] <- matchConM t -- Dict <- typeEq ta tb -- ... --matchConM :: Monad m => TypeRep t c -> m [E (TypeRep t)] -- | Witness a type constraint for a reified type class Witness p t u -- | Partially witness a type constraint for a reified type class (ShowClass p, Render t) => PWitness p t u where pwitSym _ _ = throwError "" -- | Witness a type constraint for a reified type wit :: Witness p t t => Proxy p -> TypeRep t a -> Dict (p a) -- | Partially witness a type constraint for a reified type pwit :: (PWitness p t t, MonadError String m) => Proxy p -> TypeRep t a -> m (Dict (p a)) -- | Safe cast (does not use unsafeCoerce) cast :: (Typeable t a, Typeable t b, TypeEq t t) => Proxy t -> a -> Either String b -- | Safe generalized cast (does not use unsafeCoerce) gcast :: (Typeable t a, Typeable t b, TypeEq t t) => Proxy t -> c a -> Either String (c b) -- | Dynamic type parameterized on a type universe data Dynamic t Dyn :: TypeRep t a -> a -> Dynamic t toDyn :: Typeable t a => a -> Dynamic t fromDyn :: (Typeable t a, TypeEq t t) => Dynamic t -> Either String a dynToInteger :: PWitness Integral t t => Dynamic t -> Either String Integer -- | The universal class class Any a -- | Witness a Typeable constraint for a reified type witTypeable :: Witness (Typeable t) t t => TypeRep t a -> Dict (Typeable t a) -- | Partially witness a Typeable constraint for a reified type pwitTypeable :: PWitness (Typeable t) t t => TypeRep t a -> Either String (Dict (Typeable t a)) pAny :: Proxy Any pEq :: Proxy Eq pOrd :: Proxy Ord pShow :: Proxy Show pNum :: Proxy Num pIntegral :: Proxy Integral data BoolType a data CharType a data IntType a data FloatType a data ListType a data FunType a boolType :: (Syntactic a, BoolType :<: Domain a, Internal a ~ Bool) => a charType :: (Syntactic a, CharType :<: Domain a, Internal a ~ Char) => a intType :: (Syntactic a, IntType :<: Domain a, Internal a ~ Int) => a floatType :: (Syntactic a, FloatType :<: Domain a, Internal a ~ Float) => a listType :: (Syntactic list, Syntactic elem, Domain list ~ Domain elem, ListType :<: Domain list, Internal list ~ [Internal elem], elem ~ c e, list ~ c l) => elem -> list funType :: (Syntactic fun, Syntactic a, Syntactic b, Domain fun ~ Domain a, Domain fun ~ Domain b, FunType :<: Domain fun, Internal fun ~ (Internal a -> Internal b), a ~ c x, b ~ c y, fun ~ c z) => a -> b -> fun -- | Sub-universe relation -- -- In general, a universe t is a sub-universe of u if -- u has the form -- --
-- t1 :+: t2 :+: ... :+: t --class SubUniverse sub sup -- | Cast a type representation to a larger universe weakenUniverse :: SubUniverse sub sup => TypeRep sub a -> TypeRep sup a -- | Utilities for polyvariadic functions module Data.TypeRep.VarArg -- | Newtype marking the result of a N-ary function newtype Res a Res :: a -> Res a -- | Put a Res marker at the result type of a function -- --
-- ToRes (a -> b -> ... -> x) = a -> b -> ... -> Res x ---- | Remove the Res marker at the result type of a function -- --
-- FromRes (a -> b -> ... -> Res x) = a -> b -> ... -> x ---- | Witness of the arity of a function. Arity will normally be -- indexed by (ToRes a). data Arity a FunRes :: Arity (Res a) FunArg :: Arity b -> Arity (a -> b) class VarArg t aritySym :: (VarArg t, VarArg u) => t sig -> Args (AST u) sig -> Arity (ToRes (DenResult sig)) fromResInvSym :: (VarArg t, VarArg u, a ~ DenResult sig) => t sig -> Args (AST u) sig -> Dict (FromRes (ToRes a) ~ a) -- | Get the Arity of a type. The purpose is to be able to -- distinguish between functions and non-functions without having to -- handle all cases of a TypeRep. arity :: VarArg t => TypeRep t a -> Arity (ToRes a) -- | Prove that FromRes is the inverse of ToRes fromResInv :: VarArg t => TypeRep t a -> Dict (FromRes (ToRes a) ~ a) type NonFunction a = ToRes a ~ Res a -- | Attempt to prove that a type is not a function type nonFunction :: (VarArg t, MonadError String m) => TypeRep t a -> m (Dict (NonFunction a)) -- | Give a function a monadic result type. (FunM m) will -- normally be indexed by (ToRes a). -- --
-- FunM m (a -> b -> ... -> Res x) = a -> b -> ... -> m x ---- | Lift a function to a similar function with monadic result type -- --
-- liftMonadic _ _ f = \a b ... x -> return (f a b ... x) --liftMonadic :: (VarArg t, Monad m) => Proxy m -> TypeRep t a -> a -> FunM m (ToRes a) -- | Run the result of a monadic function -- --
-- runMonadic run _ f = \a b ... x -> run (f a b ... x) --runMonadic :: VarArg t => (forall a. m a -> a) -> TypeRep t a -> FunM m (ToRes a) -> a -- | Compose a function with an N-ary monadic function -- --
-- compMonadic f _ g = \a b ... x -> f (g a b ... x) --compMonadic :: VarArg t => (forall a. m1 a -> m2 a) -> TypeRep t a -> FunM m1 (ToRes a) -> FunM m2 (ToRes a) -- | Give a function monadic arguments and result type. (FunM2 -- m) will normally be indexed by (ToRes a). -- --
-- FunM m (a -> b -> ... -> Res x) = m a -> m b -> ... -> m x ---- | Lift a function to a similar function with monadic arguments and -- result -- --
-- liftMonadic f = \ma mb ... mx -> do -- a <- ma -- b <- mb -- ... -- x <- mx -- return (f a b ... x) --liftMonadic2 :: (VarArg t, Monad m) => Proxy m -> TypeRep t a -> a -> FunM2 m (ToRes a) instance (Data.TypeRep.VarArg.VarArg t1, Data.TypeRep.VarArg.VarArg t2) => Data.TypeRep.VarArg.VarArg (t1 Language.Syntactic.Syntax.:+: t2) instance Data.TypeRep.VarArg.VarArg Data.TypeRep.Internal.BoolType instance Data.TypeRep.VarArg.VarArg Data.TypeRep.Internal.CharType instance Data.TypeRep.VarArg.VarArg Data.TypeRep.Internal.IntType instance Data.TypeRep.VarArg.VarArg Data.TypeRep.Internal.FloatType instance Data.TypeRep.VarArg.VarArg Data.TypeRep.Internal.ListType instance Data.TypeRep.VarArg.VarArg Data.TypeRep.Internal.FunType