Safe Haskell | None |
---|---|
Language | Haskell98 |
Derive lenses for Lens.Family2.
Example usage:
{-# LANGUAGE TemplateHaskell, Rank2Types #-} import Lens.Family2 import Lens.Family2.TH data Foo a = Foo { _bar :: Int, _baz :: a } deriving (Show, Read, Eq, Ord) $(makeLenses ''Foo)
- makeLenses :: Name -> Q [Dec]
- makeLensesBy :: (String -> Maybe String) -> Name -> Q [Dec]
- makeLensesFor :: [(String, String)] -> Name -> Q [Dec]
- makeTraversals :: Name -> Q [Dec]
- mkLenses :: Name -> Q [Dec]
- mkLensesBy :: (String -> Maybe String) -> Name -> Q [Dec]
- mkLensesFor :: [(String, String)] -> Name -> Q [Dec]
Documentation
makeLenses :: Name -> Q [Dec] Source
Derive lenses for the record selectors in a single-constructor data declaration, or for the record selector in a newtype declaration. Lenses will only be generated for record fields which are prefixed with an underscore.
Example usage:
$(makeLenses ''Foo)
makeLensesBy :: (String -> Maybe String) -> Name -> Q [Dec] Source
Derive lenses with the provided name transformation
and filtering function. Produce Just lensName
to generate a lens
of the resultant name, or Nothing
to not generate a lens
for the input record name.
Example usage:
$(makeLensesBy (\n -> Just (n ++ "L")) ''Foo)
makeLensesFor :: [(String, String)] -> Name -> Q [Dec] Source
Derive lenses, specifying explicit pairings of (fieldName, lensName)
.
Example usage:
$(makeLensesFor [("_foo", "fooLens"), ("bar", "lbar")] ''Foo)
makeTraversals :: Name -> Q [Dec] Source