tuple-append-0.3.0.0: A package to append, sequence and fold items and tuples into new tuples.
Maintainerhapytexeu+gh@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe
LanguageHaskell2010

Data.Tuple.Append.TemplateHaskell

Description

A module hat defines template Haskell expressions to define typeclass instances to prepend and append tuples.

Synopsis

Quasiquoters for typeclass instances

defineTupleAddUpto Source #

Arguments

:: QuasiQuoter

A QuasiQuoter that will construct typeclass instance declarations.

A QuasiQuoter that constructs instances for TupleAddL and TupleAddR for tuples up to length n where n is read as text input for the quasi quoter.

defineTupleAppendUpto Source #

Arguments

:: QuasiQuoter

A QuasiQuoter that will construct typeclass instance declarations.

A QuasiQuoter that constructs instances for TupleAppend for tuples up to length n where n is read as text input for the quasi quoter. For a single n it thus will construct n+1 instances for each tuple length.

defineSequenceTupleUpTo Source #

Arguments

:: QuasiQuoter

A QuasiQuoter that will construct typeclass instance declarations.

A QuasiQuoter that constructs instances for the SequenceTuple typeclass for tuples up to a length n where n is read as text input for the quasi quoter. For a single n it will thus construct n instances in total.

defineFoldTupleUpTo Source #

Arguments

:: QuasiQuoter

A QuasiQuoter that will construct typeclass instance declarations.

A QuasiQuoter that constructs instances for the FoldTuple typeclass for tuples up to a length n where n is read as text input for the quasi quoter. For a single n it will thus construct n+1 instances in total.

Quasiquoters for unboxed tuples

defineUnboxedTupleAppendFunctionsUpto Source #

Arguments

:: QuasiQuoter

A QuasiQuoter that will construct function definitions.

A QuasiQuoter that constructs function declarations with the name unboxedAppend_i_j with i and j the number of items of the unboxed tuples. The items sum up to at most n where n is read as text input for the quasi quoter. For a single n it thus will construct n+1 instances for each tuple length.

Functions to construct typeclass instance declarations

tupleAddL Source #

Arguments

:: Int

The given length n of the tuples to prepend an element.

-> Dec

A type instance declaration for an instance of the TupleAddL typeclass for an n-tuple.

Define a typeclass instance for TupleAddL for a tuple with n elements and an item to construct a tuple with n+1 elements where the item is added at the left side.

tupleAddR Source #

Arguments

:: Int

The given length n of the tuples to append with an element.

-> Dec

A type instance declaration for an instance of the TupleAddR typeclass for an n-tuple.

Define a typeclass instance for TupleAddR for a tuple with n elements and an item to construct a tuple with n+1 elements where the item is added at the right side.

tupleAdd Source #

Arguments

:: Int

The given length n of the tuples to prepend and append with an element.

-> [Dec]

A list of two type instance declarations that contains typeclass instances for TupleAddL and TupleAddR.

Define typeclass instances for TupleAddL and TupleAddR for a tuple with n elements and an item to construct a tuple with n+1 elements where the item is added at the left or the right side.

tupleAppend Source #

Arguments

:: Int

The length m of the first tuple.

-> Int

The length n of the second tuple.

-> Dec

An instance of the TupleAppend typeclass that appends tuples with lengths m and n to a tuple with length m+n.

Define a typeclass instance for TupleAppend where it appends tuples with m and n items with m and n the parameters of the function.

tupleAppendFor Source #

Arguments

:: Int

The given number l for which typeclass instances of TupleAppend will be made with m and n such that l=m+n.

-> [Dec]

A list of typeclass instances for the TupleAppend typeclass.

Define typeclass instances for TupleAppend that will append any tuple of at least size two with any tuple of at least size two such that the sum is the given number.

sequenceTuple Source #

Arguments

:: Int

The given length n for the tuple to be sequenced.

-> Dec

The instance declaraion for that tuple.

Define a typeclass instance for SequenceTuple where it sequences a tuple of length n.

sequenceTupleFor Source #

Arguments

:: Int

The given number n that specifies the *arity* of the tuple for which to construct an instance. Will return an empty list if the number is invalid.

-> [Dec]

A list of typeclass instances for the SequenceTuple typeclass.

Define a typeclass instance for the SequenceTuple typeclass that will sequence over a tuple for the given length.

foldTuple Source #

Arguments

:: Int

The given length n of the tuples to fold.

-> Dec

A type instance declaration for an instance of the FoldTuple typeclass for an n-tuple.

Define a typeclass instance for FoldTuple for a tuple with n elements that is folded with an arbitrary "fold" function.

foldTupleFor Source #

Arguments

:: Int

The given number n that specifies the *arity* of the tuple for which to construct an instance. Will return an empty list if the number is invalid.

-> [Dec]

A list of typeclass instances for the FoldTuple typeclass.

Define a typeclass instance for the FoldTuple typeclass that will fold over a tuple of given length.

Function declarations

boxedTupleAddLFun Source #

Arguments

:: Name

The name of the function to construct.

-> Type

The type of the item to add to the tuple, should be a lifted type.

-> [Type]

The types of the boxed tuple, all items should be lifted types.

-> [Dec]

A list that contains two Dec objects: one for the function signature declaration, and one for the function declaration.

Create a function declaration with signature to add an item with a given type to the left side of a boxed tuple with the types of the given list. This will contain two Dec items: one for the signature and one for the function declaration itself.

boxedTupleAddRFun Source #

Arguments

:: Name

The name of the function to construct.

-> [Type]

The types of the boxed tuple, all types should be lifted types.

-> Type

The type of the item to add to the tuple, should be a lifted type.

-> [Dec]

A list that contains two Dec objects: one for the function signature declaration, and one for the function declaration.

Create a function declaration with signature to add an item with a given type to the right side of a boxed tuple with the types of the given list. This will contain two Dec items: one for the signature and one for the function declaration itself.

boxedTupleAppendFun Source #

Arguments

:: Name

The name of the function to construct.

-> [Type]

The types of the first boxed tuple, all types should be lifted types.

-> [Type]

The types of the second boxed tuple, all types should be lifted types.

-> [Dec]

A list that contains two Dec objects: one for the function signature declaration, and one for the function declaration.

Create a function declaration with signature to append a boxed tuple with the types of the first list with a boxed tuple with the types of the second list. This will contain two Dec items: one for the signature and one for the function declaration itself.

unboxedTupleAddLFun Source #

Arguments

:: Name

The name of the function to construct.

-> Type

The type of the item to add to the tuple, this can be a lifted or unlifted type or a type variable.

-> [Type]

The types of the boxed tuple, all types can be lifted or unlifted types or type variables.

-> [Dec]

A list that contains two Dec objects: one for the function signature declaration, and one for the function declaration.

Create a function declaration with signature to add an item with a given type to the left side of an unboxed tuple with the types of the given list. This will contain two Dec items: one for the signature and one for the function declaration itself.

unboxedTupleAddRFun Source #

Arguments

:: Name

The name of the function to construct.

-> [Type]

The types of the boxed tuple, all types can be lifted or unlifted types or type variables.

-> Type

The type of the item to add to the tuple, this can be a lifted or unlifted type or a type variable.

-> [Dec]

A list that contains two Dec objects: one for the function signature declaration, and one for the function declaration.

Create a function declaration with signature to add an item with a given type to the right side of an unboxed tuple with the types of the given list. This will contain two Dec items: one for the signature and one for the function declaration itself.

unboxedTupleAppendFun Source #

Arguments

:: Name

The name of the function to construct.

-> [Type]

The types of the first boxed tuple, all types can be lifted or unlifted types or type variables.

-> [Type]

The types of the second boxed tuple, all types can be lifted or unlifted types or type variables.

-> [Dec]

A list that contains two Dec objects: one for the function signature declaration, and one for the function declaration.

Create a function declaration with signature to append an unboxed tuple with the types of the first list with an unboxed tuple with the types of the second list. This will contain two Dec items: one for the signature and one for the function declaration itself.

Function builders (for template Haskell)

makeBoxedTupleAddLFun Source #

Arguments

:: Name

The name of the function to construct.

-> Type

The type of the item to add to the tuple, should be a lifted type.

-> [Type]

The types of the boxed tuple, all types should be lifted types.

-> DecsQ

A builder to construct the declaration of the signature and a body of the function to add an element at the left side of a tuple.

Create a function declaration with signature to add an item with a given type to the left side of a boxed tuple with the types of the given list. This function can be used with template Haskell.

makeBoxedTupleAddRFun Source #

Arguments

:: Name

The name of the function to construct.

-> [Type]

The types of the boxed tuple, all types should be lifted types.

-> Type

The type of the item to add to the tuple, should be a lifted type.

-> DecsQ

A builder to construct the declaration of the signature and a body of the function to add an element at the right side of a tuple.

Create a function declaration with signature to add an item with a given type to the right side of a boxed tuple with the types of the given list. This function can be used with template Haskell.

makeBoxedTupleAppendFun Source #

Arguments

:: Name

The name of the function to construct.

-> [Type]

The types of the first boxed tuple, all types should be lifted types.

-> [Type]

The types of the second boxed tuple, all types should be lifted types.

-> DecsQ

A builder to construct the declaration of the signature and a body of the function to append the tuples.

Create a function declaration with signature to append a boxed tuple with the types of the first list with a boxed tuple with the types of the second list. This function can be used with template Haskell.

makeUnboxedTupleAddLFun Source #

Arguments

:: Name

The name of the function to construct.

-> Type

The type of the item to add to the tuple, this can be a lifted or unlifted type or a type variable.

-> [Type]

The types of the boxed tuple, all types can be lifted or unlifted types or type variables.

-> DecsQ

A builder to construct the declaration of the signature and a body of the function to add an element at the left side of a tuple.

Create a function declaration with signature to add an item with a given type to the left side of an unboxed tuple with the types of the given list. This function can be used with template Haskell.

makeUnboxedTupleAddRFun Source #

Arguments

:: Name

The name of the function to construct.

-> [Type]

The types of the boxed tuple, all types can be lifted or unlifted types or type variables.

-> Type

The type of the item to add to the tuple, this can be a lifted or unlifted type or a type variable.

-> DecsQ

A builder to construct the declaration of the signature and a body of the function to add an element at the right side of a tuple.

Create a function declaration with signature to add an item with a given type to the right side of an unboxed tuple with the types of the given list. This function can be used with template Haskell.

makeUnboxedTupleAppendFun Source #

Arguments

:: Name

The name of the function to construct.

-> [Type]

The types of the first boxed tuple, all types can be lifted or unlifted types or type variables.

-> [Type]

The types of the second boxed tuple, all types can be lifted or unlifted types or type variables.

-> DecsQ

A builder to construct the declaration of the signature and a body of the function to append the tuples.

Create a function declaration with signature to append an unboxed tuple with the types of the first list with an unboxed tuple with the types of the second list. This function can be used with template Haskell.

Create a function clause

Boxed tuples

boxedAddLClause Source #

Arguments

:: Int

The number of items of the boxed tuple to add an item to.

-> Name

The name of the function to define.

-> Dec

A function declaration that only contains the body of the function.

Create a function declaration to add an item to the left side of a boxed tuple in a new boxed tuple. This only contains a declaration for the body of the function, not a type signature.

boxedAddRClause Source #

Arguments

:: Int

The number of items of the boxed tuple to add an item to.

-> Name

The name of the function to define.

-> Dec

A function declaration that only contains the body of the function.

Create a function declaration to add an item to the right side of a boxed tuple in a new boxed tuple. This only contains a declaration for the body of the function, not a type signature.

boxedAppendClause Source #

Arguments

:: Int

The number of items for the first boxed tuple parameter.

-> Int

The number of items for the second boxed tuple parameter.

-> Name

The name of the function to define.

-> Dec

A function declaration that only contains the body of the function.

Create a function declaration to append two boxed tuples together in a new boxed tuple. This only contains a declaration for the body of the function, not a type signature.

sequenceClauseA Source #

Arguments

:: Int

The given number n for which a function is produced that sequences n-tuples.

-> Name

The name for the function that is generated.

-> Dec

A declaration for a function that sequences the tuple.

Produce a function for sequencing a tuple of a given length of tuples with a given name.

sequenceClauseA_ Source #

Arguments

:: Int

The given number n for which a function is produced that sequences n-tuples.

-> Name

The name for the function that is generated.

-> Dec

A declaration for a function that sequences the tuple and returns the unit value.

Produce a function for sequencing a tuple of a given length of tuples and return the unit value with a given name.

foldlClause Source #

Arguments

:: Int

The number of items of the boxed tuple to fold.

-> Name

The name of the function to define.

-> Dec

A function declaration that only contains the body of the function.

Create a function declaration to fold a boxed tuple left-to-right. This only contains a declaration for the body of the function, not a type signature.

foldrClause Source #

Arguments

:: Int

The number of items of the boxed tuple to fold.

-> Name

The name of the function to define.

-> Dec

A function declaration that only contains the body of the function.

Create a function declaration to fold a boxed tuple right-to-left. This only contains a declaration for the body of the function, not a type signature.

foldMapClause Source #

Arguments

:: Int

The number of items of the boxed tuple to foldMap.

-> Name

The name of the function to define.

-> Dec

A function declaration that only contains the body of the function.

Create a function declaration to foldMap a boxed tuple. This only contains a declaration for the body of the function, not a type signature.

Unboxed tuples

unboxedAddLClause Source #

Arguments

:: Int

The number of items of the unboxed tuple to add an item to.

-> Name

The name of the function to define.

-> Dec

A function declaration that only contains the body of the function.

Create a function declaration to add an item to the left side of an unboxed tuple in a new unboxed tuple. This only contains a declaration for the body of the function, not a type signature.

unboxedAddRClause Source #

Arguments

:: Int

The number of items of the unboxed tuple to add an item to.

-> Name

The name of the function to define.

-> Dec

A function declaration that only contains the body of the function.

Create a function declaration to add an item to the right side of an unboxed tuple in a new unboxed tuple. This only contains a declaration for the body of the function, not a type signature.

unboxedAppendClause Source #

Arguments

:: Int

The number of items for the first unboxed tuple parameter.

-> Int

The number of items for the second unboxed tuple parameter.

-> Name

The name of the function to define.

-> Dec

A function declaration that only contains the body of the function.

Create a function declaration to append two unboxed tuples together in a new unboxed tuple. This only contains a declaration for the body of the function, not a type signature.