x      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      TemplateHaskell experimentalEdward Kmett <ekmett@gmail.com> Trustworthy*Derive lenses for the record selectors in ( a single-constructor data declaration, 6 or for the record selector in a newtype declaration. 7 Lenses will only be generated for record fields which " are prefixed with an underscore. Example usage:  makeLenses ''Foo /Derive lenses, specifying explicit pairings of (fieldName, lensName). Example usage: < makeLensesFor [("_foo", "fooLens"), ("bar", "lbar")] ''Foo 4Derive 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 the name transformer  Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered  Used for  maximumOf  Used for  minimumOf Used internally by  and the like. Used internally by  traverseOf_,  and the like. Applicative composition of  State Int with a , used  by  elementOf,  elementsOf, traverseElement, traverseElementsOf 0The indexed store can be used to characterize a  LensFamily  and is used by clone Used by Focus Obtain the minimum Obtain the maximum        rank 2 types provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered'A concrete data type for isomorphisms. DThis lets you place an isomorphism inside a container without using ImpredicativeTypes. 7Used to provide overloading of isomorphism application  This is a ) with a canonical mapping to it from the . category of isomorphisms over Haskell types. *Build this morphism out of an isomorphism The intention is that by using #, you can supply both halves of an G isomorphism, but k can be instantiated to (->), so you can freely use * the resulting isomorphism as a function. MMap a morphism in the target category using an isomorphism between morphisms  in Hask. QAn isomorphism from a to b, overloaded to permit its use directly as a function. You can use a value of type (a :~ b) as if it were (a -> b) or Isomorphism a b. !Invert an isomorphism. ENote to compose an isomorphism and receive an isomorphism in turn you'll need to use     from (from l) = l If you imported 'Control.Category.(.)', then:   from l . from r = from (r . l)  from :: (a :~> b) -> (b :~> a) " % via :: Isomorphism a b -> (a :~> b)  !" !"!"  !" Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered# 7 type SimpleIsoLike k f a b = Simple (IsoLike k f) a b $ 2 type LensLike f a b c d = IsoLike (->) f a b c d % % type SimpleIso a b = Simple Iso a b &BIsomorphim families can be composed with other lenses using either' (.)' and   I from the Prelude or from Control.Category. However, if you compose them  with each other using '(.)'1 from the Prelude, they will be dumbed down to a  mere 6.   import Control.Category  import Prelude hiding ((.),id) Q type Iso a b c d = forall k f. (Isomorphic k, Functor f) => IsoLike k f a b c d 'A 'I describes how to retrieve multiple values in a way that can be composed % with other lens-like constructions. A ' a cC provides a structure with operations very similar to those of the !  typeclass, see p and the other ' combinators. !By convention, if there exists a foo method that expects a ! (f c), then there should be a  fooOf method that takes a ' a c and a value of type a. A ) is a legal ' that just ignores the supplied "  Unlike a 5 a ' is read-only. Since a ' cannot be used to write back $ there are no lens laws that apply. = type Fold a c = forall m b d. Monoid m => Getting m a b c d (Most )- combinators are able to be used with both a ) or a ' in S limited situations, to do so, they need to be monomorphic in what we are going to  extract with #. To be compatible with 6, 5 and & we also : restricted choices of the irrelevant b and d parameters. If a function accepts a Getting r a b c d , then when r is a Monoid, you can  pass a ' (or 5&), otherwise you can only pass this a ) or 6. 5 type Getting r a b c d = LensLike (Const r) a b c d )A )M describes how to retrieve a single value in a way that can be composed with  other lens-like constructions.  Unlike a 6 a ) is read-only. Since a ) cannot be used to write back 3 there are no lens laws that can be applied to it.  Moreover, a ) can be used directly as a ', since it just ignores the ". In practice the b and d? are left dangling and unused, and as such is no real point in  using a 4 ). 7type Getter a c = forall r. LensLike (Const r) a b c d *(This alias is supplied for those who don't want to use LiberalTypeSynonyms with 4. % 'SimpleSetter ' = 'Simple' 'Setter' + The only 6-like law that can apply to a + l is that  ! set l c (set l b a) = set l c a You can't T a +3 in general, so the other two laws are irrelevant. %However, two Functor laws apply to a +   adjust l id = id , adjust l f . adjust l g = adjust l (f . g) You can compose a + with a 6 or a 5 using (.) from the Prelude ! and the result is always only a + and nothing more. 1 type Setter a b c d = LensLike Identity a b c d ,This class allows us to use -. on a number of different monad transformers. -IRun a monadic action in a larger context than it was defined in, using a 4 6 or 4 5. lThis is commonly used to lift actions in a simpler state monad into a state monad with a larger state type. When applied to a 'Simple 5M over multiple values, the actions for each target are executed sequentially + and the results are aggregated monoidally  and a monoidal summary  of the result is given. N focus :: Monad m => Simple Iso a b -> st b m c -> st a m c N focus :: Monad m => Simple Lens a b -> st b m c -> st a m c N focus :: (Monad m, Monoid c) => Simple Traversal a b -> st b m c -> st a m c .Like -4, but discarding any accumulated results as you go. P focus_ :: Monad m => Simple Iso a b -> st b m c -> st a m () P focus_ :: Monad m => Simple Lens a b -> st b m c -> st a m () P focus_ :: (Monad m, Monoid c) => Simple Traversal a b -> st b m c -> st a m () /A much more limited version of - that can work with a +. 0Many combinators that accept a 6 can also accept a 5 in limited situations. 'They do so by specializing the type of " that they require of the caller. If a function accepts a 0 f a b c d for some  f, then they may be passed a 6.  Further, if f is an $, they may also be passed a 5. 1 - type SimpleLensLike f = Simple (LensLike f) 2  type SimpleLens = Simple Lens 3 ) type SimpleTraversal = Simple Traversal 4A 4 6, 4 5, ... can be used instead of a 6,5, ...  whenever the type variables don't change upon setting a value.  ( imaginary :: Simple Lens (Complex a) a ( traverseHead :: Simple Traversal [a] a .Note: To use this alias in your own code with 0 f or Setter, you may have to turn on  LiberalTypeSynonyms. 5A 5 can be used directly as a + or a ' (but not as a 6) and provides V the ability to both read and update multiple fields, subject to some relatively weak 5 laws. UThese have also been known as multilenses, but they have the signature and spirit of  8 traverse :: Traversable f => Traversal (f a) (f b) a b 8and the more evocative name suggests their application. Most of the time the 5 you will want to use is just , but you can also pass any  6 or && as a Traversal, and composition of a 5 (or 6 or & ) with a 5 (or 6 or &)  using (.) forms a valid 5. 6A 6+ is actually a lens family as described in  /http://comonad.com/reader/2012/mirrored-lenses/. 2With great power comes great responsibility and a 61 is subject to the three common sense lens laws: !1) You get back what you put in:   view l (set l b a) = b "2) Putting back what you got doesn't change anything:   set l (view l a) a = a .3) Setting twice is the same as setting once:  ! set l c (set l b a) = set l c a =These laws are strong enough that the 4 type parameters of a 6. cannot vary fully independently. For more on  how they interact, read the Why is it a Lens Family? section of  /http://comonad.com/reader/2012/mirrored-lenses/. Every 6 can be used directly as a + or 5. You can also use a 6 for ( as if it were a ' or ). 7 type Lens = forall f. Functor f => LensLike f a b c d 7Build a 6 from a getter and a setter. J lens :: Functor f => (a -> c) -> (a -> d -> b) -> (c -> f d) -> a -> f b 8(8') can be used in one of two scenarios: When applied to a 6 , it can edit the target of the 6 in a structure, extracting a  functorial result. When applied to a 5!, it can edit the targets of the  Traversals, extracting an % applicative summary of its actions. 8For all that the definition of this combinator is just:   (%%~) = id  G (%%~) :: Functor f => Iso a b c d -> (c -> f d) -> a -> f b G (%%~) :: Functor f => Lens a b c d -> (c -> f d) -> a -> f b G (%%~) :: Applicative f => Traversal a b c d -> (c -> f d) -> a -> f b `It may be beneficial to think about it as if it had these even more restrictive types, however: When applied to a 5!, it can edit the targets of the  Traversals, extracting a G supplemental monoidal summary of its actions, by choosing f = ((,) m) H (%%~) :: Iso a b c d -> (c -> (e, d)) -> a -> (e, b) H (%%~) :: Lens a b c d -> (c -> (e, d)) -> a -> (e, b) H (%%~) :: Monoid m => Traversal a b c d -> (c -> (m, d)) -> a -> (m, b) 9Modify the target of a 6: in the current state returning some extra information of c or  modify all targets of a 5< in the current state, extracting extra information of type c / and return a monoidal summary of the changes.   (%%=) = (state.) It may be useful to think of (9>), instead, as having either of the following more restricted  type signatures: Q (%%=) :: MonadState a m => Iso a a c d -> (c -> (e, d) -> m e Q (%%=) :: MonadState a m => Lens a a c d -> (c -> (e, d) -> m e Q (%%=) :: (MonadState a m, Monoid e) => Traversal a a c d -> (c -> (e, d) -> m e :AMap each element of a structure targeted by a Lens or Traversal, E evaluate these actions from left to right, and collect the results.   traverseOf = id   traverse = traverseOf traverse ; traverseOf :: Iso a b c d -> (c -> f d) -> a -> f b ; traverseOf :: Lens a b c d -> (c -> f d) -> a -> f b ; traverseOf :: Traversal a b c d -> (c -> f d) -> a -> f b ;  forOf l = flip (traverseOf l)   for = forOf traverse  forOf = morphism flip flip 1 forOf :: Lens a b c d -> a -> (c -> f d) -> f b <FEvaluate each action in the structure from left to right, and collect  the results.  " sequenceA = sequenceAOf traverse ! sequenceAOf l = traverseOf l id  sequenceAOf l = l id C sequenceAOf :: Iso a b (f c) c -> a -> f b C sequenceAOf :: Lens a b (f c) c -> a -> f b C sequenceAOf :: Applicative f => Traversal a b (f c) c -> a -> f b =HMap each element of a structure targeted by a lens to a monadic action, E evaluate these actions from left to right, and collect the results.   mapM = mapMOf traverse B mapMOf :: Iso a b c d -> (c -> m d) -> a -> m b B mapMOf :: Lens a b c d -> (c -> m d) -> a -> m b B mapMOf :: Monad m => Traversal a b c d -> (c -> m d) -> a -> m b >  forM = forMOf traverse  forMOf l = flip (mapMOf l) B forMOf :: Iso a b c d -> a -> (c -> m d) -> m b B forMOf :: Lens a b c d -> a -> (c -> m d) -> m b B forMOf :: Monad m => Traversal a b c d -> a -> (c -> m d) -> m b ?  sequence = sequenceOf traverse  sequenceOf l = mapMOf l id * sequenceOf l = unwrapMonad . l WrapMonad < sequenceOf :: Iso a b (m c) c -> a -> m b < sequenceOf :: Lens a b (m c) c -> a -> m b < sequenceOf :: Monad m => Traversal a b (m c) c -> a -> m b @This generalizes  to an arbitrary 5.  " transpose = transposeOf traverse  . ghci> transposeOf traverse [[1,2,3],[4,5,6]]  [[1,4],[2,5],[3,6]]  Since every 6. is a Traversal, we can use this as a form of  monadic strength. ( transposeOf _2 :: (b, [a]) -> [(b, a)] A Generalizes % to an arbitrary 5.  " mapAccumR = mapAccumROf traverse A' accumulates state from right to left. L mapAccumROf :: Iso a b c d -> (s -> c -> (s, d)) -> s -> a -> (s, b) L mapAccumROf :: Lens a b c d -> (s -> c -> (s, d)) -> s -> a -> (s, b) L mapAccumROf :: Traversal a b c d -> (s -> c -> (s, d)) -> s -> a -> (s, b) B Generalized & to an arbitrary 5.  " mapAccumL = mapAccumLOf traverse B' accumulates state from left to right. L mapAccumLOf :: Iso a b c d -> (s -> c -> (s, d)) -> s -> a -> (s, b) L mapAccumLOf :: Lens a b c d -> (s -> c -> (s, d)) -> s -> a -> (s, b) L mapAccumLOf :: Traversal a b c d -> (s -> c -> (s, d)) -> s -> a -> (s, b) CPermit the use of ' over an arbitrary 5 or 6.   scanr1 = scanr1Of traverse : scanr1Of :: Iso a b c c -> (c -> c -> c) -> a -> b : scanr1Of :: Lens a b c c -> (c -> c -> c) -> a -> b : scanr1Of :: Traversal a b c c -> (c -> c -> c) -> a -> b DPermit the use of ( over an arbitrary 5 or 6.   scanl1 = scanl1Of traverse : scanr1Of :: Iso a b c c -> (c -> c -> c) -> a -> b : scanr1Of :: Lens a b c c -> (c -> c -> c) -> a -> b : scanr1Of :: Traversal a b c c -> (c -> c -> c) -> a -> b E;This setter can be used to map over all of the values in a .  fmap = adjust mapped  fmapDefault = adjust traverse  (<$) = set mapped FBuild a Setter.   sets . adjust = id  adjust . sets = id  sets = from adjust  adjust = from sets 0 sets :: ((c -> d) -> a -> b) -> Setter a b c d GModify the target of a 6 or all the targets of a + or 5  with a function.   fmap = adjust mapped  fmapDefault = adjust traverse   sets . adjust = id  adjust . sets = id 0 adjust :: Setter a b c d -> (c -> d) -> a -> b HModify the target of a 6 or all the targets of a + or 5 P with a function. This is an alias for adjust that is provided for consistency.   mapOf = adjust   fmap = mapOf mapped  fmapDefault = mapOf traverse   sets . mapOf = id  mapOf . sets = id 2 mapOf :: Setter a b c d -> (c -> d) -> a -> b 2 mapOf :: Iso a b c d -> (c -> d) -> a -> b 2 mapOf :: Lens a b c d -> (c -> d) -> a -> b 2 mapOf :: Traversal a b c d -> (c -> d) -> a -> b IReplace the target of a 6 or all of the targets of a +  or 5 with a constant value.   (<$) = set mapped ) set :: Setter a b c d -> d -> a -> b ) set :: Iso a b c d -> d -> a -> b ) set :: Lens a b c d -> d -> a -> b ) set :: Traversal a b c d -> d -> a -> b JModifies the target of a 6 or all of the targets of a + or  5 with a user supplied function. This is an infix version of G   fmap f = mapped %~ f  fmapDefault f = traverse %~ f  " ghci> _2 %~ length $ (1,"hello")  (1,5) 1 (%~) :: Setter a b c d -> (c -> d) -> a -> b 1 (%~) :: Iso a b c d -> (c -> d) -> a -> b 1 (%~) :: Lens a b c d -> (c -> d) -> a -> b 1 (%~) :: Traversal a b c d -> (c -> d) -> a -> b KReplace the target of a 6 or all of the targets of a +  or 5 with a constant value. This is an infix version of I   f <$ a = mapped ^~ f $ a   ghci> bitAt 0 ^~ True $ 0  1 * (^~) :: Setter a b c d -> d -> a -> b * (^~) :: Iso a b c d -> d -> a -> b * (^~) :: Lens a b c d -> d -> a -> b * (^~) :: Traversal a b c d -> d -> a -> b L0Increment the target(s) of a numerically valued 6, Setter' or 5  ghci> _1 +~ 1 $ (1,2)  (2,2) M/Multiply the target(s) of a numerically valued 6, &, + or 5  ghci> _2 *~ 4 $ (1,2)  (1,8) N0Decrement the target(s) of a numerically valued 6, &, + or 5  ghci> _1 -~ 2 $ (1,2)  (-1,2) O-Divide the target(s) of a numerically valued 6, &, + or 5 P Logically ) the target(s) of a *-valued 6 or + Q Logically + the target(s) of a *-valued 6 or + R,Modify the target of a monoidally valued by ,ing another value. SBuild a )% from an arbitrary Haskell function.   to f . to g = to (g . f)  to = from view  to . from = id TView the value pointed to by a ), & or 6 or the result of folding over  all the results of a ' or 5# that points at a monoidal values. It may be useful to think of T. as having these more restrictive signatures: 1 view :: Getter a c -> a -> c 1 view :: Monoid m => Fold a m -> a -> m 1 view :: Iso a b c d -> a -> c 1 view :: Lens a b c d -> a -> c 1 view :: Monoid m => Traversal a b m d -> a -> m UView the value of a ), &, 6# or the result of folding over the $ result of mapping the targets of a ' or 5. It may be useful to think of U. as having these more restrictive signatures:  > views :: Getter a c -> (c -> d) -> a -> d > views :: Monoid m => Fold a c -> (c -> m) -> a -> m > views :: Iso a b c d -> (c -> d) -> a -> d > views :: Lens a b c d -> (c -> d) -> a -> d > views :: Monoid m => Traversal a b c d -> (c -> m) -> a -> m E views :: ((c -> Const m d) -> a -> Const m b) -> (c -> m) -> a -> m VView the value pointed to by a ), & or 6 or the result of folding over  all the results of a ' or 5# that points at a monoidal values. This is the same operation as T, only infix.  1 (^$) :: Getter a c -> a -> c 1 (^$) :: Monoid m => Fold a m -> a -> m 1 (^$) :: Iso a b c d -> a -> c 1 (^$) :: Lens a b c d -> a -> c 1 (^$) :: Monoid m => Traversal a b m d -> a -> m 8 (^$) :: ((c -> Const c d) -> a -> Const c b) -> a -> c WView the value pointed to by a ) or 6 or the result of folding over  all the results of a ' or 5# that points at a monoidal values. This is the same operation as T with the arguments flipped. HThe fixity and semantics are such that subsequent field accesses can be  performed with (Prelude..)  , ghci> ((0, 1 :+ 2), 3)^._1._2.to magnitude  2.23606797749979  1 (^.) :: a -> Getter a c -> c 1 (^.) :: Monoid m => a -> Fold a m -> m 1 (^.) :: a -> Iso a b c d -> c 1 (^.) :: a -> Lens a b c d -> c 1 (^.) :: Monoid m => a -> Traversal a b m d -> m 8 (^.) :: a -> ((c -> Const c d) -> a -> Const c b) -> c XJThis is a lens that can change the value (and type) of the first field of  a pair.   ghci> (1,2)^._1  1   ghci> _1 +~ "hello" $ (1,2)  ("hello",2) 3 _1 :: Functor f => (a -> f b) -> (a,c) -> f (a,c) YAs X&, but for the second field of a pair.  + anyOf _2 :: (c -> Bool) -> (a, c) -> Bool Y traverse._2 :: (Applicative f, Traversable t) => (a -> f b) -> t (c, a) -> f (t (c, b)) S foldMapOf (traverse._2) :: (Traversable t, Monoid m) => (c -> m) -> t (b, c) -> m 3 _2 :: Functor f => (a -> f b) -> (c,a) -> f (c,b) ZHThis lens can be used to change the result of a function but only where $ the arguments match the key given. [Tell a part of a value to a -, filling in the rest from . % whisper l d = tell (set l d mempty) \Query the target of a 6, & or ) in the current state, or use a  summary of a ' or 5" that points to a monoidal value.  B query :: MonadReader a m => Getter a c -> m c B query :: (MonadReader a m, Monoid c) => Fold a c -> m c B query :: MonadReader a m => Iso a b c d -> m c B query :: MonadReader a m => Lens a b c d -> m c B query :: (MonadReader a m, Monoid c) => Traversal a b c d -> m c I query :: MonadReader a m => ((c -> Const c d) -> a -> Const c b) -> m c ]Use the target of a 6, & or ) in the current state, or use a  summary of a ' or 5" that points to a monoidal value.  P queries :: MonadReader a m => Getter a c -> (c -> e) -> m e P queries :: (MonadReader a m, Monoid c) => Fold a c -> (c -> e) -> m e P queries :: MonadReader a m => Iso a b c d -> (c -> e) -> m e P queries :: MonadReader a m => Lens a b c d -> (c -> e) -> m e P queries :: (MonadReader a m, Monoid c) => Traversal a b c d -> (c -> e) -> m e W queries :: MonadReader a m => ((c -> Const e d) -> a -> Const e b) -> (c -> e) -> m e ^Use the target of a 6, &, or ) in the current state, or use a  summary of a ' or 5" that points to a monoidal value.  ? use :: MonadState a m => Getter a c -> m c ? use :: (MonadState a m, Monoid r) => Fold a r -> m r ? use :: MonadState a m => Iso a b c d -> m c ? use :: MonadState a m => Lens a b c d -> m c ? use :: (MonadState a m, Monoid r) => Traversal a b r d -> m r F use :: MonadState a m => ((c -> Const c d) -> a -> Const c b) -> m c _Use the target of a 6, & or ) in the current state, or use a  summary of a ' or 5" that points to a monoidal value.  L uses :: MonadState a m => Getter a c -> (c -> e) -> m e L uses :: (MonadState a m, Monoid r) => Fold a c -> (c -> r) -> m r L uses :: MonadState a m => Lens a b c d -> (c -> e) -> m e L uses :: MonadState a m => Iso a b c d -> (c -> e) -> m e L uses :: (MonadState a m, Monoid r) => Traversal a b c d -> (c -> r) -> m r S uses :: MonadState a m => ((c -> Const e d) -> a -> Const e b) -> (c -> e) -> m e `Replace the target of a 6 or all of the targets of a + or 5 in our monadic 2 state with a new value, irrespective of the old. : (^=) :: MonadState a m => Iso a a c d -> d -> m () : (^=) :: MonadState a m => Lens a a c d -> d -> m () : (^=) :: MonadState a m => Traversal a a c d -> d -> m () : (^=) :: MonadState a m => Setter a a c d -> d -> m () aMap over the target of a 6 or all of the targets of a + or ' Traversal in our monadic state. A (%=) :: MonadState a m => Iso a a c d -> (c -> d) -> m () A (%=) :: MonadState a m => Lens a a c d -> (c -> d) -> m () A (%=) :: MonadState a m => Traversal a a c d -> (c -> d) -> m () A (%=) :: MonadState a m => Setter a a c d -> (c -> d) -> m () bModify the target(s) of a 4 6, &, + or 5 by adding a value  Example:  fresh = do  id += 1  access id cModify the target(s) of a 4 6, &, + or 5 by subtracting a value dModify the target(s) of a 4 6, &, + or 5 by multiplying by value eModify the target(s) of a 4 6, &, + or 5 by dividing by a value fModify the target(s) of a 4 6, &, + or 5 by taking their logical + with a value gModify the target(s) of a 4 6, 'Iso, + or 5 by taking their logical ) with a value hModify the target(s) of a 4 6, &, + or 5 by , ing a value. iBuild a ) or ' from a /-like function. E folds :: ((c -> m) -> a -> m) -> (c -> Const m d) -> a -> Const m b 4 folds :: ((c -> m) -> a -> m) -> Getting m a b c d j Obtain a '9 by lifting an operation that returns a foldable result. +This can be useful to lift operations from  Data.List and elsewhere into a '. k Obtain a ' from any !.  folded = folds foldMap l Obtain a ' by filtering a 6, &, 'Getter, ' or 5. m Obtain a '+ by reversing the order of traversal for a 6, &, ), ' or 5. Of course, reversing a ' or ) has no effect. n Obtain a '! by taking elements from another ', 6, &, ) or 5 while a predicate holds.  / takeWhile p = toListOf (takingWhile p folded) / ghci> toList (takingWhile (<=3) folded) [1..]  [1,2,3] o Obtain a '# by dropping elements from another ', 6, &, ) or 5 while a predicate holds.  1 dropWhile p = toListOf (droppingWhile p folded) . ghci> toList (dropWhile (<=3) folded) [1..6]  [4,5,6] p  foldMap = foldMapOf folded   foldMapOf = views  foldMapOf = from folds  B foldMapOf :: Getter a c -> (c -> m) -> a -> m B foldMapOf :: Monoid m => Fold a c -> (c -> m) -> a -> m B foldMapOf :: Lens a b c d -> (c -> m) -> a -> m B foldMapOf :: Iso a b c d -> (c -> m) -> a -> m B foldMapOf :: Monoid m => Traversal a b c d -> (c -> m) -> a -> m 6 foldMapOf :: Getting m a b c d -> (c -> m) -> a -> m q  fold = foldOf folded   foldOf = view 3 foldOf :: Getter a m -> a -> m 3 foldOf :: Monoid m => Fold a m -> a -> m 3 foldOf :: Lens a b m d -> a -> m 3 foldOf :: Iso a b m d -> a -> m 3 foldOf :: Monoid m => Traversal a b m d -> a -> m rIRight-associative fold of parts of a structure that are viewed through a 6, ), ' or 5.   foldr = foldrOf folded > foldrOf :: Getter a c -> (c -> e -> e) -> e -> a -> e > foldrOf :: Fold a c -> (c -> e -> e) -> e -> a -> e > foldrOf :: Lens a b c d -> (c -> e -> e) -> e -> a -> e > foldrOf :: Iso a b c d -> (c -> e -> e) -> e -> a -> e > foldrOf :: Traversal a b c d -> (c -> e -> e) -> e -> a -> e sLLeft-associative fold of the parts of a structure that are viewed through a 6, ), ' or 5.   foldl = foldlOf folded > foldlOf :: Getter a c -> (e -> c -> e) -> e -> a -> e > foldlOf :: Fold a c -> (e -> c -> e) -> e -> a -> e > foldlOf :: Lens a b c d -> (e -> c -> e) -> e -> a -> e > foldlOf :: Iso a b c d -> (e -> c -> e) -> e -> a -> e > foldlOf :: Traversal a b c d -> (e -> c -> e) -> e -> a -> e t  toList = toListOf folded + toListOf :: Getter a c -> a -> [c] + toListOf :: Fold a c -> a -> [c] + toListOf :: Lens a b c d -> a -> [c] + toListOf :: Iso a b c d -> a -> [c] + toListOf :: Traversal a b c d -> a -> [c] u  and = andOf folded + andOf :: Getter a Bool -> a -> Bool + andOf :: Fold a Bool -> a -> Bool + andOf :: Lens a b Bool d -> a -> Bool + andOf :: Iso a b Bool d -> a -> Bool + andOf :: Traversl a b Bool d -> a -> Bool v  or = orOf folded + orOf :: Getter a Bool -> a -> Bool + orOf :: Fold a Bool -> a -> Bool + orOf :: Lens a b Bool d -> a -> Bool + orOf :: Iso a b Bool d -> a -> Bool + orOf :: Traversal a b Bool d -> a -> Bool w  any = anyOf folded 8 anyOf :: Getter a c -> (c -> Bool) -> a -> Bool 8 anyOf :: Fold a c -> (c -> Bool) -> a -> Bool 8 anyOf :: Lens a b c d -> (c -> Bool) -> a -> Bool 8 anyOf :: Iso a b c d -> (c -> Bool) -> a -> Bool 8 anyOf :: Traversal a b c d -> (c -> Bool) -> a -> Bool x  all = allOf folded 8 allOf :: Getter a c -> (c -> Bool) -> a -> Bool 8 allOf :: Fold a c -> (c -> Bool) -> a -> Bool 8 allOf :: Lens a b c d -> (c -> Bool) -> a -> Bool 8 allOf :: Iso a b c d -> (c -> Bool) -> a -> Bool 8 allOf :: Traversal a b c d -> (c -> Bool) -> a -> Bool y  product = productOf folded 3 productOf :: Getter a c -> a -> c 3 productOf :: Num c => Fold a c -> a -> c 3 productOf :: Lens a b c d -> a -> c 3 productOf :: Iso a b c d -> a -> c 3 productOf :: Num c => Traversal a b c d -> a -> c z  sum = sumOf folded   sumOf _1 :: (a, b) -> a ; sumOf (folded._1) :: (Foldable f, Num a) => f (a, b) -> a / sumOf :: Getter a c -> a -> c / sumOf :: Num c => Fold a c -> a -> c / sumOf :: Lens a b c d -> a -> c / sumOf :: Iso a b c d -> a -> c / sumOf :: Num c => Traversal a b c d -> a -> c {When passed a ), { can work over a . When passed a ', { requires an $.   traverse_ = traverseOf_ folded  > traverseOf_ _2 :: Functor f => (c -> f e) -> (c1, c) -> f () O traverseOf_ traverseLeft :: Applicative f => (a -> f b) -> Either a c -> f () bThe rather specific signature of traverseOf_ allows it to be used as if the signature was either: N traverseOf_ :: Functor f => Getter a c -> (c -> f e) -> a -> f () N traverseOf_ :: Applicative f => Fold a c -> (c -> f e) -> a -> f () N traverseOf_ :: Functor f => Lens a b c d -> (c -> f e) -> a -> f () N traverseOf_ :: Functor f => Iso a b c d -> (c -> f e) -> a -> f () N traverseOf_ :: Applicative f => Traversal a b c d -> (c -> f e) -> a -> f () |  for_ = forOf_ folded I forOf_ :: Functor f => Getter a c -> a -> (c -> f e) -> f () I forOf_ :: Applicative f => Fold a c -> a -> (c -> f e) -> f () I forOf_ :: Functor f => Lens a b c d -> a -> (c -> f e) -> f () I forOf_ :: Functor f => Iso a b c d -> a -> (c -> f e) -> f () I forOf_ :: Applicative f => Traversal a b c d -> a -> (c -> f e) -> f () } " sequenceA_ = sequenceAOf_ folded F sequenceAOf_ :: Functor f => Getter a (f ()) -> a -> f () F sequenceAOf_ :: Applicative f => Fold a (f ()) -> a -> f () F sequenceAOf_ :: Functor f => Lens a b (f ()) d -> a -> f () F sequenceAOf_ :: Functor f => Iso a b (f ()) d -> a -> f () F sequenceAOf_ :: Applicative f => Traversal a b (f ()) d -> a -> f () ~  mapM_ = mapMOf_ folded D mapMOf_ :: Monad m => Getter a c -> (c -> m e) -> a -> m () D mapMOf_ :: Monad m => Fold a c -> (c -> m e) -> a -> m () D mapMOf_ :: Monad m => Lens a b c d -> (c -> m e) -> a -> m () D mapMOf_ :: Monad m => Iso a b c d -> (c -> m e) -> a -> m () D mapMOf_ :: Monad m => Traversal a b c d -> (c -> m e) -> a -> m ()   forM_ = forMOf_ folded D forMOf_ :: Monad m => Getter a c -> a -> (c -> m e) -> m () D forMOf_ :: Monad m => Fold a c -> a -> (c -> m e) -> m () D forMOf_ :: Monad m => Lens a b c d -> a -> (c -> m e) -> m () D forMOf_ :: Monad m => Iso a b c d -> a -> (c -> m e) -> m () D forMOf_ :: Monad m => Traversal a b c d -> a -> (c -> m e) -> m ()   sequence_ = sequenceOf_ folded > sequenceOf_ :: Monad m => Getter a (m b) -> a -> m () > sequenceOf_ :: Monad m => Fold a (m b) -> a -> m () > sequenceOf_ :: Monad m => Lens a b (m b) d -> a -> m () > sequenceOf_ :: Monad m => Iso a b (m b) d -> a -> m () > sequenceOf_ :: Monad m => Traversal a b (m b) d -> a -> m () 1The sum of a collection of actions, generalizing .   asum = asumOf folded : asumOf :: Alternative f => Getter a c -> a -> f c : asumOf :: Alternative f => Fold a c -> a -> f c : asumOf :: Alternative f => Lens a b c d -> a -> f c : asumOf :: Alternative f => Iso a b c d -> a -> f c : asumOf :: Alternative f => Traversal a b c d -> a -> f c 1The sum of a collection of actions, generalizing .   msum = msumOf folded 8 msumOf :: MonadPlus m => Getter a c -> a -> m c 8 msumOf :: MonadPlus m => Fold a c -> a -> m c 8 msumOf :: MonadPlus m => Lens a b c d -> a -> m c 8 msumOf :: MonadPlus m => Iso a b c d -> a -> m c 8 msumOf :: MonadPlus m => Traversal a b c d -> a -> m c   elem = elemOf folded 7 elemOf :: Eq c => Getter a c -> c -> a -> Bool 7 elemOf :: Eq c => Fold a c -> c -> a -> Bool 7 elemOf :: Eq c => Lens a b c d -> c -> a -> Bool 7 elemOf :: Eq c => Iso a b c d -> c -> a -> Bool 7 elemOf :: Eq c => Traversal a b c d -> c -> a -> Bool   notElem = notElemOf folded : notElemOf :: Eq c => Getter a c -> c -> a -> Bool : notElemOf :: Eq c => Fold a c -> c -> a -> Bool : notElemOf :: Eq c => Iso a b c d -> c -> a -> Bool : notElemOf :: Eq c => Lens a b c d -> c -> a -> Bool : notElemOf :: Eq c => Traversal a b c d -> c -> a -> Bool   concatMap = concatMapOf folded < concatMapOf :: Getter a c -> (c -> [e]) -> a -> [e] < concatMapOf :: Fold a c -> (c -> [e]) -> a -> [e] < concatMapOf :: Lens a b c d -> (c -> [e]) -> a -> [e] < concatMapOf :: Iso a b c d -> (c -> [e]) -> a -> [e] < concatMapOf :: Traversal a b c d -> (c -> [e]) -> a -> [e]   concat = concatOf folded - concatOf :: Getter a [e] -> a -> [e] - concatOf :: Fold a [e] -> a -> [e] - concatOf :: Iso a b [e] d -> a -> [e] - concatOf :: Lens a b [e] d -> a -> [e] - concatOf :: Traversal a b [e] d -> a -> [e] ;Note: this can be rather inefficient for large containers.   length = lengthOf folded   lengthOf _1 :: (a, b) -> Int  lengthOf _1 = 1 : lengthOf (folded.folded) :: Foldable f => f (g a) -> Int + lengthOf :: Getter a c -> a -> Int + lengthOf :: Fold a c -> a -> Int + lengthOf :: Lens a b c d -> a -> Int + lengthOf :: Iso a b c d -> a -> Int + lengthOf :: Traversal a b c d -> a -> Int Perform a safe 0 of a ' or 5 or retrieve 1 the result  from a ) or 6.  & listToMaybe . toList = headOf folded - headOf :: Getter a c -> a -> Maybe c - headOf :: Fold a c -> a -> Maybe c - headOf :: Lens a b c d -> a -> Maybe c - headOf :: Iso a b c d -> a -> Maybe c - headOf :: Traversal a b c d -> a -> Maybe c Perform a safe 2 of a ' or 5 or retrieve 1 the result  from a ) or 6. - lastOf :: Getter a c -> a -> Maybe c - lastOf :: Fold a c -> a -> Maybe c - lastOf :: Lens a b c d -> a -> Maybe c - lastOf :: Iso a b c d -> a -> Maybe c - lastOf :: Traversal a b c d -> a -> Maybe c Returns 3 if this ' or 5( has no targets in the given container. Note: nullOf on a valid &, 6 or ) should always return 4   null = nullOf folded /This may be rather inefficient compared to the 5 check of many containers.   nullOf _1 :: (a, b) -> Int  nullOf _1 = False ? nullOf (folded._1.folded) :: Foldable f => f (g a, b) -> Bool * nullOf :: Getter a c -> a -> Bool * nullOf :: Fold a c -> a -> Bool * nullOf :: Iso a b c d -> a -> Bool * nullOf :: Lens a b c d -> a -> Bool * nullOf :: Traversal a b c d -> a -> Bool 2Obtain the maximum element (if any) targeted by a ' or 5 Note: maximumOf on a valid &, 6 or ) will always return 1 a value.  8 maximum = fromMaybe (error "empty") . maximumOf folded 9 maximumOf :: Getter a c -> a -> Maybe c 9 maximumOf :: Ord c => Fold a c -> a -> Maybe c 9 maximumOf :: Iso a b c d -> a -> Maybe c 9 maximumOf :: Lens a b c d -> a -> Maybe c 9 maximumOf :: Ord c => Traversal a b c d -> a -> Maybe c 2Obtain the minimum element (if any) targeted by a ' or 5 Note: minimumOf on a valid &, 6 or ) will always return 1 a value.  8 minimum = fromMaybe (error "empty") . minimumOf folded 9 minimumOf :: Getter a c -> a -> Maybe c 9 minimumOf :: Ord c => Fold a c -> a -> Maybe c 9 minimumOf :: Iso a b c d -> a -> Maybe c 9 minimumOf :: Lens a b c d -> a -> Maybe c 9 minimumOf :: Ord c => Traversal a b c d -> a -> Maybe c 2Obtain the maximum element (if any) targeted by a ', 5, 6, &,  or )( according to a user supplied ordering.  D maximumBy cmp = fromMaybe (error "empty") . maximumByOf folded cmp J maximumByOf :: Getter a c -> (c -> c -> Ordering) -> a -> Maybe c J maximumByOf :: Fold a c -> (c -> c -> Ordering) -> a -> Maybe c J maximumByOf :: Iso a b c d -> (c -> c -> Ordering) -> a -> Maybe c J maximumByOf :: Lens a b c d -> (c -> c -> Ordering) -> a -> Maybe c J maximumByOf :: Traversal a b c d -> (c -> c -> Ordering) -> a -> Maybe c 2Obtain the minimum element (if any) targeted by a ', 5, 6, &  or )( according to a user supplied ordering.  D minimumBy cmp = fromMaybe (error "empty") . minimumByOf folded cmp J minimumByOf :: Getter a c -> (c -> c -> Ordering) -> a -> Maybe c J minimumByOf :: Fold a c -> (c -> c -> Ordering) -> a -> Maybe c J minimumByOf :: Iso a b c d -> (c -> c -> Ordering) -> a -> Maybe c J minimumByOf :: Lens a b c d -> (c -> c -> Ordering) -> a -> Maybe c J minimumByOf :: Traversal a b c d -> (c -> c -> Ordering) -> a -> Maybe c The ? function takes a lens (or , getter, iso, fold, or traversal), O a predicate and a structure and returns the leftmost element of the structure  matching the predicate, or 6 if there is no such element. < findOf :: Getter a c -> (c -> Bool) -> a -> Maybe c < findOf :: Fold a c -> (c -> Bool) -> a -> Maybe c < findOf :: Iso a b c d -> (c -> Bool) -> a -> Maybe c < findOf :: Lens a b c d -> (c -> Bool) -> a -> Maybe c < findOf :: Traversal a b c d -> (c -> Bool) -> a -> Maybe c  A variant of r4 that has no base case and thus may only be applied K to lenses and structures such that the lens views at least one element of  the structure.  . foldr1Of l f = Prelude.foldr1 f . toListOf l   foldr1 = foldr1Of folded : foldr1Of :: Getter a c -> (c -> c -> c) -> a -> c : foldr1Of :: Fold a c -> (c -> c -> c) -> a -> c : foldr1Of :: Iso a b c d -> (c -> c -> c) -> a -> c : foldr1Of :: Lens a b c d -> (c -> c -> c) -> a -> c : foldr1Of :: Traversal a b c d -> (c -> c -> c) -> a -> c  A variant of sQ that has no base case and thus may only be applied to lenses and strutures such < that the lens views at least one element of the structure.  . foldl1Of l f = Prelude.foldl1Of l f . toList   foldl1 = foldl1Of folded : foldl1Of :: Getter a c -> (c -> c -> c) -> a -> c : foldl1Of :: Fold a c -> (c -> c -> c) -> a -> c : foldl1Of :: Iso a b c d -> (c -> c -> c) -> a -> c : foldl1Of :: Lens a b c d -> (c -> c -> c) -> a -> c : foldl1Of :: Traversal a b c d -> (c -> c -> c) -> a -> c 6Strictly fold right over the elements of a structure.   foldr' = foldrOf' folded ? foldrOf' :: Getter a c -> (c -> e -> e) -> e -> a -> e ? foldrOf' :: Fold a c -> (c -> e -> e) -> e -> a -> e ? foldrOf' :: Iso a b c d -> (c -> e -> e) -> e -> a -> e ? foldrOf' :: Lens a b c d -> (c -> e -> e) -> e -> a -> e ? foldrOf' :: Traversal a b c d -> (c -> e -> e) -> e -> a -> e NFold over the elements of a structure, associating to the left, but strictly.   foldl' = foldlOf' folded A foldlOf' :: Getter a c -> (e -> c -> e) -> e -> a -> e A foldlOf' :: Fold a c -> (e -> c -> e) -> e -> a -> e A foldlOf' :: Iso a b c d -> (e -> c -> e) -> e -> a -> e A foldlOf' :: Lens a b c d -> (e -> c -> e) -> e -> a -> e A foldlOf' :: Traversal a b c d -> (e -> c -> e) -> e -> a -> e IMonadic fold over the elements of a structure, associating to the right,  i.e. from right to left.   foldrM = foldrMOf folded N foldrMOf :: Monad m => Getter a c -> (c -> e -> m e) -> e -> a -> m e N foldrMOf :: Monad m => Fold a c -> (c -> e -> m e) -> e -> a -> m e N foldrMOf :: Monad m => Iso a b c d -> (c -> e -> m e) -> e -> a -> m e N foldrMOf :: Monad m => Lens a b c d -> (c -> e -> m e) -> e -> a -> m e N foldrMOf :: Monad m => Traversal a b c d -> (c -> e -> m e) -> e -> a -> m e HMonadic fold over the elements of a structure, associating to the left,  i.e. from left to right.   foldlM = foldlMOf folded N foldlMOf :: Monad m => Getter a c -> (e -> c -> m e) -> e -> a -> m e N foldlMOf :: Monad m => Fold a c -> (e -> c -> m e) -> e -> a -> m e N foldlMOf :: Monad m => Iso a b c d -> (e -> c -> m e) -> e -> a -> m e N foldlMOf :: Monad m => Lens a b c d -> (e -> c -> m e) -> e -> a -> m e N foldlMOf :: Monad m => Traversal a b c d -> (e -> c -> m e) -> e -> a -> m e BThis is the traversal that never succeeds at returning any values < traverseNothing :: Applicative f => (c -> f d) -> a -> f a ;A traversal for tweaking the left-hand value in an Either: M traverseLeft :: Applicative f => (a -> f b) -> Either a c -> f (Either b c) ,traverse the right-hand value in an Either:   traverseRight = traverse Unfortunately the instance for 'Traversable (Either c)' is still missing  from base, so this can' t just be  N traverseRight :: Applicative f => (a -> f b) -> Either c a -> f (Either c a) This provides a 5) that checks a predicate on a key before ( allowing you to traverse into a value. This allows you to  the elements of a 5 in the  opposite order. Note: m% is similar, but is able to accept a ' (or ))  and produce a ' (or )). This requires at least a 5 (or 6) and can produce a  5 (or 6 ) in turn.  A backwards & is the same &". If you reverse the direction of  the isomorphism use ! instead. 9Merge two lenses, getters, setters, folds or traversals. 6 makes a lens from two other lenses (or isomorphisms) @Build an isomorphism family from two pairs of inverse functions E isos :: (a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> Iso a b c d <Build a simple isomorphism from a pair of inverse functions / iso :: (a -> b) -> (b -> a) -> Simple Iso a b :This isomorphism can be used to wrap or unwrap a value in 7.  x^.identity = Identity x  Identity x^.from identity = x :This isomorphism can be used to wrap or unwrap a value in #  x^.konst = Const x  Const x^.from konst = x  Cloning a 6) is one way to make sure you arent given  something weaker, such as a 5 and can be used ? as a way to pass around lenses that have to be monomorphic in f. !Note: This only accepts a proper 6 , because  lacks its $ (admissable) Applicative instance. #$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~89:!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~6054231897XYZ&%$#!+*FEGHI[KJ`a)'(SijklmnoTUWV^_\]pqrstwxuvyz{|}~LNMOPQRbcdegfh,-./:;<=>?@BACD#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~89: RankNTypes provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedGSometimes you need to store a path lens into a container, but at least F at this time, impredicative polymorphism in GHC is somewhat lacking. FThis type provides a way to, say, store a list of polymorphic lenses. Representable Functors. A  f is  if it is isomorphic to (x -> a) > for some x. All such functors can be represented by choosing x to be ? the set of lenses that are polymorphic in the contents of the ,  that is to say  x = Rep f is a valid choice of x for every   . @Note: Some sources refer to covariant representable functors as ) corepresentable functors, and leave the " representable" name to 1 contravariant functors (those are isomorphic to (a -> x) for some x). LAs the covariant case is vastly more common, and both are often referred to = as representable functors, we choose to call these functors   here. The representation of a   as Lenses # is a valid default definition for ; for a representable  functor.  $ fmapRep f m = rep $ \i -> f (m^.i) "Usage for a representable functor Foo:  instance Functor Foo where  fmap = fmapRep # is a valid default definition for < and = for a  representable functor.   pureRep = rep . const "Usage for a representable functor Foo:   instance Applicative Foo where  pure = pureRep  (<*>) = apRep  instance Monad Foo where  return = pureRep  (>>=) = bindRep # is a valid default definition for '( *)' for a representable  functor.  ) apRep mf ma = rep $ \i -> mf^.i $ ma^.i "Usage for a representable functor Foo:  instance Applicative Foo where  pure = pureRep  (<*>) = apRep + is a valid default default definition for '(>>=)' for a  representable functor.  & bindRep m f = rep $ \i -> f(m^.i)^.i "Usage for a representable functor Foo:  instance Monad ... where  return = pureRep  (>>=) = bindRep A default definition for  for a    . distributeRep wf = rep $ \i -> fmap (^.i) wf Typical Usage: ! instance Distributive ... where  distribute = distributeRep A  . has a fixed shape. This fills each position  in it with a   Map over a  " with access to the lens for the  current position ) mapWithKey f m = rep $ \i -> f i (m^.i)  Traverse a  ! with access to the current path  Traverse a  ! with access to the current path " as a lens, discarding the result  Traverse a  ! with access to the current path ( and a lens (and the arguments flipped) > over a  ! with access to the current path  as a lens > over a  ! with access to the current path " as a lens, discarding the result > over a  ! with access to the current path ( as a lens (with the arguments flipped)  Fold over a  ! with access to the current path  as a lens, yielding a "  Fold over a  ! with access to the current path  as a lens. ?CNB: The Eq requirement on this instance is a consequence of a lens  rather than e as the representation. ?@?@portable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedEvaluate the targets of a 6 or 5 into a data structure " according to the given strategy.  * evalTraversable = evalTraversal traverse   evalTraversal = id  > evalTraversal :: Simple Lens a b -> Strategy b -> Strategy a C evalTraversal :: Simple Traversal a b -> Strategy b -> Strategy a L evalTraversal :: (b -> Eval b) -> a -> Eval a) -> Strategy b -> Strategy a Evaluate the targets of a 6 or 5 according into a % data structure according to a given A in parallel.  ( parTraversable = parTraversal traverse  = parTraversal :: Simple Lens a b -> Strategy b -> Strategy a B parTraversal :: Simple Traversal a b -> Strategy b -> Strategy a L parTraversal :: ((b -> Eval b) -> a -> Eval a) -> Strategy b -> Strategy a  Transform a 6, ', ), + or 5 to P first evaluates its argument according to a given strategy, before proceeding.  after rdeepseq traverse  Transform a 6, ', ), + or 5 to R evaluate its argument according to a given strategy in parallel with evaluating.  meanwhile rdeepseq traverse portable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedDEvaluate the elements targeted by a Lens, Traversal, Getter or Fold " according to the given strategy.  seqFoldable = seqOf folded &MPTCs, Rank2Types, LiberalTypeSynonyms provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedAccess an element of an array. CNote: The indexed element is assumed to exist in the target array.   arr ! i = arr^.ix i " arr // [(i,e)] = ix i ^= e $ arr / ghci> ix 2 ^= 9 $ listArray (1,5) [4,5,6,7,8]  array (1,5) [4,9,6,7,8] CThis setter can be used to map over all of the values in an array. Note: 6 is strictly more general and permits more operations  amap = adjust amapped  amapped = sets amap CThis setter can be used to derive a new array from an old array by - applying a function to each of the indices.  ixmap = adjust . ixmapped  ixmapped = sets . ixmap Generic 5 of the elements of an array.  amap = adjust traverseArray  LiberalTypeSynonyms provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedBitwise B the target(s) of a *-valued 6 or + Bitwise C the target(s) of a *-valued 6 or + Modify the target(s) of a 4 6, + or 5 by computing its bitwise C with another value. Modify the target(s) of a 4 6, + or 5 by computing its bitwise B with another value. FThis lens can be used to access the value of the nth bit in a number. bitsAt n is only a legal 6 into b if 0 <= n < bitSize (undefined :: b) *Traverse over all bits in a numeric type.  * ghci> toListOf traverseBits (5 :: Word8) 1 [True,False,True,False,False,False,False,False] %If you supply this an Integer, it won't crash, but the result will = be an infinite traversal that can be productively consumed.  ghci> toListOf traverseBits 5 K [True,False,True,False,False,False,False,False,False,False,False,False...  portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered(Pack (or unpack) a list of bytes into a D  pack x = x^.packedBytes  unpack x = x^.from packedBytes #Traverse the individual bytes in a D  % bytes = from packedBytes . traverse , anyOf bytes (==0x80) :: ByteString -> Bool -Pack (or unpack) a list of characters into a D FWhen writing back to the byteString it is assumed that all characters  lie between '\x00' and '\xff'.  pack x = x^.packedChars  unpack x = x^.from packedChars #Traverse the individual bytes in a D as characters. FWhen writing back to the byteString it is assumed that all characters  lie between '\x00' and '\xff'.   chars = from packed . traverse + anyOf chars (=='c') :: ByteString -> Bool  portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered(Pack (or unpack) a list of bytes into a E  pack x = x^.packedBytes  unpack x = x^.from packedBytes #Traverse the individual bytes in a E  % bytes = from packedBytes . traverse , anyOf bytes (==0x80) :: ByteString -> Bool -Pack (or unpack) a list of characters into a E FWhen writing back to the byteString it is assumed that all characters  lie between '\x00' and '\xff'.  pack x = x^.packedChars  unpack x = x^.from packedChars #Traverse the individual bytes in a E as characters. FWhen writing back to the byteString it is assumed that all characters  lie between '\x00' and '\xff'.   chars = from packed . traverse + anyOf chars (=='c') :: ByteString -> Bool   Haskell2010 provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered)Access the real part of a complex number ? real :: Functor f => (a -> f a) -> Complex a -> f (Complex a) .Access the imaginary part of a complex number D imaginary :: Functor f => (a -> f a) -> Complex a -> f (Complex a) This isn't quite a legal lens. Notably the view l (set l b a) = b law L is violated when you set a polar value with 0 magnitude and non-zero phase ) as the phase information is lost. So don' t do that! Otherwise, this is a  perfectly cromulent lens. @Traverse both the real and imaginary parts of a complex number. N traverseComplex :: Applicative f => (a -> f b) -> Complex a -> f (Complex b)  portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered(Traverse the typed value contained in a F7 where the type required by your function matches that  of the contents of the F. b traverseDynamic :: (Applicative f, Typeable a, Typeable b) => (a -> f b) -> Dynamic -> f Dynamic  Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedThis 6K can be used to read, write or delete the value associated with a key in a G.  0 ghci> Map.fromList [("hello",12)] ^.at "hello"  Just 12 H at :: Ord k => k -> (Maybe v -> f (Maybe v)) -> Map k v -> f (Map k v) +Traverse the value at a given key in a Map S traverseAt :: (Applicative f, Ord k) => k -> (v -> f v) -> Map k v -> f (Map k v) % traverseAt k = valueAt k . traverse /Traverse the value at the minimum key in a Map /Traverse the value at the maximum key in a Map  Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedThis 6L can be used to read, write or delete the value associated with a key in an H.  % ghci> fromList [(1,"hello")] ^.at 1  Just "hello"  % ghci> at 1 ^~ Just "hello" $ mempty  fromList [(1,"hello")] C at :: Int -> (Maybe v -> f (Maybe v)) -> IntMap v -> f (IntMap v) /Traverse the value at a given key in an IntMap N traverseAt :: Applicative f => Int -> (v -> f v) -> IntMap v -> f (IntMap v)  traverseAt k = at k . traverse /Traverse the value at the minimum key in a Map /Traverse the value at the maximum key in a Map portable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedThis 65 can be used to read, write or delete a member of an I  0 ghci> contains 3 +~ False $ fromList [1,2,3,4]  fromList [1,2,4] ; contains :: Int -> (Bool -> f Bool) -> IntSet -> f IntSet This +* can be used to change the contents of an I by mapping  the elements to new values. Sadly, you can't create a valid 5 for a Set, because the number of B elements might change but you can manipulate it by reading using k and  reindexing it via setmap. / ghci> adjust members (+1) (fromList [1,2,3,4]  fromList [2,3,4,5] portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered A 6 that can access the nth element of a J. =Note: This is only a legal lens if there is such an element! A J is isomorphic to a K  viewl m = m^.viewL A J is isomorphic to a L  viewr m = m^.viewR Traverse the head of a J Traverse the tail of a J Traverse the last element of a J 'Traverse all but the last element of a J Traverse the first n elements of a J Traverse all but the first n elements of a J 'Travere all the elements numbered from i to j of a J portable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedThis 64 can be used to read, write or delete a member of a M  4 ghci> contains 3 +~ False $ Set.fromList [1,2,3,4]  fromList [1,2,4] B contains :: Ord k => k -> (Bool -> f Bool) -> Set k -> f (Set k) This +% can be used to change the type of a M by mapping  the elements to new values. Sadly, you can't create a valid 5 for a M, but you can  manipulate it by reading using k and reindexing it via setmap. / ghci> adjust members (+1) (fromList [1,2,3,4]  fromList [2,3,4,5] portable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedPack (or unpack) N.  pack x = x^.packed  unpack x = x^.from packed >Traverse the individual characters in a either strict or lazy N. $ anyOf text (=='c') :: Text -> Bool portable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedPack (or unpack) O.  pack x = x^.packed  unpack x = x^.from packed (Traverse the individual characters in a O. $ anyOf text (=='c') :: Text -> Bool LiberalTypeSynonyms provisionalEdward Kmett <ekmett@gmail.com>None ISO 8601 Ordinal Date format $year (proleptic Gregorian calendar) Nday of the year, with 1 for Jan 1, and 365 (or 366 in leap years) for Dec 31. ISO 8601 Week Date format. nThe first week of a year is the first week to contain at least four days in the corresponding Gregorian year. year. Note: that Weekc years are not quite the same as Gregorian years, as the first day of the year is always a Monday. week number (1-53) ,day of week (1 for Monday to 7 for Sunday). &Proleptic Julian year and day format. (year (in the proleptic Julian calendar) Nday of the year, with 1 for Jan 1, and 365 (or 366 in leap years) for Dec 31. *Date in the proleptic Gregorian calendar. year  month (1-12)  day (1-31) ]Ad hoc overloading for accessing the day (what it is relative to may vary from type to type) Get the day of a date ^Ad hoc overloading for accessing the week (what it is relative to may vary from type to type) Get the week of a date +Ad hoc overloading for accessing the month Get the month of a date *Ad hoc overloading for accessing the year Get the year of a date BProvide ad hoc overloading for traversing the modified Julian day GConvert the type to a modified Julian day if possible and traverse it. !Traverses nothing if the date isn' t valid.  =Returns the modified Julian Day as a standard count of days, % with zero being the day 1858-11-17.   Convert tofrom a valid/* date in the proleptic Gregorian calendar   Convert tofrom a valid/ proleptic Julian year and day.   Convert to/from a valid WeekDate   Convert to/+from a valid ISO 8601 Ordinal Date format. P Day of week Q Day of year R Day of month 0     STUPVWXQYZR[\]^!     !          STUPVWXQYZR[\]^portable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedA 6 that focuses on the root of a _. A 5, of the direct descendants of the root of a _. portable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedTraverse the strongly typed ` contained in a) where the type of your function matches  the desired `. @ traverseException :: (Applicative f, Exception a, Exception b) E => (a -> f b) -> SomeException -> f SomeException b !"##$%%&''())*++,--../01223456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~       !"#$%&"'()*+,-,./01213456478459*:;<=*>(?1@AB1C47D47E1FAGHIJKLMN,OPQRSTUVWXWYZ[\Z]\^_`ab`cd`ef`gh`gi`gj`klmnompoqrstuvwxyz{|}~`lens-1.2 Control.LensControl.Lens.THControl.Lens.InternalControl.IsomorphicControl.Lens.Representable Control.Parallel.Strategies.LensControl.Seq.LensData.Array.LensData.Bits.LensData.ByteString.LensData.ByteString.Lazy.LensData.Complex.LensData.Dynamic.Lens Data.Map.LensData.IntMap.LensData.IntSet.LensData.Sequence.Lens Data.Set.LensData.Text.LensData.Text.Lazy.LensData.Time.Calendar.LensData.Tree.LensControl.Exception.Lens Data.List transposeData.Distributive distributebaseData.Traversable Traversabletraverse makeLenses makeLensesFor makeLensesByMaxNoMaxMinNoMinAction getAction Traversed getTraversed AppliedStaterunAppliedState IndexedStoreFocusing unfocusinggetMingetMax Isomorphism Isomorphic isomorphicisomap:~>fromvia SimpleIsoLikeIsoLike SimpleIsoIsoFoldGettingGetter SimpleSetterSetterFocusfocusfocus_setFocusLensLikeSimpleLensLike SimpleLensSimpleTraversalSimple TraversalLenslens%%~%%= traverseOfforOf sequenceAOfmapMOfforMOf sequenceOf transposeOf mapAccumROf mapAccumLOfscanr1Ofscanl1OfmappedsetsadjustmapOfset%~^~+~*~-~//~||~&&~<>~toviewviews^$^._1_2resultAtwhisperqueryqueriesuseuses^=%=+=-=*=//=&&=||=<>=foldsfoldingfoldedfilteredreversed takingWhile droppingWhile foldMapOffoldOffoldrOffoldlOftoListOfandOforOfanyOfallOf productOfsumOf traverseOf_forOf_ sequenceAOf_mapMOf_forMOf_ sequenceOf_asumOfmsumOfelemOf notElemOf concatMapOfconcatOflengthOfheadOflastOfnullOf maximumOf minimumOf maximumByOf minimumByOffindOffoldr1Offoldl1OffoldrOf'foldlOf'foldrMOffoldlMOftraverseNothing traverseLeft traverseRight traverseValue backwardsmerged bothLensesisosisoidentitykonstcloneKeyturn RepresentablerepRepfmapReppureRepapRepbindRep distributeRepkeys mapWithReptraverseWithReptraverseWithRep_ forWithRep mapMWithRep mapMWithRep_ forMWithRepfoldMapWithRep foldrWithRepevalOfparOfafter meanwhileseqOfixamappedixmapped traverseArray|~&~&=|=bitAt traverseBits packedBytesbytes packedCharscharsreal imaginarypolarizetraverseComplextraverseDynamicat traverseAt traverseAtMin traverseAtMaxcontainsmembersviewLviewR traverseHead traverseTail traverseLast traverseInit traverseTo traverseFrom traverseSlicepackedtext OrdinalDateordinalDateYearordinalDateDayWeekDate weekDateYear weekDateWeek weekDateDayJulianYearAndDayjulianYearAndDayYearjulianYearAndDayDay Gregorian gregorianYeargregorianMonth gregorianDayHasDaydayHasWeekweekHasMonthmonthHasYearyear TraverseDay traverseDaymodifiedJulianDay gregorianjulianYearAndDayweekDate ordinalDaterootchildrentraverseException Control.MonadmapM_GHC.BaseFunctor $fMonoidMax $fMonoidMin$fMonoidAction$fMonoidTraversed$fApplicativeAppliedState$fFunctorAppliedState$fFunctorIndexedStore$fApplicativeFocusing$fFunctorFocusingControl.CategoryCategory$fIsomorphicIsomorphism$fCategoryIsomorphism$fIsomorphic(->)id Data.FoldableFoldable Data.MonoidMonoidControl.ApplicativeConst Applicative mapAccumR mapAccumLGHC.Listscanr1scanl1ghc-prim GHC.Classes|| GHC.TypesBool&&mappend mtl-2.1.2Control.Monad.Writer.Class MonadWritermemptyfoldMaphead Data.MaybeJustlastTrueFalsenullNothingtransformers-0.3.0.0Data.Functor.IdentityIdentity$fFocusReaderT $fFocusStateT$fFocusStateT0fmappurereturnmapM$fRepresentable(->)$fRepresentableIdentityparallel-3.2.0.3Control.Parallel.StrategiesStrategy Data.Bits.|..&.bytestring-0.9.2.1Data.ByteString.Internal ByteStringData.ByteString.Lazy.Internal Data.DynamicDynamiccontainers-0.4.2.1Data.MapMap Data.IntMapIntMap Data.IntSetIntSet Data.SequenceSeqViewLViewRData.SetSet text-0.11.2.2Data.Text.InternalTextData.Text.Lazy.Internal$fHasDayWeekDate$fHasDayJulianYearAndDay$fHasDayGregorian$fHasDayOrdinalDate$fHasYearOrdinalDate$fTraverseDayOrdinalDate$fHasWeekWeekDate$fHasYearWeekDate$fTraverseDayWeekDate$fHasYearJulianYearAndDay$fTraverseDayJulianYearAndDay$fHasMonthGregorian$fHasYearGregorian$fTraverseDayGregorian$fTraverseDayDay Data.TreeTree GHC.Exception Exception SomeException