lens-4.13.2.1: Lenses, Folds and Traversals

Copyright(C) 2012-16 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell98

Generics.Deriving.Lens

Contents

Description

Note: Generics.Deriving exports a number of names that collide with Control.Lens.

You can use hiding to mitigate this to an extent, and the following import represents a fair compromise for user code:

import Generics.Deriving hiding (from, to)

You can use generic to replace from and to from Generics.Deriving.

Synopsis

Isomorphisms for GHC.Generics

generic :: Generic a => Iso' a (Rep a b) Source

Convert from the data type to its representation (or back)

>>> "hello"^.generic.from generic :: String
"hello"

generic1 :: Generic1 f => Iso' (f a) (Rep1 f a) Source

Convert from the data type to its representation (or back)

Generic Traversal

tinplate :: (Generic a, GTraversal (Rep a), Typeable b) => Traversal' a b Source

A Generic Traversal that visits every occurrence of something Typeable anywhere in a container.

>>> allOf tinplate (=="Hello") (1::Int,2::Double,(),"Hello",["Hello"])
True
>>> mapMOf_ tinplate putStrLn ("hello",[(2 :: Int, "world!")])
hello
world!

class GTraversal f Source

Used to traverse Generic data by uniplate.

Minimal complete definition

tinplated

Instances

GTraversal V1 Source 

Methods

tinplated :: Typeable * b => Maybe TypeRep -> Traversal' (V1 a) b

GTraversal U1 Source 

Methods

tinplated :: Typeable * b => Maybe TypeRep -> Traversal' (U1 a) b

(Generic a, GTraversal (Rep a), Typeable * a) => GTraversal (K1 i a) Source 

Methods

tinplated :: Typeable * c => Maybe TypeRep -> Traversal' (K1 i a b) c

(GTraversal f, GTraversal g) => GTraversal ((:+:) f g) Source 

Methods

tinplated :: Typeable * b => Maybe TypeRep -> Traversal' ((f :+: g) a) b

(GTraversal f, GTraversal g) => GTraversal ((:*:) f g) Source 

Methods

tinplated :: Typeable * b => Maybe TypeRep -> Traversal' ((f :*: g) a) b

GTraversal a => GTraversal (M1 i c a) Source 

Methods

tinplated :: Typeable * d => Maybe TypeRep -> Traversal' (M1 i c a b) d