| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Control.Lens.TH.ADT
Description
This module allows generating lenses for non-record ADTs.
To allow overloading (e.g. using the same lens name for multiple ADTs), it first generates a typeclass and then an instance for it. If other lenses generated in the same scope have the same name, only an instance is generated.
data A = A Int data B = B IntmakeADTLenses'A ["value"] -- ===> Generates the following class HasValue a b where value = 'Lens'' a b instance HasValue A Int where value =position11makeADTLenses'B ["value"] -- ===> Generates the following instance HasValue B Int where value =position
Synopsis
- makeADTLenses :: Name -> [String] -> DecsQ
- makeADTLens :: Name -> String -> Int -> DecsQ
- lensClassName :: Name -> Name
Documentation
makeADTLenses :: Name -> [String] -> DecsQ Source #
Generates lenses for all the fields of the given type. Uses makeADTLens for each field.
makeADTLens :: Name -> String -> Int -> DecsQ Source #
Generates a lens with the given name for the field at the given index for the given type
makeADTLens'(,) "left" 0 -- ===> Generates the following instance HasLeft (a,b) a where left =position@1
lensClassName :: Name -> Name Source #
Get the name of the lens typeclass to define, using the lens' name