autoapply-0.4: Template Haskell to automatically pass values to functions
Safe HaskellNone
LanguageHaskell2010

AutoApply

Synopsis

Documentation

autoapply Source #

Arguments

:: [Name]

Values which will be used if their type subsumes the argument type

-> [Name]

Values which will be used if their type unifies with the argument type

-> Name

A function to apply to some values

-> Q Exp 

autoapply argsSubsuming argsUnifying fun creates an expression which is equal to fun applied to as many of the values in argsSubsuming and argsUnifying as possible.

The types of first list of args must subsume the type of the argument they're passed to. The types of the second list must merely unify.

autoapplyDecs Source #

Arguments

:: (String -> String)

A function to generate a new name for the wrapping function

-> [Name]

A list of values which will be passed to any arguments their type subsumes

-> [Name]

A list of values which will be passed to any arguments their type unify with

-> [Name]

A list of function to wrap with the above parameters

-> Q [Dec] 

autoapplyDecs mkName argsSubsuming argsUnifying funs will wrap every function in funs by applying it to as many of the values in argsSubsuming and argsUnifying as possible. The new function name will be mkName applied to the wrapped function name.

The types of first list of args must subsume the type of the argument they're passed to. The types of the second list must merely unify.

Type signatures are not generated, so you may want to add these yourself or turn on NoMonomorphismRestriction if you have polymorphic constraints.