api-tools-0.4: DSL for generating API boilerplate and docs

Safe HaskellNone





data Tool a Source

A Tool a is something that can generate TH declarations from a value of type a. Tools can be combined using the Monoid instance.


Monoid (Tool a) 

runTool :: Tool a -> ToolSettings -> a -> Q [Dec]Source

Execute a tool to generate some TH declarations.

Smart constructors and combinators

simpleTool :: (a -> Q [Dec]) -> Tool aSource

Construct a tool that does not depend on any settings

mkTool :: (ToolSettings -> a -> Q [Dec]) -> Tool aSource

Construct a tool that may depend on the settings

contramapTool :: (a -> b) -> Tool b -> Tool aSource

Tool is a contravariant functor

readTool :: (a -> Tool a) -> Tool aSource

Make a tool that reads its argument to decide what to do

subTools :: Tool a -> Tool [a]Source

Apply a tool that acts on elements of a list to the entire list

apiNodeTool :: Tool APINode -> Tool APISource

Apply a tool that acts on nodes to an entire API

apiDataTypeTool :: Tool APINode -> Tool APISource

Apply a tool that acts on datatype nodes (i.e. those that are not synonyms) to an entire API

apiSpecTool :: Tool (APINode, SpecNewtype) -> Tool (APINode, SpecRecord) -> Tool (APINode, SpecUnion) -> Tool (APINode, SpecEnum) -> Tool (APINode, APIType) -> Tool APINodeSource

Create a tool that acts on nodes from its action on individual specs.

Tool settings

data ToolSettings Source

Settings to control the behaviour of API tools. This record may be extended in the future, so you should construct a value by overriding individual fields of defaultToolSettings.

warnOnOmittedInstance :: ToolSettings -> BoolSource

Generate a warning when an instance declaration is omitted because it already exists

defaultToolSettings :: ToolSettingsSource

Default settings designed to be overridden.