| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
FCI.TH
Contents
Description
Configuration options for mkDict
Synopsis
- mkDict :: Name -> Q [Dec]
- data DictOptions
- setDictOptions :: DictOptions -> Q [a]
- dictOptions :: DictOptions
- methodName :: DictOptions -> ClassName -> MethodName -> FieldName
- superclassName :: DictOptions -> ClassName -> ClassName -> Int -> FieldName
- typeName :: DictOptions -> ClassName -> TypeName
- constructorName :: DictOptions -> ClassName -> ConstrName
- autoDoc :: DictOptions -> Bool
Documentation
mkDict :: Name -> Q [Dec] Source #
Declare the dictionary type associated with a given class.
The generated type is a record of class members with the following format
by default (it can be customized using setDictOptions):
- The type of the record is
Dictprepended to the name of the class. - The name of the constructor is the name of the class.
Superclass constraints are transformed into fields containing their dictionaries. The names of those fields are generated this way:
- Alphabetic names (e.g.,
Show,Applicative) are prefixed with_ - Operators (e.g.,
(~)) are prefixed with/ - Tuples are converted into
_Tuple2,_Tuple3, etc. - Multiple occurrences of the same superclass are suffixed with an index
starting from 1, or with an increasing number of
|s if its name is an operator.
- Alphabetic names (e.g.,
- Methods get their own fields; their names are the names of methods
prefixed with
_for alphabetic method names, or|for operators.
This behavior can be configured using setDictOptions from FCI.TH.
data DictOptions Source #
Options to configure mkDict. The constructor is hidden so you have to use
record update with dictOptions.
Example
setDictOptionsdictOptions{autoDoc= False }
setDictOptions :: DictOptions -> Q [a] Source #
Set options for subsequent invocations of mkDict.
This setting only affects the current module.
Returns the empty list so it can be used as a top-level slice.
dictOptions :: DictOptions Source #
Default DictOptions. To be modified with record updates.
dictOptions{methodName= _ ,superclassName= _ ,typeName= _ ,constructorName= _ ,autoDoc= _ }
DictOptions fields
methodName :: DictOptions -> ClassName -> MethodName -> FieldName Source #
DictOptions setting to generate a field name from the
name of the class and one of its methods.
By default, prepend "_" to alphabetic identifiers, and prepend "|"
to operators.
superclassName :: DictOptions -> ClassName -> ClassName -> Int -> FieldName Source #
DictOptions setting to generate a field name from the name
of the class and one of its superclasses. The Int is a counter of duplicate
superclasses, starts at 0.
By default, prepend "_" to alphabetic identifiers, and prepend "/"
to operators.
typeName :: DictOptions -> ClassName -> TypeName Source #
DictOptions setting to generate a type name from the name of the class.
By default, prepend "Dict" to alphabetic identifiers, and prepend
"." to operators.
constructorName :: DictOptions -> ClassName -> ConstrName Source #
DictOptions setting to generate a constructor name from the name of the class.
By default, keep alphabetic identifiers unchanged, and prepend
":" to operators.
autoDoc :: DictOptions -> Bool Source #
DictOptions setting to automatically generate a haddock comment.
The comment will say "Dictionary type for CLASS".
True by default.