Safe Haskell | None |
---|
Utility Template Haskell functions for working with types.
Synopsis
- newtype OneTuple a = OneTuple {
- getOneTuple :: a
- typeOfFun :: Name -> Q Type
- funArgs :: Type -> ([Type], Type)
- tupleArgs :: Type -> Maybe [Type]
- argumentType :: Type -> Q Type
- uncurryVarType :: Type -> Q Exp
- uncurryVar :: Name -> Q Exp
- curryN :: Int -> Q Exp
Documentation
This fills the gap between ()
and (,)
, providing a wrapper for
1-element tuples. It's needed for RPC, where arguments for a function are
sent as a list of values, and therefore for 1-argument functions we need
this wrapper, which packs/unpacks 1-element lists.
OneTuple | |
|
typeOfFun :: Name -> Q Type Source #
Returns the type of a function. If the given name doesn't correspond to a function, fails.
funArgs :: Type -> ([Type], Type) Source #
Splits a function type into the types of its arguments and the result.
argumentType :: Type -> Q Type Source #
Given a type of the form m a
, this function extracts a
.
If the given type is of another form, it fails with an error message.
uncurryVarType :: Type -> Q Exp Source #
Generic uncurry
that counts the number of function arguments in a type
and constructs the appropriate uncurry function into i -> o
.
It the type has no arguments, it's converted into () -> o
.
uncurryVar :: Name -> Q Exp Source #
Creates an uncurried version of a function.
If the function has no arguments, it's converted into () -> o
.