ganeti

Safe HaskellNone

Ganeti.THH.Types

Description

Utility Template Haskell functions for working with types.

Synopsis

Documentation

newtype OneTuple a Source

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.

Constructors

OneTuple 

Fields

getOneTuple :: a
 

Instances

Functor OneTuple 
Eq a => Eq (OneTuple a) 
Ord a => Ord (OneTuple a) 
Show a => Show (OneTuple a) 
JSON a => JSON (OneTuple a) 
Arbitrary a => Arbitrary (OneTuple a) 

typeOfFun :: Name -> Q TypeSource

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.

tupleArgs :: Type -> Maybe [Type]Source

argumentType :: Type -> Q TypeSource

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 ExpSource

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 ExpSource

Creates an uncurried version of a function. If the function has no arguments, it's converted into () -> o.

curryN :: Int -> Q ExpSource

Generic curry that constructs a curring function of a given arity.