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

Instances

Instances details
Functor OneTuple # 
Instance details

Defined in Ganeti.THH.Types

Methods

fmap :: (a -> b) -> OneTuple a -> OneTuple b

(<$) :: a -> OneTuple b -> OneTuple a

Eq a => Eq (OneTuple a) # 
Instance details

Defined in Ganeti.THH.Types

Methods

(==) :: OneTuple a -> OneTuple a -> Bool

(/=) :: OneTuple a -> OneTuple a -> Bool

Ord a => Ord (OneTuple a) # 
Instance details

Defined in Ganeti.THH.Types

Methods

compare :: OneTuple a -> OneTuple a -> Ordering

(<) :: OneTuple a -> OneTuple a -> Bool

(<=) :: OneTuple a -> OneTuple a -> Bool

(>) :: OneTuple a -> OneTuple a -> Bool

(>=) :: OneTuple a -> OneTuple a -> Bool

max :: OneTuple a -> OneTuple a -> OneTuple a

min :: OneTuple a -> OneTuple a -> OneTuple a

Show a => Show (OneTuple a) # 
Instance details

Defined in Ganeti.THH.Types

Methods

showsPrec :: Int -> OneTuple a -> ShowS

show :: OneTuple a -> String

showList :: [OneTuple a] -> ShowS

JSON a => JSON (OneTuple a) # 
Instance details

Defined in Ganeti.THH.Types

Methods

readJSON :: JSValue -> Result (OneTuple a)

showJSON :: OneTuple a -> JSValue

readJSONs :: JSValue -> Result [OneTuple a]

showJSONs :: [OneTuple a] -> JSValue

Arbitrary a => Arbitrary (OneTuple a) 
Instance details

Defined in Test.Ganeti.THH.Types

Methods

arbitrary :: Gen (OneTuple a)

shrink :: OneTuple a -> [OneTuple a]

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.

tupleArgs :: Type -> Maybe [Type] Source #

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.

curryN :: Int -> Q Exp Source #

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