optics-th-0.4.1: Optics construction using TemplateHaskell
Safe HaskellNone
LanguageHaskell2010

Optics.TH.Internal.Product

Synopsis

Documentation

data LensRules Source #

Rules to construct lenses for data fields.

Constructors

LensRules 

Fields

type FieldNamer Source #

Arguments

 = Name

Name of the data type that lenses are being generated for.

-> [Name]

Names of all fields (including the field being named) in the data type.

-> Name

Name of the field being named.

-> [DefName]

Name(s) of the lens functions. If empty, no lens is created for that field.

The rule to create function names of lenses for data fields.

Although it's sometimes useful, you won't need the first two arguments most of the time.

data DefName Source #

Name to give to generated field optics.

Constructors

TopName Name

Simple top-level definition name

MethodName Name Name

makeFields-style class name and method name

Instances

Instances details
Eq DefName Source # 
Instance details

Defined in Optics.TH.Internal.Product

Methods

(==) :: DefName -> DefName -> Bool #

(/=) :: DefName -> DefName -> Bool #

Ord DefName Source # 
Instance details

Defined in Optics.TH.Internal.Product

Show DefName Source # 
Instance details

Defined in Optics.TH.Internal.Product

type ClassyNamer Source #

Arguments

 = Name

Name of the data type that lenses are being generated for.

-> Maybe (Name, Name)

Names of the class and the main method it generates, respectively.

The optional rule to create a class and method around a monomorphic data type. If this naming convention is provided, it generates a "classy" lens.

makeFieldOptics :: LensRules -> Name -> DecsQ Source #

Compute the field optics for the type identified by the given type name. Lenses will be computed when possible, Traversals otherwise.

makeFieldLabelsWith :: LensRules -> Name -> DecsQ Source #

Build field optics as labels with a custom configuration.

type HasFieldClasses = StateT (Set Name) Q Source #

Tracks the field class Names that have been created so far. We consult these so that we may avoid creating duplicate classes.