api-tools-0.9.0.0: DSL for generating API boilerplate and docs
Safe HaskellNone
LanguageHaskell2010

Data.API.Tools.Combinators

Synopsis

Documentation

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.

Instances

Instances details
Semigroup (Tool a) Source # 
Instance details

Defined in Data.API.Tools.Combinators

Methods

(<>) :: Tool a -> Tool a -> Tool a #

sconcat :: NonEmpty (Tool a) -> Tool a #

stimes :: Integral b => b -> Tool a -> Tool a #

Monoid (Tool a) Source # 
Instance details

Defined in Data.API.Tools.Combinators

Methods

mempty :: Tool a #

mappend :: Tool a -> Tool a -> Tool a #

mconcat :: [Tool a] -> 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 a Source #

Construct a tool that does not depend on any settings

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

Construct a tool that may depend on the settings

contramapTool :: (a -> b) -> Tool b -> Tool a Source #

Tool is a contravariant functor

readTool :: (a -> Tool a) -> Tool a Source #

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 API Source #

Apply a tool that acts on nodes to an entire API

apiDataTypeTool :: Tool APINode -> Tool API Source #

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 APINode Source #

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 -> Bool Source #

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

newtypeSmartConstructors :: ToolSettings -> Bool Source #

Rename the constructors of filtered newtypes and generate smart constructors that enforce the invariants

defaultToolSettings :: ToolSettings Source #

Default settings designed to be overridden.