[$      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXY Z [ \ ] ^!_!`!a!b"c"d"e"f"g#h$i$j$k%l%m%n%o%p%q%r%s%t%u%v%w&x&y&z&{&|&}&~&&&''(()))**++,,,------------..../0 Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred'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 + 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. Invert an isomorphism. ENote to compose an isomorphism and receive an isomorphism in turn you'll need to use     ( l) "a lIf you imported  from Control.Category, then:  l   r "a  (r  l)Convert from an  back to any  value. WThis is useful when you need to store an isomoprhism as a data type inside a container 6 and later reconstitute it as an overloaded function.  Rank2Types provisionalEdward Kmett <ekmett@gmail.com>None%   is just a renamed  functor to give better error = messages when someone attempts to use a getter as a setter. 1Most user code will never need to see this type.  Anything   must be isomorphic to the  . A  for a  . An  K ignores its argument and is isomorphic to a monad wrapped around a value. 9That said, the monad is possibly rather unrelated to any  structure. Used instead of  to report  No instance of (0 )#when the user attempts to misuse a 1 as a  2., rather than a monolithic unification error.  Generalizing  so we can apply simple  > transformations to it and so we can get nicer error messages A  4 ignores its argument, which it carries solely as a  phantom type parameter. To ensure this, an instance of  is required to satisfy:  =  f = #Replace the phantom type argument. OWrap a monadic effect with a phantom type argument. Used when magnifying RWST. 4Wrap a monadic effect with a phantom type argument. This is used to characterize a 3. Ta.k.a. indexed Cartesian store comonad, indexed Kleene store comonad, or an indexed FunList.  *http://twanvl.nl/blog/haskell/non-regular1 Mnemonically, a 0 holds many stores and you can easily add more. This is a final encoding of . !Used to find the nth 4 of a 3. $!The result of trying to find the nth 4 of a 3. ( Used for 5 + Used for 6 .Used internally by 7 and the like. 1Used internally by 8 and the like. 4Applicative composition of 9:  with a , used  by ; 7The result of 4 90The indexed store can be used to characterize a <  and is used by = ;Used by > to ? into @A >Make a monoid out of  for error handling AUsed by > to ? into @A DMake a monoid out of  for error handling GUsed by > to ? into BC or DE JUsed by > to ? into FG. MUsed by > to ? into HI PUsed by > to ? into JK SObtain the minimum. TObtain the maximum UAGiven an action to run for each matched pair, traverse a bazaar. V is an indexed . W A trivial . X.A convenient antonym that is used internally. YThe  equivalent for a   . L so you can pass our a 1, into combinators from other lens libraries 0This instance is a lie, but it is a useful lie.  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYQ  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYQ9:PQRMNOJKLGHI;<=>?@ABCDEF123./045678+-,S(*)T!"#$'&% UVWXY Y    !"#$'&%(*)+-,./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXY"rank 2 types, MPTCs, TFs, flexible provisionalEdward Kmett <ekmett@gmail.com>None ZYA function with access to a index. This constructor may be useful when you need to store  a ] in a container to avoid ImpredicativeTypes. ]*Type alias for passing around polymorphic ^ functions that can be called \ or  directly as a function ^bPermit overloading of function application for things that also admit a notion of a key or index. Provides overloading for ^ functions. _Build a function from an ^ function ` Compose an ^' function with a non-indexed function. Mnemonically, the <* points to the index we want to preserve. a'Compose a non-indexed function with an ^ function. Mnemonically, the >* points to the index we want to preserve. bRemap the index. cComposition of ^ functions Mnemonically, the  @and @: points to the fact that we want to preserve the indices. dComposition of ^> functions with a user supplied function for combining indexs eRTransform an Traversal into an IndexedTraversal, a Fold into an IndexedFold, etc.   e :: 3 a b c d ->  M  a b c d  e :: < a b c d ->  N  a b c d  e :: O a b ->  P  a b  e :: Q a b c d ->  N  a b c d  e :: 2 a b -> R  a b c d CUsing an equality witness to avoid potential overlapping instances  and aid dispatch. Z[\]^_`abcde Z[\]^_`abcde ^_]Z[\c`adbe Z[\]^_`abcderank 2 types, MPTCs experimentalEdward Kmett <ekmett@gmail.com>NonefUseful for storage. iUsed to consume an  P. jEvery j is a valid  P and Getter. fghijfghijjifghfghijMTPCs, FDs, Rank2 experimentalEdward Kmett <ekmett@gmail.com>NonekUsed to evaluate an m. lA l is a Fold enriched with access to a  for side-effects. Every Fold can be used as a l(, that simply ignores the access to the . You can compose a l with another l using ( ) from the Prelude. mAn m is a Getter enriched with access to a  for side-effects. Every Getter can be used as an m You can compose an m with another m using ( ) from the Prelude. n Perform an m.  perform = flip (^!) o Perform an m import Control.Lens&["hello","world"]^!folded.act putStrLnhelloworldp Construct an m from a monadic side-effect qA self-running m, analogous to ST.  q = p import Control.Lens(1,"hello")^!_2.acts.to succ"ifmmp"rApply a  transformer to an m. klmnopqrklmnopqrmpqnrolkklmnopqrportable provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferreds^Passes the result of the left side to the function on the right side (forward pipe operator).  This is the flipped version of (+), which is more common in languages like F# where it is needed e for inference. Here it is supplied for notational convenience and given a precedence that allows it  to be nested inside uses of (). "hello" |> length |> succ6tA strict version of (UV) for monads. (+1) <$!> [1,2,3,4] [2,3,4,5]uA strict version of (UW) for monads. () <$! [1,2,3,4] [(),(),(),()]stustustustu Rank2Types provisionalEdward Kmett <ekmett@gmail.com>None$v type v =  ww)Useful for storing lenses in containers. z type z k f a b =  ({ k f) a b{ type | f a b c d = { (->) f a b c d|Many combinators that accept a  can also accept a  3 in limited situations. 'They do so by specializing the type of  that they require of the  caller. If a function accepts a | f a b c d for some  f,  then they may be passed a .  Further, if f is an , they may also be passed a  3. } type } f =  (| f)~ type ~ =  A  ,  3 , ... can  be used instead of a ,3, ...  whenever the type variables don't change upon setting a value.    !X ::   (YZ a) a  [ ::  \3 [a] a .Note: To use this alias in your own code with | f or  1, you may have to turn on LiberalTypeSynonyms. A + is actually a lens family as described in   /http://comonad.com/reader/2012/mirrored-lenses/. 2With great power comes great responsibility and a is subject to the  three common sense lens laws: !1) You get back what you put in:  ] l (^ l b a) "a b"2) Putting back what you got doesn't change anything:  ^ l (] l a) a "a a.3) Setting twice is the same as setting once:  ^ l c (^ l b a) "a ^ l c a=These laws are strong enough that the 4 type parameters of a  cannot C 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  can be used directly as a Setter or  3. You can also use a  for _ as if it were a  O or 2. Since every lens is a valid 3, the 7 traversal laws are required of any lenses you create:    l  "a    (l f)  l g "a `a  l (`b   f  g)  type  a b c d = forall f.  f => | f a b c dBuild a  from a getter and a setter.  :: 9 f => (a -> c) -> (a -> d -> b) -> (c -> f d) -> a -> f b(') can be used in one of two scenarios: When applied to a  , it can edit the target of the  in a , structure, extracting a functorial result. When applied to a 3, 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:  () "a    () ::  f => Q) a b c d -> (c -> f d) -> a -> f b  () ::  f => ( a b c d -> (c -> f d) -> a -> f b  () ::  f => 3# a b c d -> (c -> f d) -> a -> f b DIt may be beneficial to think about it as if it had these even more  restrictive types, however: When applied to a 3, it can edit the  targets of the  Traversals-, extracting a supplemental monoidal summary  of its actions, by choosing  f = ((,) m)   () :: Q/ a b c d -> (c -> (e, d)) -> a -> (e, b)  () :: . a b c d -> (c -> (e, d)) -> a -> (e, b)  () :: Monoid m => 3) a b c d -> (c -> (m, d)) -> a -> (m, b) Modify the target of a + in the current state returning some extra  information of c or modify all targets of a  3( in the current state, extracting extra  information of type c/ and return a monoidal summary of the changes.  () "a ( )It may be useful to think of ($), instead, as having either of the , following more restricted type signatures:   () ::  a m => Q& a a c d -> (c -> (e, d) -> m e  () ::  a m => % a a c d -> (c -> (e, d) -> m e  () :: ( a m, Monoid e) => 3 a a c d -> (c -> (e, d) -> m e HThis lens can be used to change the result of a function but only where $ the arguments match the key given. 9Merge two lenses, getters, setters, folds or traversals.  makes a ) from two other lenses (or isomorphisms)  Cloning a ) is one way to make sure you arent given  something weaker, such as a 3 and can be D used as a way to pass around lenses that have to be monomorphic in f. !Note: This only accepts a proper . c\"Costate Comonad Coalgebra is equivalent of Java's member variable update technology for Haskell\" -- @PLT_Borat on Twitter Modify the target of a  and return the result 2When you do not need the result of the addition, (c) is more flexible.   () :: ) a b c d -> (c -> d) -> a -> (d, b)  () :: Q* a b c d -> (c -> d) -> a -> (d, b)  () :: Monoid d => 3$ a b c d -> (c -> d) -> a -> (d, b) -Increment the target of a numerically valued  and return the result 2When you do not need the result of the addition, (d) is more flexible.   () ::  b =>   a b -> b -> a -> (b, a)  () ::  b =>  Q a b -> b -> a -> (b, a) -Decrement the target of a numerically valued  and return the result 5When you do not need the result of the subtraction, (e) is more flexible.   () ::  b =>   a b -> b -> a -> (b, a)  () ::  b =>  Q a b -> b -> a -> (b, a) ,Multiply the target of a numerically valued  and return the result 8When you do not need the result of the multiplication, (f ) is more  flexible.   () ::  b =>   a b -> b -> a -> (b, a)  () ::  b =>  Q a b -> b -> a -> (b, a) +Divide the target of a fractionally valued  and return the result. 2When you do not need the result of the division, (g) is more flexible.   () ::  b =>   a b -> b -> a -> (b, a)  () ::  b =>  Q a b -> b -> a -> (b, a) )Raise the target of a numerically valued  to a non-negative   power and return the result 2When you do not need the result of the division, (h) is more flexible.   () :: ( b,  c) =>   a b -> c -> a -> (b, a)  () :: ( b,  c) =>  Q a b -> c -> a -> (b, a) *Raise the target of a fractionally valued  to an  power  and return the result. 2When you do not need the result of the division, (i) is more flexible.   () :: ( b,  c) =>   a b -> c -> a -> (b, a)  () :: ( b,  c) =>  Q a b -> c -> a -> (b, a) ,Raise the target of a floating-point valued  to an arbitrary power  and return the result. 2When you do not need the result of the division, (j) is more flexible.   () ::  b =>   a b -> b -> a -> (b, a)  () ::  b =>  Q a b -> b -> a -> (b, a)  Logically  a Boolean valued  and return the result 3When you do not need the result of the operation, (k) is more flexible.   () ::   a  ->  -> a -> (, a)  () ::  Q a  ->  -> a -> (, a)  Logically  a Boolean valued  and return the result 3When you do not need the result of the operation, (l) is more flexible.   () ::   a  ->  -> a -> (, a)  () ::  Q a  ->  -> a -> (, a) Modify the target of a  into your monad's state by a user supplied ! function and return the result. When applied to a 3D, it this will return a monoidal summary of all of the intermediate  results. 3When you do not need the result of the operation, (m) is more flexible.   () ::  a m =>   a b -> (b -> b) -> m b  () ::  a m =>  Q a b -> (b -> b) -> m b  () :: ( a m, Monoid b) =>  Traveral a b -> (b -> b) -> m b *Add to the target of a numerically valued  into your monad's state  and return the result. 8When you do not need the result of the multiplication, (n ) is more  flexible.   () :: ( a m,  b) =>   a b -> b -> m b  () :: ( a m,  b) =>  Q a b -> b -> m b 1Subtract from the target of a numerically valued  into your monad's  state and return the result. 8When you do not need the result of the multiplication, (o ) is more  flexible.   () :: ( a m,  b) =>   a b -> b -> m b  () :: ( a m,  b) =>  Q a b -> b -> m b ,Multiply the target of a numerically valued  into your monad's  state and return the result. 8When you do not need the result of the multiplication, (p ) is more  flexible.   () :: ( a m,  b) =>   a b -> b -> m b  () :: ( a m,  b) =>  Q a b -> b -> m b +Divide the target of a fractionally valued  into your monad's state  and return the result. 2When you do not need the result of the division, (q) is more flexible.   () :: ( a m,  b) =>   a b -> b -> m b  () :: ( a m,  b) =>  Q a b -> b -> m b )Raise the target of a numerically valued  into your monad's state  to a non-negative  power and return the result. 3When you do not need the result of the operation, (r) is more flexible.   () :: ( a m,  b,  c) =>   a b -> c -> m b  () :: ( a m,  b,  c) =>  Q a b -> c -> m b *Raise the target of a fractionally valued  into your monad's state  to an  power and return the result. 3When you do not need the result of the operation, (s) is more flexible.   () :: ( a m,  b,  c) =>   a b -> c -> m b  () :: ( a m,  b,  c) =>  Q a b -> c -> m b ,Raise the target of a floating-point valued  into your monad's 4 state to an arbitrary power and return the result. 3When you do not need the result of the operation, (r) is more flexible.   () :: ( a m,  b) =>   a b -> b -> m b  () :: ( a m,  b) =>  Q a b -> b -> m b  Logically  a Boolean valued  into your monad's state and return  the result. 3When you do not need the result of the operation, (t) is more flexible.   () ::  a m =>   a  ->  -> m   () ::  a m =>  Q a  ->  -> m   Logically  a Boolean valued  into your monad's state and return  the result. 3When you do not need the result of the operation, (u) is more flexible.   () ::  a m =>   a  ->  -> m   () ::  a m =>  Q a  ->  -> m  &vwxyz{|}~&vwxyz{|}~&wxy|{~}zv$vwxyz{|}~ "rank 2 types, MPTCs, TFs, flexible provisionalEdward Kmett <ekmett@gmail.com>None type  i =  ( i)Useful for storage.  Provides an L that can be used to read, write or delete a member of a set-like container :m + Control.Lens/contains 3 .~ False $ IntSet.fromList [1,2,3,4]fromList [1,2,4] Provides an d that can be used to read, write or delete the value associated with a key in a map-like container. import Control.Lens!Map.fromList [(1,"hello")] ^.at 1 Just "hello" at 1 .~ Just "hello" $ Map.emptyfromList [(1,"hello")] type  i =  ( i)Every  is a valid  and a valid  M. Adjust the target of an ' returning the intermediate result, or ! adjust all of the targets of an  M and return a monoidal summary  along with the answer.  l  f = l   f/When you do not need access to the index then ()) is more liberal in what it can accept. 9If you do not need the intermediate result, you can use (v ) or even (c).   () :: + i a b c d -> (i -> c -> d) -> a -> (d, b)  () :: Monoid d =>  M+ i a b c d -> (i -> c -> d) -> a -> (d, b) Adjust the target of an & returning a supplementary result, or ! adjust all of the targets of an  M and return a monoidal summary . of the supplementary results and the answer.  () = \   () ::  f => / i a b c d -> (i -> c -> f d) -> a -> f b  () ::  f =>  M* i a b c d -> (i -> c -> f d) -> a -> f b ]In particular, it is often useful to think of this function as having one of these even more  restrictive type signatures   () :: 5 i a b c d -> (i -> c -> (e, d)) -> a -> (e, b)  () :: Monoid e =>  M0 i a b c d -> (i -> c -> (e, d)) -> a -> (e, b) Adjust the target of an & returning a supplementary result, or ! adjust all of the targets of an  M within the current state, and 9 return a monoidal summary of the supplementary results.  l  f =  (l  f)   () ::  a m 2 i a a c d -> (i -> c -> (e, d)) -> a -> m e  () :: ( a m, Monoid e) =>  M- i a a c d -> (i -> c -> (e, d)) -> a -> m e Adjust the target of an ' returning the intermediate result, or ! adjust all of the targets of an  M within the current state, and 8 return a monoidal summary of the intermediate results.   () ::  a m - i a a c d -> (i -> c -> d) -> a -> m d  () :: ( a m, Monoid e) =>  M( i a a c d -> (i -> c -> d) -> a -> m d  "rank 2 types, MPTCs, TFs, flexible provisionalEdward Kmett <ekmett@gmail.com>NoneUseful for storage. Every  is a valid O. Fold an  or  M/ by mapping indices and values to an arbitrary  with access  to the index i.  When you don' t need access to the index then w& is more flexible in what it accepts.  w l "a  l      :: j+ i a c -> (i -> c -> m) -> a -> m   ::  m => - i a c -> (i -> c -> m) -> a -> m   ::  x' i a c -> (i -> c -> m) -> a -> m   ::  m =>  y" i a c -> (i -> c -> m) -> a -> m JRight-associative fold of parts of a structure that are viewed through an  or  M with  access to the index i.  When you don' t need access to the index then z& is more flexible in what it accepts.  z l "a  l      :: j5 i a c -> (i -> c -> e -> e) -> e -> a -> e   :: 7 i a c -> (i -> c -> e -> e) -> e -> a -> e   ::  x1 i a c -> (i -> c -> e -> e) -> e -> a -> e   ::  y, i a c -> (i -> c -> e -> e) -> e -> a -> e MLeft-associative fold of the parts of a structure that are viewed through an  or  M with  access to the index i.  When you don' t need access to the index then {& is more flexible in what it accepts.  { l "a  l      :: j5 i a c -> (i -> e -> c -> e) -> e -> a -> e   :: 7 i a c -> (i -> e -> c -> e) -> e -> a -> e   ::  x1 i a c -> (i -> e -> c -> e) -> e -> a -> e   ::  y, i a c -> (i -> e -> c -> e) -> e -> a -> e 4Return whether or not any element viewed through an  or  M / satisfy a predicate, with access to the index i.  When you don' t need access to the index then |& is more flexible in what it accepts.  | l "a  l      :: j i a c -> (i -> c ->  ) -> a ->    ::  i a c -> (i -> c ->  ) -> a ->    ::  x i a c -> (i -> c ->  ) -> a ->    ::  y i a c -> (i -> c ->  ) -> a ->  5Return whether or not all elements viewed through an  or  M / satisfy a predicate, with access to the index i.  When you don' t need access to the index then }& is more flexible in what it accepts.  } l "a  l      :: j i a c -> (i -> c ->  ) -> a ->    ::  i a c -> (i -> c ->  ) -> a ->    ::  x i a c -> (i -> c ->  ) -> a ->    ::  y i a c -> (i -> c ->  ) -> a ->  Traverse the targets of an  or  M with access to the index i, discarding the results.  When you don' t need access to the index then 8& is more flexible in what it accepts.  8 l "a  itraverseOf l      ::  f => j0 i a c -> (i -> c -> f e) -> a -> f ()   ::  f => 2 i a c -> (i -> c -> f e) -> a -> f ()   ::  f =>  x, i a c -> (i -> c -> f e) -> a -> f ()   ::  f =>  y' i a c -> (i -> c -> f e) -> a -> f () Traverse the targets of an  or  M2 with access to the index, discarding the results  (with the arguments flipped).   "a    When you don' t need access to the index then ~& is more flexible in what it accepts.  ~ l a "a  l a      ::  f => j0 i a c -> a -> (i -> c -> f e) -> f ()   ::  f => 2 i a c -> a -> (i -> c -> f e) -> f ()   ::  f =>  x, i a c -> a -> (i -> c -> f e) -> f ()   ::  f =>  y' i a c -> a -> (i -> c -> f e) -> f () *Run monadic actions for each target of an  or  M with access to the index,  discarding the results.  When you don' t need access to the index then & is more flexible in what it accepts.   l "a imapMOf l      ::  m => j0 i a c -> (i -> c -> m e) -> a -> m ()   ::  m => 2 i a c -> (i -> c -> m e) -> a -> m ()   ::  m =>  x, i a c -> (i -> c -> m e) -> a -> m ()   ::  m =>  y' i a c -> (i -> c -> m e) -> a -> m () *Run monadic actions for each target of an  or  M with access to the index, 6 discarding the results (with the arguments flipped).   "a    When you don' t need access to the index then & is more flexible in what it accepts.   l a "a iforMOf l a      ::  m => j0 i a c -> a -> (i -> c -> m e) -> m ()   ::  m => 2 i a c -> a -> (i -> c -> m e) -> m ()   ::  m =>  x, i a c -> a -> (i -> c -> m e) -> m ()   ::  m =>  y' i a c -> a -> (i -> c -> m e) -> m () <Concatenate the results of a function of the elements of an  or  M  with access to the index.  When you don' t need access to the index then ' is more flexible in what it accepts.     l "a  l     "a      :: j i a c -> (i -> c -> [e] ) -> a -> [e]   :: " i a c -> (i -> c -> [e] ) -> a -> [e]   ::  x i a c -> (i -> c -> [e] ) -> a -> [e]   ::  y i a c -> (i -> c -> [e] ) -> a -> [e] The findOf function takes an  or  M, a predicate that is also T supplied the index, a structure and returns the left-most element of the structure  matching the predicate, or  if there is no such element.  When you don' t need access to the index then & is more flexible in what it accepts.   l "a  l      :: j a c -> (i -> c ->  ) -> a ->  (i, c)   ::  a c -> (i -> c ->  ) -> a ->  (i, c)   ::  x a c -> (i -> c ->  ) -> a ->  (i, c)   ::  y a c -> (i -> c ->  ) -> a ->  (i, c) Strictly< fold right over the elements of a structure with an index.  When you don' t need access to the index then & is more flexible in what it accepts.   l "a  l      :: j5 i a c -> (i -> c -> e -> e) -> e -> a -> e   :: 7 i a c -> (i -> c -> e -> e) -> e -> a -> e   ::  x1 i a c -> (i -> c -> e -> e) -> e -> a -> e   ::  y, i a c -> (i -> c -> e -> e) -> e -> a -> e RFold over the elements of a structure with an index, associating to the left, but strictly.  When you don' t need access to the index then & is more flexible in what it accepts.   l "a  l      :: j7 i a c -> (i -> e -> c -> e) -> e -> a -> e   :: 9 i a c -> (i -> e -> c -> e) -> e -> a -> e   ::  x3 i a c -> (i -> e -> c -> e) -> e -> a -> e   ::  y. i a c -> (i -> e -> c -> e) -> e -> a -> e CMonadic fold right over the elements of a structure with an index.  When you don' t need access to the index then & is more flexible in what it accepts.   l "a  l      ::  m => j7 i a c -> (i -> c -> e -> m e) -> e -> a -> e   ::  m => 9 i a c -> (i -> c -> e -> m e) -> e -> a -> e   ::  m =>  x3 i a c -> (i -> c -> e -> m e) -> e -> a -> e   ::  m =>  y. i a c -> (i -> c -> e -> m e) -> e -> a -> e VMonadic fold over the elements of a structure with an index, associating to the left.  When you don' t need access to the index then & is more flexible in what it accepts.   l "a  l      ::  m => j9 i a c -> (i -> e -> c -> m e) -> e -> a -> e   ::  m => ; i a c -> (i -> e -> c -> m e) -> e -> a -> e   ::  m =>  x5 i a c -> (i -> e -> c -> m e) -> e -> a -> e   ::  m =>  y0 i a c -> (i -> e -> c -> m e) -> e -> a -> e .Extract the key-value pairs from a structure.  When you don'1t need access to the indices in the result, then & is more flexible in what it accepts.   l "a     l    :: j i a c -> a -> [(i,c)]   ::  i a c -> a -> [(i,c)]   ::  x i a c -> a -> [(i,c)]   ::  y i a c -> a -> [(i,c)] JTransform an indexed fold into a fold of both the indices and the values.     withIndices ::  i a c -> Fold a (i, c)   withIndices ::   IndexedLens i a c -> Getter a (i, c)   withIndices ::  IndexedTraversal i a c -> Fold a (i, c) All Fold9 operations are safe, and comply with the laws. However, Passing this an IndexedTraversal will still allow many   Traversal9 combinators to type check on the result, but the result K can only be legally traversed by operations that do not edit the indices.     withIndices :: IndexedTraversal i a b c d ->  Traversal a b (i, c) (j, d) .Change made to the indices will be discarded. 6Transform an indexed fold into a fold of the indices.   indices ::  i a c -> Fold a i  indices ::   IndexedLens i a c -> Getter a i  indices ::  IndexedTraversal i a c -> Fold a i  Obtain an  by filtering a  N, j,  or  M.  Obtain an ! by taking elements from another ,  N, j or  M while a predicate holds.  Obtain an # by dropping elements from another ,  N, j or  M while a predicate holds.  "rank 2 types, MPTCs, TFs, flexible provisionalEdward Kmett <ekmett@gmail.com>None type  i =  ( i)Useful for storage. Allows $ of the value at the largest index. & of the element at the largest index. Allows " the value at the smallest index. ) of the element with the smallest index. type  i =  ( i)#Every indexed traversal is a valid 3 or  P. The ^ constraint is used to allow an  to be used directly as a 3. The 3" laws are still required to hold. Traversal with an index. NB: When you don'8t need access to the index then you can just apply your   directly as a function!     "a \   l =  l   =      :: / i a b c d -> (i -> c -> f d) -> a -> f b   :: * i a b c d -> (i -> c -> f d) -> a -> f b 3Traverse with an index (and the arguments flipped)     l a "a  l a     "a  .      :: / i a b c d -> a -> (i -> c -> f d) -> f b   :: * i a b c d -> a -> (i -> c -> f d) -> f b HMap each element of a structure targeted by a lens to a monadic action, Q evaluate these actions from left to right, and collect the results, with access  its position.  When you don't need access to the index mapMOf( is more liberal in what it can accept.   l "a  l      ::  m => / i a b c d -> (i -> c -> m d) -> a -> m b   ::  m => * i a b c d -> (i -> c -> m d) -> a -> m b HMap each element of a structure targeted by a lens to a monadic action, Q evaluate these actions from left to right, and collect the results, with access + its position (and the arguments flipped).     l a "a  l a     "a        ::  m => / i a b c d -> a -> (i -> c -> m d) -> m b   ::  m => * i a b c d -> a -> (i -> c -> m d) -> m b  Generalizes  to an arbitrary  with access to the index. ' accumulates state from right to left.   l "a  l      :: ? i a b c d -> (i -> s -> c -> (s, d)) -> s -> a -> (s, b)   :: : i a b c d -> (i -> s -> c -> (s, d)) -> s -> a -> (s, b)  Generalizes  to an arbitrary  with access to the index. ' accumulates state from left to right.   l "a  l      :: ? i a b c d -> (i -> s -> c -> (s, d)) -> s -> a -> (s, b)   :: : i a b c d -> (i -> s -> c -> (s, d)) -> s -> a -> (s, b) Access the element of an & where the index matches a predicate. :m + Control.LensOover (iwhereOf (indexed traverse) (>0)) reverse $ ["He","was","stressed","o_O"]["He","saw","desserts","O_o"]    ::  IndexedFold i a b -> (i -> ) ->  IndexedFold i a b   ::  IndexedGetter i a b -> (i -> ) ->  IndexedFold i a b   ::  i a b -> (i -> ) ->  i a b   ::  i a b -> (i -> ) ->  i a b   :: SimpleIndexedSetter i a b -> (i -> ) -> SimpleIndexedSetter i a b +Traverse the value at a given key in a map  k =  k ` This provides a  Traversal) that checks a predicate on a key before ( allowing you to traverse into a value.       "rank 2 types, MPTCs, TFs, flexible provisionalEdward Kmett <ekmett@gmail.com>None type  i =  ( i)Useful for storage. type  i =  ( i)Every  is a valid Setter The 1" laws are still required to hold. Map with index. /When you do not need access to the index, then mapOf( is more liberal in what it can accept.   l "a  l      :: ) i a b c d -> (i -> c -> d) -> a -> b   ::  N+ i a b c d -> (i -> c -> d) -> a -> b   ::  M& i a b c d -> (i -> c -> d) -> a -> b %Map with index. This is an alias for . /When you do not need access to the index, then over( is more liberal in what it can accept.   l "a  l      :: ) i a b c d -> (i -> c -> d) -> a -> b   ::  N+ i a b c d -> (i -> c -> d) -> a -> b   ::  M& i a b c d -> (i -> c -> d) -> a -> b  Build an  from an imap-like function. Your supplied function f is required to satisfy:    f  "a   f g  f h "a f (g  h) Equational reasoning:       "a      "a  Another way to view sets is that it takes a "semantic editor combinator"  and transforms it into a Setter. Adjust every target of an ,  N or  M  with access to the index.  () "a /When you do not need access to the index then ()) is more liberal in what it can accept.  l c f "a l   f   () :: ) i a b c d -> (i -> c -> d) -> a -> b  () ::  N+ i a b c d -> (i -> c -> d) -> a -> b  () ::  M& i a b c d -> (i -> c -> d) -> a -> b /Adjust every target in the current state of an ,  N or  M  with access to the index. /When you do not need access to the index then (m)) is more liberal in what it can accept.  l m f "a l   f   () ::  a m => ' i a a c d -> (i -> c -> d) -> m ()  () ::  a m =>  N) i a a c d -> (i -> c -> d) -> m ()  () ::  a m =>  M$ i a b c d -> (i -> c -> d) -> m ()    Rank2Types provisionalEdward Kmett <ekmett@gmail.com>None,Provides access to the 9th field of a tuple  Access the 9th field of a tuple +Provide access to the 8th field of a tuple  Access the 8th field of a tuple +Provide access to the 7th field of a tuple  Access the 7th field of a tuple .Provides access to the 6th element of a tuple  Access the 6th field of a tuple ,Provides access to the 5th field of a tuple  Access the 5th field of a tuple +Provide access to the 4th field of a tuple  Access the 4th field of a tuple ,Provides access to the 3rd field of a tuple  Access the 3rd field of a tuple ,Provides access to the 2nd field of a tuple  Access the 2nd field of a tuple import Control.Lens_2 .~ "hello" $ (1,(),3,4)(1,"hello",3,4)   |  :: (c -> ) -> (a, c) ->      :: ( Applicative f, . t) => (a -> f b) -> t (c, a) -> f (t (c, b))  w (  ) :: ( t, ! m) => (c -> m) -> t (b, c) -> m )Provides access to 1st field of a tuple. @Access the 1st field of a tuple (and possibly change its type). import Control.Lens (1,2)^._11_1 .~ "hello" $ (1,2) ("hello",2)/This can also be used on larger tuples as well _1 +~ 41 $ (1,2,3,4,5) (42,2,3,4,5)   _1 ::  (a,b) (a',b) a a'  _1 ::  (a,b,c) (a' ,b,c) a a'  _1 ::  (a,b,c,d) (a' ,b,c,d) a a'  ...  _1 ::  (a,c,d,e,f,g,h,i) (a',b,c,d,e,f,g,h,i) a a' >   !"#$%&'()*+,-./012345675   !"#$%&'()*+,-./01234567 Rank2Types provisionalEdward Kmett <ekmett@gmail.com>None% type  =  :Reify a setter so it can be stored safely in a container. 0This is a useful alias for use when consuming a . 1Most user code will never have to use this type. type  m =  A Simple Setter is just a  that doesn't change the types. IThese are particularly common when talking about monomorphic containers. e.g.   Data.Text.map ::   8 type  =   Running a % instantiates it to a concrete type. WWhen consuming a setter directly to perform a mapping, you can use this type, but most + user code will not need to use this type.  By choosing   rather than , we get nicer error messages.  The only <-like law that can apply to a  l is that   l c ( l b a) "a  l c aYou can't view a 3 in general, so the other two laws are irrelevant.  However, two  laws apply to a :     l  "a    l f   l g "a  l (f  g) "These an be stated more directly:    l  "a   l f .   . l g "a l (f .   . g) You can compose a  with a < or a 3 using () from the Prelude ! and the result is always only a  and nothing more. ;This setter can be used to map over all of the values in a .     "a     "a    (9) "a   import Control.Lensover mapped (+1) [1,2,3][2,3,4]set mapped () [1,2,3] [(),(),()]#mapped.mapped %~ (+1) $ [[1,2],[3]] [[2,3],[4]]=over (mapped._2) length [("hello","world"),("leaders","!!!")][("hello",5),("leaders",3)])Build a Setter from a map-like function. Your supplied function f is required to satisfy:    f  "a   f g  f h "a f (g  h) Equational reasoning:       "a      "a  Another way to view  is that it takes a "semantic editor combinator"  and transforms it into a . Modify the target of a < or all the targets of a  or 3  with a function.     "a     "a       "a      "a  import Control.Lensover mapped (*10) [1,2,3] [10,20,30]over _1 show (10,20) ("10",20)Another way to view " is to say that it transformers a  into a  "semantic editor combinator".  ::  a b c d -> (c -> d) -> a -> bModify the target of a < or all the targets of a  or 3 ' with a function. This is an alias for # that is provided for consistency.     "a    "a     fmapDefault "a  traverse     "a      "a  import Control.LensmapOf mapped (+1) [1,2,3,4] [2,3,4,5]mapOf _1 (+1) (1,2)(2,2)mapOf both (+1) (1,2)(2,3)    :: $ a b c d -> (c -> d) -> a -> b   :: Q' a b c d -> (c -> d) -> a -> b   :: <& a b c d -> (c -> d) -> a -> b   :: 3! a b c d -> (c -> d) -> a -> b Replace the target of a < or all of the targets of a   or 3 with a constant value.  (9) "a  import Control.Lensset _2 "hello" (1,()) (1,"hello")set mapped () [1,2,3,4] [(),(),(),()]Note: Attempting to  a Fold or Getter# will fail at compile time with an  relatively nice error message.    ::  a b c d -> d -> a -> b   :: Q a b c d -> d -> a -> b   :: < a b c d -> d -> a -> b   :: 3 a b c d -> d -> a -> b Modifies the target of a < or all of the targets of a  or  3 with a user supplied function. This is an infix version of      f "a   f   f "a traverse  f import Control.Lens_2 %~ length $ (1,"hello")(1,5)traverse %~ (+1) $ [1,2,3][2,3,4]_2 %~ (+1) $ (3,4)(3,5)9traverse.traverse %~ length $ [["hello","world"],["!!!"]] [[5,5],[3]]   () :: " a b c d -> (c -> d) -> a -> b  () :: Q% a b c d -> (c -> d) -> a -> b  () :: <$ a b c d -> (c -> d) -> a -> b  () :: 3 a b c d -> (c -> d) -> a -> b Replace the target of a < or all of the targets of a   or 3 with a constant value. This is an infix version of !, provided for consistency with ( )  f 9 a "a   f  aimport Control.Lens_1 .~ "hello" $ (42,"world")("hello","world")   () ::  a b c d -> d -> a -> b  () :: Q a b c d -> d -> a -> b  () :: < a b c d -> d -> a -> b  () :: 3 a b c d -> d -> a -> b Set with pass-through WThis is mostly present for consistency, but may be useful for for chaining assignments AIf you do not need a copy of the intermediate result, then using l  d directly is a good idea. import Control.Lens-_3 <.~ "world" $ ("good","morning","vietnam")$("world",("good","morning","world"))import Data.Map as MapK_2.at "hello" <.~ Just "world" $ (42,Map.fromList [("goodnight","gracie")])G(Just "world",(42,fromList [("goodnight","gracie"),("hello","world")]))   () ::  a b c d -> d -> a -> (d, b)  () :: Q# a b c d -> d -> a -> (d, b)  () :: <" a b c d -> d -> a -> (d, b)  () :: 3 a b c d -> d -> a -> (d, b) 0Increment the target(s) of a numerically valued <,  or 3 import Control.Lens_1 +~ 1 $ (1,2)(2,2)both +~ 2 $ (5,6)(7,8)   () :: Num b =>   a b -> b -> a -> a  () :: Num b =>  Q a b -> b -> a -> a  () :: Num b =>  < a b -> b -> a -> a  () :: Num b =>  3 a b -> b -> a -> a /Multiply the target(s) of a numerically valued <, Q,  or 3 import Control.Lens_2 *~ 4 $ (1,2)(1,8)mapped *~ 2 $ Just 24Just 48   () ::  b =>   a b -> b -> a -> a  () ::  b =>  Q a b -> b -> a -> a  () ::  b =>  < a b -> b -> a -> a  () ::  b =>  3 a b -> b -> a -> a 0Decrement the target(s) of a numerically valued <, Q,  or 3 import Control.Lens_1 -~ 2 $ (1,2)(-1,2)"mapped.mapped -~ 1 $ [[4,5],[6,7]] [[3,4],[5,6]]   () ::  b =>   a b -> b -> a -> a  () ::  b =>  Q a b -> b -> a -> a  () ::  b =>  < a b -> b -> a -> a  () ::  b =>  3 a b -> b -> a -> a -Divide the target(s) of a numerically valued <, Q,  or 3 import Control.Lens_2 //~ 2 $ ("Hawaii",10)("Hawaii",5.0)   () ::  b =>   a b -> b -> a -> a  () ::  b =>  Q a b -> b -> a -> a  () ::  b =>  < a b -> b -> a -> a  () ::  b =>  3 a b -> b -> a -> a ,Raise the target(s) of a numerically valued <,  or 3" to a non-negative integral power import Control.Lens_2 ^~ 2 $ (1,3)(1,9)   () :: ( b,  c) =>   a b -> c -> a -> a  () :: ( b,  c) =>  Q a b -> c -> a -> a  () :: ( b,  c) =>  < a b -> c -> a -> a  () :: ( b,  c) =>  3 a b -> c -> a -> a -Raise the target(s) of a fractionally valued <,  or 3 to an integral power import Control.Lens_2 ^^~ (-1) $ (1,2)(1,0.5)   () :: ( b,  c) =>   a b -> c -> a -> a  () :: ( b,  c) =>  Q a b -> c -> a -> a  () :: ( b,  c) =>  < a b -> c -> a -> a  () :: ( b,  c) =>  3 a b -> c -> a -> a  /Raise the target(s) of a floating-point valued <,  or 3 to an arbitrary power. import Control.Lens_2 **~ pi $ (1,3)(1,31.54428070019754)   ( ) ::  b =>   a b -> b -> a -> a  ( ) ::  b =>  Q a b -> b -> a -> a  ( ) ::  b =>  < a b -> b -> a -> a  ( ) ::  b =>  3 a b -> b -> a -> a   Logically  the target(s) of a -valued < or  import Control.Lensboth ||~ True $ (False,True) (True,True)both ||~ False $ (False,True) (False,True)   ( ) ::   a  ->  -> a -> a  ( ) ::  Q a  ->  -> a -> a  ( ) ::  < a  ->  -> a -> a  ( ) ::  3 a  ->  -> a -> a   Logically  the target(s) of a -valued < or  import Control.Lensboth &&~ True $ (False, True) (False,True)both &&~ False $ (False, True) (False,False)   ( ) ::   a  ->  -> a -> a  ( ) ::  Q a  ->  -> a -> a  ( ) ::  < a  ->  -> a -> a  ( ) ::  3 a  ->  -> a -> a  Replace the target of a < or all of the targets of a  or 3 in our monadic 2 state with a new value, irrespective of the old. This is an alias for ( ).     ::  a m =>  Q a b -> b -> m ()    ::  a m =>  < a b -> b -> m ()    ::  a m =>  3 a b -> b -> m ()    ::  a m =>   a b -> b -> m ()  Replace the target of a < or all of the targets of a  or 3 in our monadic 2 state with a new value, irrespective of the old. This is an infix version of  .    ( ) ::  a m =>  Q a b -> b -> m ()  ( ) ::  a m =>  < a b -> b -> m ()  ( ) ::  a m =>  3 a b -> b -> m ()  ( ) ::  a m =>   a b -> b -> m () 9It puts the state in the monad or it gets the hose again. Map over the target of a < or all of the targets of a  or 3 in our monadic state.   () ::  a m =>  Q a b -> (b -> b) -> m ()  () ::  a m =>  < a b -> (b -> b) -> m ()  () ::  a m =>  3 a b -> (b -> b) -> m ()  () ::  a m =>   a b -> (b -> b) -> m () Modify the target(s) of a  <, Q,  or 3 by adding a value  Example:   $ fresh :: MonadState Int m => m Int  fresh = do    1  use     () :: ( a m,  b) =>   a b -> b -> m ()  () :: ( a m,  b) =>  Q a b -> b -> m ()  () :: ( a m,  b) =>  < a b -> b -> m ()  () :: ( a m,  b) =>  3 a b -> b -> m () Modify the target(s) of a  <, Q,  or 3 by subtracting a value   () :: ( a m,  b) =>   a b -> b -> m ()  () :: ( a m,  b) =>  Q a b -> b -> m ()  () :: ( a m,  b) =>  < a b -> b -> m ()  () :: ( a m,  b) =>  3 a b -> b -> m () Modify the target(s) of a  <, Q,  or 3 by multiplying by value.   () :: ( a m,  b) =>   a b -> b -> m ()  () :: ( a m,  b) =>  Q a b -> b -> m ()  () :: ( a m,  b) =>  < a b -> b -> m ()  () :: ( a m,  b) =>  3 a b -> b -> m () Modify the target(s) of a  <, Q,  or 3 by dividing by a value.   () :: ( a m,  b) =>   a b -> b -> m ()  () :: ( a m,  b) =>  Q a b -> b -> m ()  () :: ( a m,  b) =>  < a b -> b -> m ()  () :: ( a m,  b) =>  3 a b -> b -> m () ,Raise the target(s) of a numerically valued <,  or 3# to a non-negative integral power.   () :: ( a m,  b,  c) =>   a b -> c -> m ()  () :: ( a m,  b,  c) =>  Q a b -> c -> m ()  () :: ( a m,  b,  c) =>  < a b -> c -> m ()  () :: ( a m,  b,  c) =>  3 a b -> c -> m () ,Raise the target(s) of a numerically valued <,  or 3 to an integral power.   () :: ( a m,  b,  c) =>   a b -> c -> m ()  () :: ( a m,  b,  c) =>  Q a b -> c -> m ()  () :: ( a m,  b,  c) =>  < a b -> c -> m ()  () :: ( a m,  b,  c) =>  3 a b -> c -> m () ,Raise the target(s) of a numerically valued <,  or 3 to an arbitrary power   () :: ( a m,  b) =>   a b -> b -> m ()  () :: ( a m,  b) =>  Q a b -> b -> m ()  () :: ( a m,  b) =>  < a b -> b -> m ()  () :: ( a m,  b) =>  3 a b -> b -> m () Modify the target(s) of a  <, Q,  or 3 by taking their logical  with a value   () ::  a m =>   a  ->  -> m ()  () ::  a m =>  Q a  ->  -> m ()  () ::  a m =>  < a  ->  -> m ()  () ::  a m =>  3 a  ->  -> m () Modify the target(s) of a  <, 'Iso,  or 3 by taking their logical  with a value   () ::  a m =>   a  ->  -> m ()  () ::  a m =>  Q a  ->  -> m ()  () ::  a m =>  < a  ->  -> m ()  () ::  a m =>  3 a  ->  -> m () 6Run a monadic action, and set all of the targets of a <,  or 3 to its result.    () ::  a m => Q a a c d -> m d -> m ()  () ::  a m => < a a c d -> m d -> m ()  () ::  a m => 3 a a c d -> m d -> m ()  () ::  a m =>  a a c d -> m d -> m () cAs a reasonable mnemonic, this lets you store the result of a monadic action in a lens rather than  in a local variable.    do foo <- bar  ... +will store the result in a variable, while    do foo  bar  ... will store the result in a <, , or 3. Set with pass-through XThis is useful for chaining assignment without round-tripping through your monad stack.  do x <- _2 <*.= ninety_nine_bottles_of_beer_on_the_wallAIf you do not need a copy of the intermediate result, then using l .= d$ will avoid unused binding warnings   () ::  a m =>  a a c d -> d -> m d  () ::  a m => Q a a c d -> d -> m d  () ::  a m => < a a c d -> d -> m d  () ::  a m => 3 a a c d -> d -> m d '     '     '     %      Rank2Types provisionalEdward Kmett <ekmett@gmail.com>None *Useful for storing getters in containers. Most - combinators are able to be used with both a  or a  O2 in limited situations, to do so, they need to be 2 monomorphic in what we are going to extract with Const. To be compatible  with <, 3 and  Q. we also restricted choices of the irrelevant b and  d parameters. If a function accepts a  r a b c d , then when r is a Monoid, then  you can pass a O (or  3&), otherwise you can only pass this a   or <. A ? describes how to retrieve a single value in a way that can be . composed with other lens-like constructions.  Unlike a < a  is read-only. Since a  L cannot be used to write back there are no lens laws that can be applied to = it. In fact, it is isomorphic to an arbitrary function from (a -> c).  Moreover, a  can be used directly as a O,  since it just ignores the  Applicative. Build a % from an arbitrary Haskell function.   f .  g =  (g . f) a #  f = f aimport Control.Lens("hello","world")^.to snd"world" 5^.to succ6(0, -5)^._2.to abs5 View the value pointed to by a , Q or  <4 or the result of folding over all the results of a  O or 3 that points  at a monoidal values.    .  = import Control.Lensview _2 (1,"hello")"hello"view (to succ) 56&view (_2._1) ("hello",("world","!!!"))"world"It may be useful to think of  ) as having one of these more restrictive  signatures:     ::  a c -> a -> c    :: Monoid m => O a m -> a -> m    ::  Q a c -> a -> c    ::  < a c -> a -> c    :: Monoid m =>  3 a m -> a -> m !View the value of a , Q,  <5 or the result of folding over the result of mapping  the targets of a O or  3. It may be useful to think of !" as having these more restrictive  signatures:  ! l f =   (l   f)import Control.Lensviews _2 length (1,"hello")5   ! :: ' a c -> (c -> d) -> a -> d  ! :: Monoid m => O) a c -> (c -> m) -> a -> m  ! ::  Q# a c -> (c -> d) -> a -> d  ! ::  <" a c -> (c -> d) -> a -> d  ! :: Monoid m =>  3 a c -> (c -> m) -> a -> m "View the value pointed to by a , Q or  <4 or the result of folding over all the results of a  O or 3 that points  at a monoidal values. This is the same operation as  , only infix.   f " x = f ximport Control.Lens_2 ^$ (1, "hello")"hello"   (") ::  a c -> a -> c  (") :: Monoid m => O a m -> a -> m  (") ::  Q a c -> a -> c  (") ::  < a c -> a -> c  (") :: Monoid m =>  3 a m -> a -> m #View the value pointed to by a  or < or the - result of folding over all the results of a O or  3# that points at a monoidal values. This is the same operation as   with the arguments flipped. HThe fixity and semantics are such that subsequent field accesses can be  performed with () import Control.Lens("hello","world")^._2"world"import Data.Complex$((0, 1 :+ 2), 3)^._1._2.to magnitude2.23606797749979   (#) :: a ->  a c -> c  (#) :: Monoid m => a -> O a m -> m  (#) :: a ->  Q a c -> c  (#) :: a ->  < a c -> c  (#) :: Monoid m => a ->  3 a m -> m $Use the target of a <, Q, or  - in the current state, or use a summary of a  O or 3 that points  to a monoidal value.   $ ::  a m =>  a c -> m c  $ :: ( a m, Monoid r) => O a r -> m r  $ ::  a m =>  Q a c -> m c  $ ::  a m =>  < a c -> m c  $ :: ( a m, Monoid r) =>  3 a r -> m r %Use the target of a <, Q or  - in the current state, or use a summary of a  O or 3 that  points to a monoidal value.   % ::  a m => " a c -> (c -> e) -> m e  % :: ( a m, Monoid r) => O$ a c -> (c -> r) -> m r  % ::  a m =>  < a c -> (c -> e) -> m e  % ::  a m =>  Q a c -> (c -> e) -> m e  % :: ( a m, Monoid r) =>  3 a c -> (c -> r) -> m r &Query the target of a <, Q or  - in the current state, or use a summary of a  O or 3 that points  to a monoidal value.   & :: : a m =>  a c -> m c  & :: (: a m, Monoid c) => O a c -> m c  & :: : a m =>  Q a c -> m c  & :: : a m =>  < a c -> m c  & :: (: a m, Monoid c) =>  3 a c -> m c 'Use the target of a <, Q or  - in the current state, or use a summary of a  O or 3 that points  to a monoidal value.   ' :: : a m => " a c -> (c -> e) -> m e  ' :: (: a m, Monoid c) => O$ a c -> (c -> e) -> m e  ' :: : a m =>  Q a c -> (c -> e) -> m e  ' :: : a m =>  < a c -> (c -> e) -> m e  ' :: (: a m, Monoid c) =>  3 a c -> (c -> e) -> m e  !"#$%&' !"#$%&'#" !$%&'  !"#$%&' Rank2Types provisionalEdward Kmett <ekmett@gmail.com>None ( type SimpleReifiedIso =  ))/Useful for storing isomorphisms in containers. , type SimpleIso =  --DIsomorphim 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 (2) from the Prelude, they will be dumbed down to a  mere .   import Control.Category  import Prelude hiding ((.),id)  type Iso a b c d = forall k f. ( k,  f) => { k f a b c d.@Build an isomorphism family from two pairs of inverse functions      (. ac ca bd db) "a ac    ( (. ac ca bd db)) "a ca   (. ac ca bd db) cd "a db  cd  ac   ( (. ac ca bd db' )) ab "a bd  ab  ca  8isos :: (a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> - a b c d/<Build a simple isomorphism from a pair of inverse functions      (/ f g) "a f    ( (/ f g)) "a g   (. f g) h "a g  h  f   ( (/ f g' )) h "a f  h  g  iso :: (a -> b) -> (b -> a) ->  - a b0 Based on ala from Conor McBride's work on Epigram. 0:m + Control.Lens Data.Monoid.Lens Data.Foldableala _sum foldMap [1,2,3,4]101 Based on ala' from Conor McBride's work on Epigram. Mnemonically, the German auf plays a similar role to  la, and the combinator  is au" with an extra function argument. 2The opposite of working  a Setter is working 2 an Isomorphism.  2 =    2' :: Iso a b c d -> (a -> b) -> (c -> d)3:This isomorphism can be used to wrap or unwrap a value in .   x^.identity "a  x   x #  3 "a x 4:This isomorphism can be used to wrap or unwrap a value in    x # 4 "a  x   x #  4 "a x  ()*+,-./01234()*+,-./01234-/.01243)*+,( ()*+,-./01234portable provisionalEdward Kmett <ekmett@gmail.com>None5This % can be used to change the type of a ; by mapping  the elements to new values. Sadly, you can't create a valid  Traversal for a ;, but you can  manipulate it by reading using folded and reindexing it via setmap. :m + Data.Set.Lens Control.Lens(over setmapped (+1) (fromList [1,2,3,4])fromList [2,3,4,5]6Construct a set from a , Fold,  Traversal, Lens or Iso. :m + Data.Set.Lens Control.Lens5setOf (folded._2) [("hello",1),("world",2),("!!!",3)]fromList [1,2,3]   setOf ::  a c -> a -> ; c  setOf :: < c => Fold a c -> a -> ; c  setOf :: Simple Iso a c -> a -> ; c  setOf :: Simple Lens a c -> a -> ; c  setOf :: < c => Simple  Traversal a c -> a -> ; c 56565656 RankNTypes provisionalEdward Kmett <ekmett@gmail.com>None7GSometimes you need to store a path lens into a container, but at least  at this time, ImpredicativePolymorphism in GHC is somewhat lacking. *This type provides a way to, say, store a [] of paths. :Representable Functors. A  f is : if it is isomorphic to (x -> a) E for some x. Nearly 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 = < f is a valid choice of x for (nearly) 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 :  functor.  = f m = ;  i -> f (m # i) Usage for a : Foo:   instance  Foo where   = = >># is a valid default definition for  and = for a  : functor.  > = ; .  Usage for a : Foo:    instance  Foo where   = >  ...    instance  Foo where  = = >  ... ??$ is a valid default definition for (>) for a :  functor.  ? mf ma = ;  i -> mf # i  ma # i Usage for a : Foo:   instance  Foo where   = >  (>) = ? @@+ is a valid default default definition for '(>>=)' for a  representable functor.  @ m f = ;  i -> f (m # i) # i Usage for a : Foo:   instance  Foo where  = = >  (?) = @ AA default definition for  for a :   A wf = ;  i ->  (# i) wf Usage for a : Foo:   instance  Foo where   = A BA : - has a fixed shape. This fills each position  in it with a 7 C A version of ;5 that is an isomorphism. Predicativity requires that  we wrap the < as a Key , however. D Map over a : functor with access to the  for the  current position D f m = ;  i -> f i (m # i)E Traverse a :) functor with access to the current path F Traverse a :) functor with access to the current path  as a , discarding the result G Traverse a :) functor with access to the current path  and a  (and the arguments flipped) H@ over a :) functor with access to the current path  as a  I@ over a :) functor with access to the current path  as a , discarding the result J@ over a :) functor with access to the current path  as a  (with the arguments flipped) K Fold over a :) functor with access to the current path  as a  , yielding a  L Fold over a :) functor with access to the current path  as a . MAn  that walks an :  using a 7 for an index. NAn  that walks an A :  using a 7 for an index. OAn  for a  : . BNB: The C@ requirement on this instance is a consequence of the choice of  as a <, it isn't fundamental. 789:;<=>?@ABCDEFGHIJKLMNOBD789:;<=>?@ABCDEFGHIJKLMNO:;<=>?@A789BCDKLEFGHIJMNO789:;<=>?@ABCDEFGHIJKLMNOBD Rank2Types provisionalEdward Kmett <ekmett@gmail.com>NonePThis class allows us to use Q? part of the environment, changing the environment supplied by + many different monad transformers. Unlike focusG this can change the environment of a deeply nested monad transformer.  Also, unlike focus", this can be used with any valid , but cannot be used with a  Traversal or Fold. QMRun a monadic action in a larger environment than it was defined in, using a . This acts like D, but can in many cases change the type of the environment as well. mThis is commonly used to lift actions in a simpler Reader monad into a monad with a larger environment type. \This can be used to edit pretty much any monad transformer stack with an environment in it:   Q ::  a b -> (b -> c) -> a -> c  Q ::  c => Fold a b -> (b -> c) -> a -> c  Q ::  w  a b -> E a w s c -> E b w s c  Q :: ( w,  c) => Fold a b -> E a w s c -> E b w s c  ... RThis class allows us to use S$ in, changing the State supplied by Y many different monad transformers, potentially quite deep in a monad transformer stack. S?Run a monadic action in a larger state than it was defined in,  using a   or  3. FThis 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 3 over H multiple values, the actions for each target are executed sequentially ! and the results are aggregated. UThis can be used to edit pretty much any monad transformer stack with a state in it!   S ::  m =>   a b -> F b m c -> F a m c  S :: ( m,  c) =>  3 a b -> F b m c -> F a m c  S ::  m =>   a b -> E r w b m c -> E r w a m c  S :: ( m,  c) =>  3 a b -> E r w b m c -> E r w a m c  S ::  m =>   a b -> G e (E r w b m c) -> G e (E r w a m c)  S :: ( m,  c) =>  3 a b -> G e (E r w b m c) -> G e (E r w a m c)  ... H Q = !PQRSIJKHLMNOPQRSTUVWPQRSPQRSPQRSIJKHLMNOPQRSTUVWportable provisionalEdward Kmett <ekmett@gmail.com>NoneTThis % can be used to change the type of a X by mapping  the elements to new values. Sadly, you can't create a valid  Traversal for a Set, but you can  manipulate it by reading using folded and reindexing it via setmap. :m + Data.HashSet Control.Lens(over setmapped (+1) (fromList [1,2,3,4])fromList [2,3,4,5]UConstruct a set from a , Fold,  Traversal, Lens or Iso. :m + Control.Lens5setOf (folded._2) [("hello",1),("world",2),("!!!",3)]fromList [1,2,3]   setOf :: Y c =>  a c -> a -> X c  setOf :: (C c, Y c) => Fold a c -> a -> X c  setOf :: Y c => Simple Iso a c -> a -> X c  setOf :: Y c => Simple Lens a c -> a -> X c  setOf :: (C c, Y c) => Simple  Traversal a c -> a -> X c TUTUTUTU Rank2Types provisionalEdward Kmett <ekmett@gmail.com>None5V(Useful for storing folds in containers. YA YI describes how to retrieve multiple values in a way that can be composed % with other lens-like constructions. A Y a cC provides a structure with operations very similar to those of the A  typeclass, see e and the other Y combinators. !By convention, if there exists a foo method that expects a A (f c), then there should be a  fooOf method that takes a Y a c and a value of type a. A  is a legal Y that just ignores the supplied   Unlike a 3 a Y is read-only. Since a Y cannot be used to write back $ there are no lens laws that apply. Z Obtain a Y9 by lifting an operation that returns a foldable result. +This can be useful to lift operations from  Data.List and elsewhere into a Y. [ Obtain a Y from any A. \%Fold by repeating the input forever. Z "a i \]!A fold that replicates its input n times. [ n "a i (] n)^ITransform a fold into a fold that loops over its elements over and over. import Control.Lens+take 6 $ toListOf (cycled traverse) [1,2,3] [1,2,3,1,2,3]_2Build a fold that unfolds its values from a seed.  "a i . _`x ^. ` f5 Return an infinite fold of repeated applications of f to x. i (` f) a "a \ f aa Obtain a Y by filtering a , Q, , Y or 3. b.This allows you to traverse the elements of a 3 or Y in the opposite order. Note: b should have no impact on a  Setter,  or Q. To change the direction of an Q, use from. c Obtain a Y! by taking elements from another Y, , Q,  or 3 while a predicate holds.  ] p "a i (c p [))toListOf (takingWhile (<=3) folded) [1..][1,2,3]d Obtain a Y# by dropping elements from another Y, , Q,  or 3 while a predicate holds.  ^ p "a i (d p [),toListOf (droppingWhile (<=3) folded) [1..6][4,5,6]e  = e [ e "a !   e :: % a c -> (c -> r) -> a -> r  e ::  r => Y' a c -> (c -> r) -> a -> r  e ::   a c -> (c -> r) -> a -> r  e ::  Q! a c -> (c -> r) -> a -> r  e ::  r =>  3 a c -> (c -> r) -> a -> r f  = f [ f "a    f ::  a m -> a -> m  f ::  m => Y a m -> a -> m  f ::   a m -> a -> m  f ::  Q a m -> a -> m  f ::  m =>  3 a m -> a -> m gIRight-associative fold of parts of a structure that are viewed through a , , Y or 3.   "a g [   g :: / a c -> (c -> e -> e) -> e -> a -> e  g :: Y1 a c -> (c -> e -> e) -> e -> a -> e  g ::  * a c -> (c -> e -> e) -> e -> a -> e  g ::  Q+ a c -> (c -> e -> e) -> e -> a -> e  g ::  3% a c -> (c -> e -> e) -> e -> a -> e hLLeft-associative fold of the parts of a structure that are viewed through a , , Y or 3.   "a h [   h :: / a c -> (e -> c -> e) -> e -> a -> e  h :: Y1 a c -> (e -> c -> e) -> e -> a -> e  h ::  * a c -> (e -> c -> e) -> e -> a -> e  h ::  Q+ a c -> (e -> c -> e) -> e -> a -> e  h ::  3% a c -> (e -> c -> e) -> e -> a -> e i#Extract a list of the targets of a Y . See also (j).    "a i [  (j) "a  i j(A convenient infix (flipped) version of i. import Control.Lens[[1,2],[3]]^..traverse.traverse[1,2,3] (1,2)^..both[1,2]    xs "a xs j [  (j) "a  i    (j ) :: a ->  a c -> [c]  (j ) :: a -> Y a c -> [c]  (j ) :: a ->   a c -> [c]  (j ) :: a ->  Q a c -> [c]  (j ) :: a ->  3 a c -> [c] kReturns _ if every target of a Y is _. import Control.LensandOf both (True,False)FalseandOf both (True,True)True  "a k [   k ::  a  -> a ->   k :: Y a  -> a ->   k ::   a  -> a ->   k ::  Q a  -> a ->   k ::  3 a  -> a ->  lReturns _ if any target of a Y is _. import Control.LensorOf both (True,False)TrueorOf both (False,False)False  "a l [   l ::  a  -> a ->   l :: Y a  -> a ->   l ::   a  -> a ->   l ::  Q a  -> a ->   l ::  3 a  -> a ->  mReturns _ if any target of a Y satisfies a predicate. import Control.LensanyOf both (=='x') ('x','y')Trueimport Data.Data.Lens=anyOf biplate (== "world") (((),2::Int),"hello",("world",11))True  "a m [   m ::  a c -> (c ->  ) -> a ->   m :: Y a c -> (c ->  ) -> a ->   m ::   a b c d -> (c ->  ) -> a ->   m ::  Q a b c d -> (c ->  ) -> a ->   m ::  3 a b c d -> (c ->  ) -> a ->  nReturns _ if every target of a Y satisfies a predicate. import Control.LensallOf both (>=3) (4,5)TrueallOf folded (>=2) [1..10]False  "a n [   n ::  a c -> (c ->  ) -> a ->   n :: Y a c -> (c ->  ) -> a ->   n ::   a c -> (c ->  ) -> a ->   n ::  Q a c -> (c ->  ) -> a ->   n ::  3 a c -> (c ->  ) -> a ->  o4Calculate the product of every number targeted by a Y import Control.LensproductOf both (4,5)20productOf folded [1,2,3,4,5]120  "a o [   o ::  a c -> a -> c  o ::  c => Y a c -> a -> c  o ::   a c -> a -> c  o ::  Q a c -> a -> c  o ::  c =>  3 a c -> a -> c p0Calculate the sum of every number targeted by a Y. import Control.LenssumOf both (5,6)11sumOf folded [1,2,3,4]10!sumOf (folded.both) [(1,2),(3,4)]10import Data.Data.Lens8sumOf biplate [(1::Int,[]),(2,[(3::Int,4::Int)])] :: Int10  "a p [   p _1 :: (a, b) -> a  p ([ . _1) :: (A f,  a) => f (a, b) -> a    p ::  a c -> a -> c  p ::  c => Y a c -> a -> c  p ::   a c -> a -> c  p ::  Q a c -> a -> c  p ::  c =>  3 a c -> a -> c q&Traverse over all of the targets of a Y (or ), computing an  (or ) -based answer,  but unlike # do not construct a new structure. q generalizes   to work over any Y. When passed a , q can work over any , but when passed a Y, q requires  an . import Control.Lens+traverseOf_ both putStrLn ("hello","world")helloworld  "a q [   q _2 :: $ f => (c -> f e) -> (c1, c) -> f ()  q  ::  f => (a -> f b) ->  a c -> f () !The rather specific signature of q6 allows it to be used as if the signature was any of:   q ::  f => * a c -> (c -> f e) -> a -> f ()  q ::  f => Y, a c -> (c -> f e) -> a -> f ()  q ::  f =>  % a c -> (c -> f e) -> a -> f ()  q ::  f =>  Q& a c -> (c -> f e) -> a -> f ()  q ::  f =>  3 a c -> (c -> f e) -> a -> f () r&Traverse over all of the targets of a Y (or ), computing an  (or ) -based answer,  but unlike # do not construct a new structure. r generalizes   to work over any Y. When passed a , r can work over any , but when passed a Y, r requires  an .  ` "a r [!The rather specific signature of r6 allows it to be used as if the signature was any of:   r ::  f => * a c -> a -> (c -> f e) -> f ()  r ::  f => Y, a c -> a -> (c -> f e) -> f ()  r ::  f =>  % a c -> a -> (c -> f e) -> f ()  r ::  f =>  Q& a c -> a -> (c -> f e) -> f ()  r ::  f =>  3 a c -> a -> (c -> f e) -> f () s&Evaluate each action in observed by a Y: on a structure from left to right, ignoring the results.  a "a s [   s ::  f => ! a (f ()) -> a -> f ()  s ::  f => Y# a (f ()) -> a -> f ()  s ::  f =>   a (f ()) -> a -> f ()  s ::  f =>  Iso a (f ()) -> a -> f ()  s ::  f =>  3 a (f ()) -> a -> f () tMap each target of a Yh on a structure to a monadic action, evaluate these actions from left to right, and ignore the results.  7 "a t [   t ::  m => * a c -> (c -> m e) -> a -> m ()  t ::  m => Y, a c -> (c -> m e) -> a -> m ()  t ::  m =>  % a c -> (c -> m e) -> a -> m ()  t ::  m =>  Q& a c -> (c -> m e) -> a -> m ()  t ::  m =>  3 a c -> (c -> m e) -> a -> m () uu is t$ with two of its arguments flipped.   "a u [   u ::  m => * a c -> a -> (c -> m e) -> m ()  u ::  m => Y, a c -> a -> (c -> m e) -> m ()  u ::  m =>  % a c -> a -> (c -> m e) -> m ()  u ::  m =>  Q& a c -> a -> (c -> m e) -> m ()  u ::  m =>  3 a c -> a -> (c -> m e) -> m () v-Evaluate each monadic action referenced by a Y> on the structure from left to right, and ignore the results.   "a v [   v ::  m =>  a (m b) -> a -> m ()  v ::  m => Y" a (m b) -> a -> m ()  v ::  m =>   a (m b) -> a -> m ()  v ::  m =>  Q a (m b) -> a -> m ()  v ::  m =>  3 a (m b) -> a -> m () w1The sum of a collection of actions, generalizing |.  b "a w [   w :: c f =>  a c -> a -> f c  w :: c f => Y a c -> a -> f c  w :: c f =>   a c -> a -> f c  w :: c f =>  Q a c -> a -> f c  w :: c f =>  3 a c -> a -> f c x1The sum of a collection of actions, generalizing |.  d "a x [   x :: e m =>  a c -> a -> m c  x :: e m => Y a c -> a -> m c  x :: e m =>   a c -> a -> m c  x :: e m =>  Q a c -> a -> m c  x :: e m =>  3 a c -> a -> m c y/Does the element occur anywhere within a given Y of the structure? import Control.Lens%elemOf both "hello" ("hello","world")True f "a y [   y :: C c =>  a c -> c -> a ->   y :: C c => Y a c -> c -> a ->   y :: C c =>   a c -> c -> a ->   y :: C c =>  Q a c -> c -> a ->   y :: C c =>  3 a c -> c -> a ->  z3Does the element not occur anywhere within a given Y of the structure?  g "a z [   z :: C c =>  a c -> c -> a ->   z :: C c => Y a c -> c -> a ->   z :: C c =>  Q a c -> c -> a ->   z :: C c =>   a c -> c -> a ->   z :: C c =>  3 a c -> c -> a ->  {)Map a function over all the targets of a Y5 of a container and concatenate the resulting lists.  h "a { [   { ::  a c -> (c -> [e] ) -> a -> [e]  { :: Y a c -> (c -> [e] ) -> a -> [e]  { ::   a c -> (c -> [e] ) -> a -> [e]  { ::  Q a c -> (c -> [e] ) -> a -> [e]  { ::  3 a c -> (c -> [e] ) -> a -> [e] |+Concatenate all of the lists targeted by a Y into a longer list. import Control.LensconcatOf both ("pan","ama")"panama"   i "a | [  | "a      | ::  a [e] -> a -> [e]  | :: Y a [e] -> a -> [e]  | ::  Q a [e] -> a -> [e]  | ::   a [e] -> a -> [e]  | ::  3 a [e] -> a -> [e] };Note: this can be rather inefficient for large containers.  j "a } [import Control.LenslengthOf _1 ("hello",())1 } ([ . [) :: A f => f (g a) ->    } ::  a c -> a ->   } :: Y a c -> a ->   } ::   a c -> a ->   } ::  Q a c -> a ->   } ::  3 a c -> a ->  ~Perform a safe k of a Y or 3 or retrieve l the result  from a  or  . See also ().  m  n "a ~ [   ~ ::  a c -> a ->  c  ~ :: Y a c -> a ->  c  ~ ::   a c -> a ->  c  ~ ::  Q a c -> a ->  c  ~ ::  3 a c -> a ->  c Perform a safe k of a Y or 3 or retrieve l the result  from a  or .  When using a 3 as a partial , or a Y as a partial  this can be a convenient $ way to extract the optional value.  () "a  ~   ( ) :: a ->  a c ->  c  ( ) :: a -> Y a c ->  c  ( ) :: a ->   a c ->  c  ( ) :: a ->  Q a c ->  c  ( ) :: a ->  3 a c ->  c Perform a safe o of a Y or 3 or retrieve l the result  from a  or .    ::  a c -> a ->  c   :: Y a c -> a ->  c   ::   a c -> a ->  c   ::  Q a c -> a ->  c   ::  3 a c -> a ->  c Returns _ if this Y or 3( has no targets in the given container. Note:  on a valid Q,  or  should always return p  q "a  [/This may be rather inefficient compared to the q check of many containers. import Control.LensnullOf _1 (1,2)False  ([  _1  [) :: A f => f (g a, b) ->     ::  a c -> a ->    :: Y a c -> a ->    ::  Q a c -> a ->    ::   a c -> a ->    ::  3 a c -> a ->  2Obtain the maximum element (if any) targeted by a Y or 3 Note: maximumOf on a valid Q,  or  will always return l a value.  r "a s (t empty)   [    ::  a c -> a ->  c   :: < c => Y a c -> a ->  c   ::  Q a c -> a ->  c   ::   a c -> a ->  c   :: < c =>  3 a c -> a ->  c 2Obtain the minimum element (if any) targeted by a Y or 3 Note: minimumOf on a valid Q,  or  will always return l a value.  u "a s (t empty)   [    ::  a c -> a ->  c   :: < c => Y a c -> a ->  c   ::  Q a c -> a ->  c   ::   a c -> a ->  c   :: < c =>  3 a c -> a ->  c 2Obtain the maximum element (if any) targeted by a Y, 3, , Q,  or ( according to a user supplied ordering.   cmp "a s (t empty)   [ cmp    ::  a c -> (c -> c -> v ) -> a ->  c   :: Y a c -> (c -> c -> v ) -> a ->  c   ::  Q a c -> (c -> c -> v ) -> a ->  c   ::   a c -> (c -> c -> v ) -> a ->  c   ::  3 a c -> (c -> c -> v ) -> a ->  c 2Obtain the minimum element (if any) targeted by a Y, 3, , Q  or ( according to a user supplied ordering.  w cmp "a s (t empty)   [ cmp    ::  a c -> (c -> c -> v ) -> a ->  c   :: Y a c -> (c -> c -> v ) -> a ->  c   ::  Q a c -> (c -> c -> v ) -> a ->  c   ::   a c -> (c -> c -> v ) -> a ->  c   ::  3 a c -> (c -> c -> v ) -> a ->  c The  function takes a  (or , Q, Y, or 3), O a predicate and a structure and returns the leftmost element of the structure  matching the predicate, or  if there is no such element.    ::  a c -> (c ->  ) -> a ->  c   :: Y a c -> (c ->  ) -> a ->  c   ::  Q a c -> (c ->  ) -> a ->  c   ::   a c -> (c ->  ) -> a ->  c   ::  3 a c -> (c ->  ) -> a ->  c  A variant of g4 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.     l f "a x f  i l   "a  [     :: * a c -> (c -> c -> c) -> a -> c   :: Y, a c -> (c -> c -> c) -> a -> c   ::  Q& a c -> (c -> c -> c) -> a -> c   ::  % a c -> (c -> c -> c) -> a -> c   ::  3 a c -> (c -> c -> c) -> a -> c  A variant of hQ 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.     l f "a  l f . n   "a  [     :: * a c -> (c -> c -> c) -> a -> c   :: Y, a c -> (c -> c -> c) -> a -> c   ::  Q& a c -> (c -> c -> c) -> a -> c   ::  % a c -> (c -> c -> c) -> a -> c   ::  3 a c -> (c -> c -> c) -> a -> c 6Strictly fold right over the elements of a structure.   "a  [    :: / a c -> (c -> e -> e) -> e -> a -> e   :: Y1 a c -> (c -> e -> e) -> e -> a -> e   ::  Q+ a c -> (c -> e -> e) -> e -> a -> e   ::  * a c -> (c -> e -> e) -> e -> a -> e   ::  3% a c -> (c -> e -> e) -> e -> a -> e NFold over the elements of a structure, associating to the left, but strictly.   "a  [    :: / a c -> (e -> c -> e) -> e -> a -> e   :: Y1 a c -> (e -> c -> e) -> e -> a -> e   ::  Q+ a c -> (e -> c -> e) -> e -> a -> e   ::  * a c -> (e -> c -> e) -> e -> a -> e   ::  3% a c -> (e -> c -> e) -> e -> a -> e IMonadic fold over the elements of a structure, associating to the right,  i.e. from right to left.   "a  [    ::  m => 3 a c -> (c -> e -> m e) -> e -> a -> m e   ::  m => Y5 a c -> (c -> e -> m e) -> e -> a -> m e   ::  m =>  Q/ a c -> (c -> e -> m e) -> e -> a -> m e   ::  m =>  . a c -> (c -> e -> m e) -> e -> a -> m e   ::  m =>  3) a c -> (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.   "a  [    ::  m => 3 a c -> (e -> c -> m e) -> e -> a -> m e   ::  m => Y5 a c -> (e -> c -> m e) -> e -> a -> m e   ::  m =>  Q/ a c -> (e -> c -> m e) -> e -> a -> m e   ::  m =>  . a c -> (e -> c -> m e) -> e -> a -> m e   ::  m =>  3) a c -> (e -> c -> m e) -> e -> a -> m e 8VWXYZ[\]^_`abcdefghijklmnopqrstyuvwxyz{|}~7VWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~7YjZ[_`ab\]^cdefghimnklopqrstuvwx{|yz}~VWX6VWXYZ[\]^_`abcdefghijklmnopqrstyuvwxyz{|}~ Rank2Types provisionalEdward Kmett <ekmett@gmail.com>None type SimpleReifiedTraversal =   A form of 4 that can be stored monomorphically in a container.  type SimpleTraversal =  A  can be used directly as a 1 or a Y (but not as a ) and provides V the ability to both read and update multiple fields, subject to some relatively weak  laws. UThese have also been known as multilenses, but they have the signature and spirit of   ::  f =>  (f a) (f b) a b8and the more evocative name suggests their application. Most of the time the  you will want to use is just , but you can also pass any   or Q as a , and composition of a  (or  or Q ) with a  (or  or Q)  using (.) forms a valid . The laws for a Traversal t3 follow from the laws for Traversable as stated in "#The Essence of the Iterator Pattern".    t  "a    (t f)  t g "a `a  t (`b   f  g) .One consequence of this requirement is that a 1 needs to leave the same number of elements as a  candidate for subsequent G that it started with. Another testament to the strength of these laws 4 is that the caveat expressed in section 5.5 of the "Essence of the Iterator Pattern" about exotic   instances that E the same entry multiple times was actually already ruled out by the  second law in that same paper! AMap each element of a structure targeted by a Lens or Traversal, E evaluate these actions from left to right, and collect the results.   "a   "a      :: Q) a b c d -> (c -> f d) -> a -> f b   :: ( a b c d -> (c -> f d) -> a -> f b   :: # a b c d -> (c -> f d) -> a -> f b   l "a  ( l)   z "a     "a      :: Q# a b c d -> a -> (c -> f d) -> f b   :: # a b c d -> a -> (c -> f d) -> f b   :: # a b c d -> a -> (c -> f d) -> f b FEvaluate each action in the structure from left to right, and collect  the results.    { "a   =     l "a  l id   l "a l id     :: Q a b (f c) c -> a -> f b   ::  a b (f c) c -> a -> f b   ::  f =>  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.  @ "a      :: Q) a b c d -> (c -> m d) -> a -> m b   :: ( a b c d -> (c -> m d) -> a -> m b   ::  m => # a b c d -> (c -> m d) -> a -> m b    | "a     l "a  ( l)     :: Q) a b c d -> a -> (c -> m d) -> m b   :: ( a b c d -> a -> (c -> m d) -> m b   ::  m => # a b c d -> a -> (c -> m d) -> m b    } "a     l "a  l id   l "a ~ . l      :: Q a b (m c) c -> a -> m b   ::  a b (m c) c -> a -> m b   ::  m =>  a b (m c) c -> a -> m b This generalizes  to an arbitrary . Note: F handles ragged inputs more intelligently, but for non-ragged inputs:   "a  &transposeOf traverse [[1,2,3],[4,5,6]][[1,4],[2,5],[3,6]] Since every  is a , we can use this as a form of  monadic strength as well:  _2 :: (b, [a] ) -> [(b, a)] Generalizes  to an arbitrary .   "a  ' accumulates state from right to left.    :: Q9 a b c d -> (s -> c -> (s, d)) -> s -> a -> (s, b)   :: 8 a b c d -> (s -> c -> (s, d)) -> s -> a -> (s, b)   :: 3 a b c d -> (s -> c -> (s, d)) -> s -> a -> (s, b)  Generalized  to an arbitrary .   "a  ' accumulates state from left to right.    :: Q9 a b c d -> (s -> c -> (s, d)) -> s -> a -> (s, b)   :: 8 a b c d -> (s -> c -> (s, d)) -> s -> a -> (s, b)   :: 3 a b c d -> (s -> c -> (s, d)) -> s -> a -> (s, b) Permit the use of  over an arbitrary  or .   "a      :: Q* a b c c -> (c -> c -> c) -> a -> b   :: ) a b c c -> (c -> c -> c) -> a -> b   :: $ a b c c -> (c -> c -> c) -> a -> b Permit the use of  over an arbitrary  or .   "a     1 :: Iso a b c c -> (c -> c -> c) -> a -> b  1 :: Lens a b c c -> (c -> c -> c) -> a -> b  1 :: Traversal a b c c -> (c -> c -> c) -> a -> b A  to 4'Control.Lens.Getter.view'/'Control.Lens.Setter.set' the nth element  a ,  or Q. +Attempts to access beyond the range of the  will cause an error. import Control.Lens,[[1],[3,4]]^.elementOf (traverse.traverse) 13Access the nth element of a  container. +Attempts to access beyond the range of the  will cause an error.  "a  %This is the traversal that just doesn't return anything   ::  f => (c -> f d) -> a -> f a  "a  4Traverse both parts of a tuple with matching types. 3A traversal for tweaking the left-hand value of an : traverseLeft ::  f => (a -> f b) ->  a c -> f ( b c)$traverse the right-hand value of an :   "a Unfortunately the instance for   ( c) is still missing from base,  so this can' t just be  traverseRight ::  f => (a -> f b) ->  c a -> f ( c a)A 2 is completely characterized by its behavior on a .  Cloning a ) is one way to make sure you arent given  something weaker, such as a O and can be H used as a way to pass around traversals that have to be monomorphic in f. !Note: This only accepts a proper  (or ). To clone a   as such, use  Note: It is usually better to  and use   than to 2. The former can execute at full speed, while the ( latter needs to round trip through the . TemplateHaskell experimentalEdward Kmett <ekmett@gmail.com> Trustworthy  Provides substitution for types Perform substitution for types HProvides for the extraction of free type variables, and alpha renaming. 4When performing substitution into this traversal you're not allowed 8 to substitute in a name that is bound internally or you' ll violate  the . laws, when in doubt generate your names with . Has a  Extract (or modify) the  of something  Traverse free type variables 'Substitute using a map of names in for free type variables  Provides a . of the types of each field of a constructor.  of the types of the named fields of a constructor.    Rank2Types provisionalEdward Kmett <ekmett@gmail.com>None:A O type is one where we know how to extract its immediate self-similar children.  Example 1:    import Control.Applicative  import Control.Lens  import Control.Plated  import Data.Data  import Data.Data.Lens (")    data Expr  = Val   | Neg Expr  | Add Expr Expr  deriving (C,<,,,Data,Typeable)    instance  Expr where   f (Neg e) = Neg  f e   f (Add a b) = Add  f a > f b   _ a =  a or    instance  Expr where   = "  Example 2:    import Control.Applicative  import Control.Lens  import Control.Plated  import Data.Data  import Data.Data.Lens (")    data Tree a  = Bin (Tree a) (Tree a)  | Tip a  deriving (C,<,,,Data,Typeable)    instance  (Tree a) where   f (Bin l r) = Bin  f l > f r   _ t =  t or    instance Data a =>  (Tree a) where   = uniplate <Note the big distinction between these two implementations. JThe former will only treat children directly in this tree as descendents, I the latter will treat trees contained in the values under the tips also  as descendants! When in doubt, pick a  and just use the various ...Of combinators  rather than pollute  with orphan instances! >If you want to find something unplated and non-recursive with "  use the ...OnOf variant with /, though those usecases are much better served < in most cases by using the existing lens combinators! e.g. i biplate "a  biplate . )This same ability to explicitly pass the  in question is why there is no  analogue to uniplate's Biplate. UMoreover, since we can allow custom traversals, we implement reasonable defaults for A polymorphic data types, that only traverse into themselves, and not their  polymorphic arguments. . of the immediate children of this structure. *The default definition finds no children. 'Extract the immediate descendants of a  container.  "a i  Provided for compatibility with uniplate.   "a i  :: Y a c -> a -> [c]LRewrite by applying a rule everywhere you can. Ensures that the rule cannot $ be applied anywhere in the result:  propRewrite r x =  ( . r) ( ( r x))Usually  is more appropriate, but  can give better 4 compositionality. Given two single transformations f and g , you can  construct a -> f a mplus g a3 which performs both rewrites until a fixed point. LRewrite by applying a rule everywhere you can. Ensures that the rule cannot $ be applied anywhere in the result:  propRewriteOf l r x =  ( . r) ( l ( l r x))Usually  is more appropriate, but  can give better 4 compositionality. Given two single transformations f and g , you can  construct a -> f a mplus g a3 which performs both rewrites until a fixed point.    ::  Q a a -> (a ->  a) -> a -> a   ::   a a -> (a ->  a) -> a -> a   ::   a a -> (a ->  a) -> a -> a   ::   a a -> (a ->  a) -> a -> a 5Rewrite recursively over part of a larger structure.    ::  c =>  Q a b -> (b ->  b) -> a -> a   ::  c =>   a b -> (b ->  b) -> a -> a   ::  c =>   a b -> (b ->  b) -> a -> a   ::  c =>   a b -> (b ->  b) -> a -> a NRewrite recursively over part of a larger structure using a specified setter.    ::  b =>  Q a b ->  Q b b -> (b ->  b) -> a -> a   ::  b =>   a b ->   b b -> (b ->  b) -> a -> a   ::  b =>   a b ->   b b -> (b ->  b) -> a -> a   ::  b =>   a b ->   b b -> (b ->  b) -> a -> a TRewrite by applying a monadic rule everywhere you can. Ensures that the rule cannot $ be applied anywhere in the result. RRewrite by applying a monadic rule everywhere you recursing with a user-specified . A Ensures that the rule cannot be applied anywhere in the result. `Rewrite by applying a monadic rule everywhere inside of a structure located by a user-specified . A Ensures that the rule cannot be applied anywhere in the result. `Rewrite by applying a monadic rule everywhere inside of a structure located by a user-specified ,  using a user-specified P for recursion. Ensures that the rule cannot be applied anywhere in the result. 0Retrieve all of the transitive descendants of a  container, including itself. Given a fold that knows how to locate immediate children, retrieve all of the transitive descendants of a node, including itself.  :: Y a a -> a -> [a]Given a Y that knows how to find O parts of a container retrieve them and all of their descendants, recursively. Given a Y~ that knows how to locate immediate children, retrieve all of the transitive descendants of a node, including itself that lie " in a region indicated by another Y. i l "a  l <Transform every element in the tree, in a bottom-up manner. 8For example, replacing negative literals with literals:   negLits =  $ x -> case x of  Neg (Lit i) -> Lit ( i)  _ -> x WTransform every element in the tree in a bottom-up manner over a region indicated by a .    ::  b =>   a b -> (b -> b) -> a -> a   ::  b =>   a b -> (b -> b) -> a -> a 8Transform every element by recursively applying a given  in a bottom-up manner.    ::   a a -> (a -> a) -> a -> a   ::   a a -> (a -> a) -> a -> a 3Transform every element in a region indicated by a ! by recursively applying another   in a bottom-up manner.    ::  a b ->   b b -> (b -> b) -> a -> a   ::  a b ->   b b -> (b -> b) -> a -> a ITransform every element in the tree, in a bottom-up manner, monadically. HTransform every element in the tree in a region indicated by a supplied &, in a bottom-up manner, monadically.  :: ( m,  c) =>   a b -> (b -> m b) -> a -> m a8Transform every element in a tree using a user supplied . in a bottom-up manner with a monadic effect.  ::  m => 'Simple  a a -> (a -> m a) -> a -> m aPTransform every element in a tree that lies in a region indicated by a supplied , walking with a user supplied  in + a bottom-up manner with a monadic effect.  ::  m =>   a b ->   b b -> (b -> m b) -> a -> m a+Recurse one level into a structure. (a.k.a composOp from Bjrn Bringert's compos)  "a  TRecurse one level into a structure using a user specified recursion scheme. This is , but it is supplied here ( for consistency with the uniplate API.   "a     ::   a b -> (b -> b) -> a -> a   ::   a b -> (b -> b) -> a -> a 2Recurse one level into the parts delimited by one , using another.   b l "a  (b  l)    ::   a b ->   b b -> (b -> b) -> a -> a   ::   a b ->   b b -> (b -> b) -> a -> a ARecurse one level into the parts of the structure delimited by a .   b "a  (b  )  ::  c =>  a b -> (b -> b) -> a -> a+Recurse one level into a structure with an  effect, this is , but it is supplied ( for consistency with the uniplate API.  "a ORecurse one level into a structure using a user specified recursion scheme and  effects. This is , but it is supplied ( for consistency with the uniplate API.   "a   ::  m =>   a b => (b -> m b) -> a -> m a2Recurse one level into the parts delimited by one , using another with  effects.   "a ()  ::  f =>   a b ->   b b -> (b -> f b) -> a -> f aARecurse one level into the parts of the structure delimited by a  with  effects.   b "a b    :: ( f, Plated' c) =>   a b -> (b -> f b) -> a -> f a  "a traverseOf_' ORecurse one level into a structure using a user specified recursion scheme and ; effects, without reconstructing the structure behind you.  This is just q#, but is provided for consistency.   "a q  ::  f => Y a b => (b -> f b) -> a -> f ()2Recurse one level into the parts delimited by one Y, using another with ; effects, without reconstructing the structure behind you.   b l "a q (b  l)  ::  f => Y a b -> Y b b -> (b -> f c) -> a -> f ()ARecurse one level into the parts of the structure delimited by a  with monadic effects.   b "a q (b  )  :: ( f,  b) =>   a b -> (b -> f c) -> a -> f ()ARecurse one level into a structure with a monadic effect. (a.k.a  composOpM from Bjrn Bringert's compos)  "a  hRecurse one level into a structure using a user specified recursion scheme and monadic effects. This is  , but it is 1 supplied for consistency with the uniplate API.   "a   ::  m =>   a b => (b -> m b) -> a -> m a2Recurse one level into the parts delimited by one &, using another with monadic effects.   b l "a  (b  l)  ::  m =>   a b ->   b b -> (b -> m b) -> a -> m aARecurse one level into the parts of the structure delimited by a  with monadic effects.   b "a  (b . )  :: ( m,  c) =>   a b -> (b -> m b) -> a -> m a?Descend one level into a structure with monadic effects (a.k.a  composOpM from Bjrn Bringert's compos)  "a mapMOf_' mRecurse one level into a structure using a user specified recursion scheme and monadic effects. This is just t#, but is provided for consistency.   "a t  ::  m => Y a b => (b -> m b) -> a -> m ()2Recurse one level into the parts delimited by one &, using another with monadic effects.   b l "a t (b  l)  ::  m => Y a b -> Y b b -> (b -> m b) -> a -> m ()ARecurse one level into the parts of the structure delimited by a  with monadic effects.   b "a t (b  )  :: ( m,  b) =>   a b -> (b -> m c) -> a -> m ()`Return a list of all of the editable contexts for every location in the structure, recursively.    propUniverse x =  x ==  pos ( x)  propId x =  ( x) [extract w | w <-  x]   "a  wReturn a list of all of the editable contexts for every location in the structure, recursively, using a user-specified  to walk each layer.    propUniverse l x =  l x ==  pos ( l x)  propId l x =  ( x) [extract w | w <-  l x]   ::   a a -> a -> [9 a a]{Return a list of all of the editable contexts for every location in the structure in an areas indicated by a user supplied , recursively using .   b "a  b   ::  b =>   a b -> a -> [9 b b a]{Return a list of all of the editable contexts for every location in the structure in an areas indicated by a user supplied , recursively using  another user-supplied  to walk each layer.  ::   a b ->   b b -> a -> [9 b b a]The one-level version of contextG. This extracts a list of the immediate children as editable contexts. Given a context you can use pos to see the values, peekF at what the structure would be like with an edited result, or simply extract the original structure.    propChildren x =  l x   pos ( l x)  propId x =  ( x) [extract w | w <-  l x]   =  The one-level version of F. This extracts a list of the immediate children according to a given  as editable contexts. Given a context you can use pos to see the values, peekF at what the structure would be like with an edited result, or simply extract the original structure.    propChildren l x =  childrenOf l x   pos ( l x)  propId l x =  ( x) [extract w | w <-  l x]     ::  Iso a b -> a -> [9 b a]   ::   a b -> a -> [9 b a]   ::   a b -> a -> [9 b a]  An alias for 7, provided for consistency with the other combinators.   "a     ::  Iso a b -> a -> [9 b b a]   ::   a b -> a -> [9 b b a]   ::   a b -> a -> [9 b b a] IExtract one level of holes from a container in a region specified by one , using another.   b l "a  (b  l)    ::  Iso a b ->  Iso b b -> a -> [9 b a]   ::   a b ->   b b -> a -> [9 b a]   ::   a b ->   b b -> a -> [9 b a] KPerform a fold-like computation on each value, technically a paramorphism.  :: Y a a -> (a -> [r] -> r) -> a -> rKPerform a fold-like computation on each value, technically a paramorphism.  "a  !Fold the immediate children of a  container.  z c f = g  (c  f) z The original uniplate% combinator, implemented in terms of  as a .   "a  1The resulting lens is safer to use as it ignores 'over-application'. and deals gracefully with under-application, ( but it is only a proper lens if you don't change the list j!  turns a 4 into a lens that resembles an early version of the uniplate (or biplate) type. Note:X You should really try to maintain the invariant of the number of children in the list. pAny extras will be lost. If you do not supply enough, then the remainder will come from the original structure. [So technically, this is only a lens if you do not change the number of results it returns.    ::  Q a b ->   a [b]   ::   a b ->   a [b]   ::   a b ->   a [b]  turns a  into a uniplate (or biplate ) family.  If you do not need the types of c and d) to be different, it is recommended that  you use  +It is generally safer to traverse with the  rather than use this 2 combinator. However, it is sometimes convenient. !This is unsafe because if you don't supply at least as many d's as you were  given c's, then the reconstruction of b will result in an error!    :: Q a b c d ->  a b [c] [d]   ::  a b c d ->  a b [c] [d]   ::  a b c d ->  a b [c] [d] D::A Rank2Types provisionalEdward Kmett <ekmett@gmail.com>None#A  with an additional index. 2An instance must satisfy a (modified) form of the  laws:    ( ) "a    ( f)   g "a  getCompose   (i -> Compose   (f i)  g i) Traverse an indexed container. <A container that supports folding with an additional index. 2Fold a container by mapping value to an arbitrary  with access to the index i.  When you don' t need access to the index then & is more flexible in what it accepts.  "a   HRight-associative fold of an indexed container with access to the index i.  When you don' t need access to the index then & is more flexible in what it accepts.  "a   GLeft-associative fold of an indexed container with access to the index i.  When you don' t need access to the index then & is more flexible in what it accepts.  "a   StrictlyF fold right over the elements of a structure with access to the index i.  When you don' t need access to the index then & is more flexible in what it accepts.  "a   RFold over the elements of a structure with an index, associating to the left, but strictly.  When you don' t need access to the index then & is more flexible in what it accepts.   l "a  l      :: R7 i a c -> (i -> e -> c -> e) -> e -> a -> e   :: 9 i a c -> (i -> e -> c -> e) -> e -> a -> e   ::  x3 i a c -> (i -> e -> c -> e) -> e -> a -> e   :: . i a c -> (i -> e -> c -> e) -> e -> a -> e A  with an additional index. .Instances must satisfy a modified form of the  laws:    f   g "a  (i -> f i . g i)   (_ a -> a) "a  Map with access to the index. The  for a .  If you don'!t need access to the index, then mapped& is more flexible in what it accepts. The  of a  container.  Obtain a Y9 by lifting an operation that returns a foldable result. +This can be useful to lift operations from  Data.List and elsewhere into a Y. aReturn whether or not any element in a container satisfies a predicate, with access to the index i.  When you don' t need access to the index then & is more flexible in what it accepts.  =   `Return whether or not all elements in a container satisfy a predicate, with access to the index i.  When you don' t need access to the index then & is more flexible in what it accepts.  "a   +Traverse elements with access to the index i, discarding the results.  When you don' t need access to the index then & is more flexible in what it accepts.  l =   +Traverse elements with access to the index i7, discarding the results (with the arguments flipped).   "a   When you don' t need access to the index then `& is more flexible in what it accepts. ` a "a  a  *Run monadic actions for each target of an  or  with access to the index,  discarding the results.  When you don' t need access to the index then t& is more flexible in what it accepts.  "a   *Run monadic actions for each target of an  or  with access to the index, 6 discarding the results (with the arguments flipped).   "a   When you don' t need access to the index then u& is more flexible in what it accepts. u l a "a  l a  hConcatenate the results of a function of the elements of an indexed container with access to the index.  When you don' t need access to the index then h& is more flexible in what it accepts.   h "a  .    "a  xSearches a container with a predicate that is also supplied the index, returning the left-most element of the structure  matching the predicate, or  if there is no such element.  When you don' t need access to the index then & is more flexible in what it accepts.  "a   CMonadic fold right over the elements of a structure with an index.  When you don' t need access to the index then & is more flexible in what it accepts.  "a   VMonadic fold over the elements of a structure with an index, associating to the left.  When you don' t need access to the index then & is more flexible in what it accepts.  "a   .Extract the key-value pairs from a structure.  When you don'1t need access to the indices in the result, then & is more flexible in what it accepts.  "a    IFold a container with indices returning both the indices and the values. :Fold a container with indices returning only the indices. The  of a  container. 3Traverse with an index (and the arguments flipped)   z a "a  a     "a   5Map each element of a structure to a monadic action, Q evaluate these actions from left to right, and collect the results, with access  the index.  When you don't need access to the index @( is more liberal in what it can accept. @ "a   5Map each element of a structure to a monadic action, Q evaluate these actions from left to right, and collect the results, with access + its position (and the arguments flipped).   | a "a  a     "a    Generalizes  to add access to the index. ' accumulates state from right to left.  "a    Generalizes  to add access to the index. ' accumulates state from left to right.  "a    PAccess the element of an indexed container where the index matches a predicate. import Control.LensBover (iwhere (>0)) Prelude.reverse $ ["He","was","stressed","o_O"]["He","saw","desserts","O_o"]8The position in the sequence is available as the index. 4The position in the list is available as the index. 2 ! ! + TemplateHaskell experimentalEdward Kmett <ekmett@gmail.com> Trustworthy +This configuration describes the options we',ll be using to make isomorphisms or lenses.  Flags for lens construction Only Generate valid   lenses. HEnables the generation of partial lenses, generating runtime errors for L every constructor that does not have a valid definition for the lens. This L occurs when the constructor lacks the field, or has multiple fields mapped  to the same lens. 5In the situations that a lens would be partial, when  is M used, this flag instead causes traversals to be generated. Only one can be C used, and if neither are, then compile-time errors are generated. )Handle singleton constructors specially. When building a singleton - (or ') for a record constructor, build both  the - (or ,) for the record and the one for the field. Use - for singleton constructors. @Expect a single constructor, single field newtype or data type. 6Create the class if the constructor is simple and the # rule matches. 9Create the instance if the constructor is simple and the # rule matches.   Die if the # fails to match. !SLens to access the convention for naming top level isomorphisms in our lens rules. =Defaults to lowercasing the first letter of the constructor. "CLens to access the convention for naming fields in our lens rules. MDefaults to stripping the _ off of the field name, lowercasing the name, and  rejecting the field if it doesn't start with an '_'. #JRetrieve options such as the name of the class and method to put in it to . build a class around monomorphic data types. $JRetrieve options such as the name of the class and method to put in it to . build a class around monomorphic data types. %Default lens rules &JRules for making fairly simple partial lenses, ignoring the special cases > for isomorphisms and traversals, and not making any classes. 'ERules for making lenses and traversals that precompose another lens. (1Rules for making an isomorphism from a data type )EBuild lenses (and traversals) with a sensible default configuration. ' makeLenses = makeLensesWith lensRules *ZMake lenses and traversals for a type, and create a class when the type has no arguments. e.g.   " data Foo = Foo { _fooX, _fooY ::  }  * ''Foo  will create    class HasFoo t where  foo ::   t Foo ! instance HasFoo Foo where foo =   fooX, fooY :: HasFoo t =>   t   ) makeClassy = makeLensesWith classyRules +'Make a top level isomorphism injecting into the type. dThe supplied name is required to be for a type with a single constructor that has a single argument e.g.    newtype List a = List [a]  makeIso ''List  will create    list :: Iso [a] [b] (List a) (List b)  # makeIso = makeLensesWith isoRules ,>Derive lenses and traversals, specifying explicit pairings of (fieldName, lensName). qIf you map multiple names to the same label, and it is present in the same constructor then this will generate a . e.g. < makeLensesFor [("_foo", "fooLens"), ("baz", "lbaz")] ''Foo 9 makeLensesFor [("_barX", "bar"), ("_barY", "bar)] ''Bar -JDerive lenses and traversals, using a named wrapper class, and specifying  explicit pairings of (fieldName, traversalName). Example usage: K makeClassyFor "HasFoo" "foo" [("_foo", "fooLens"), ("bar", "lbar")] ''Foo .*Build lenses with a custom configuration. ZGiven a set of names, build a map from those names to a set of fresh names based on them. Given  8 newtype Cxt b => Foo a b c d = Foo { _baz :: Bar a b } This will generate: N foo :: (Cxt b, Cxt f) => Iso (Foo a b c d) (Foo e f g h) (Bar a b) (Bar e f) : foo = isomorphic (\f a -> (\(Foo b) -> b) <$> f (Foo a)) 1 (\f (Foo a) -> fmap Foo (f a))  {-# INLINE foo #-} Gets 2[(lens name, (constructor name, field name, type))] from a record constructor 7     !"#$%&'()*+,-.0surrounding cxt driven by the data type context data/newtype constructor name args %     !"#$%&'()*+,-.%),*-+.%  &'(!"#$   (     !"#$%&'()*+,-. Rank2Types provisionalEdward Kmett <ekmett@gmail.com>NoneZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./01234789:;<=>?@ABCDEFGHIJKLMNOPQRSVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-.GHC experimentalEdward Kmett <ekmett@gmail.com>None/Used to traverse  data by uniplate. 0;Convert from the data type to its representation (or back) '"hello"^.generic.from generic :: String"hello"1;Convert from the data type to its representation (or back) 2A   that visits every occurence  of something  anywhere in a container. BallOf tinplate (=="Hello") (1::Int,2::Double,(),"Hello",["Hello"])True:mapMOf_ tinplate putStrLn ("hello",[(2 :: Int, "world!")])helloworld! /012/012012/ /012Control.Exception provisionalEdward Kmett <ekmett@gmail.com>None3Traverse the strongly typed  contained in ) where the type of your function matches  the desired .   traverseException :: ( f,  a,  b) $ => (a -> f b) ->  -> f  3333LiberalTypeSynonyms experimentalEdward Kmett <ekmett@gmail.com>None 4Bitwise  the target(s) of a  or  _2 |~ 6 $ ("hello",3) ("hello",7)   (4) ::  c =>  a b c c -> c -> a -> b  (4) ::  c => - a b c c -> c -> a -> b  (4) ::  c =>  a b c c -> c -> a -> b  (4) :: ('Monoid c',  c) =>  a b c c -> c -> a -> b 5Bitwise  the target(s) of a  or  _2 &~ 7 $ ("hello",254) ("hello",6)   (5) ::  c =>  a b c c -> c -> a -> b  (5) ::  c => - a b c c -> c -> a -> b  (5) ::  c =>  a b c c -> c -> a -> b  (5) :: ('Monoid c',  c) =>  a b c c -> c -> a -> b 6Modify the target(s) of a  ,  or  by computing its bitwise  with another value.   (6) :: ( a m,  b) =>   a b -> b -> m ()  (6) :: ( a m,  b) =>  - a b -> b -> m ()  (6) :: ( a m,  b) =>   a b -> b -> m ()  (6) :: ( a m,  b) =>   a b -> b -> m () 7Modify the target(s) of a  ,  or  by computing its bitwise  with another value.   (7) :: ( a m,  b) =>   a b -> b -> m ()  (7) :: ( a m,  b) =>  - a b -> b -> m ()  (7) :: ( a m,  b) =>   a b -> b -> m ()  (7) :: ( a m,  b) =>   a b -> b -> m () 8Bitwise  the target(s) of a  (or ), returning the result 0 (or a monoidal summary of all of the results). _2 <|~ 6 $ ("hello",3)(7,("hello",7))   (8) ::  c => - a b c c -> c -> a -> (c, b)  (8) ::  c =>  a b c c -> c -> a -> (c, b)  (8) :: ( c, ' Monoid c) =>  a b c c -> c -> a -> (c, b) 9Bitwise  the target(s) of a  or , returning the result 0 (or a monoidal summary of all of the results). _2 <&~ 7 $ ("hello",254)(6,("hello",6))   (9) ::  c => - a b c c -> c -> a -> (c, b)  (9) ::  c =>  a b c c -> c -> a -> (c, b)  (9) :: ( c, ' Monoid c) =>  a b c c -> c -> a -> (c, b) :Modify the target(s) of a   (or ) by computing its bitwise  with another value, N returning the result (or a monoidal summary of all of the results traversed)   (:) :: ( a m,  b) =>   a b -> b -> m b  (:) :: ( a m,  b, Monoid b) =>   a b -> b -> m b ;Modify the target(s) of a  , (or ) by computing its bitwise  with another value, N returning the result (or a monoidal summary of all of the results traversed)   (;) :: ( a m,  b) =>   a b -> b -> m b  (;) :: ( a m,  b, Monoid b) =>   a b -> b -> m b <FThis lens can be used to access the value of the nth bit in a number. < n is only a legal  into b if 0 <= n <  ( :: b)  16^.bitAt 4True 15^.bitAt 4False=*Traverse over all bits in a numeric type. ,The bit position is available as the index. import Data.Word"toListOf traverseBits (5 :: Word8)/[True,False,True,False,False,False,False,False]If you supply this an , the result will  be an infinite $ that can be productively consumed. 456789:;<= 456789:;<= 458976;:<= 456789:;<=portable provisionalEdward Kmett <ekmett@gmail.com>None>,A lens reading and writing to the head of a  non-empty list. .Attempting to read or write to the head of an empty list will result in an t. [1,2,3]^._head1?,A lens reading and writing to the tail of a  non-empty list .Attempting to read or write to the tail of an empty list will result in an t. _tail .~ [3,4,5] $ [1,2] [1,3,4,5]@4A lens reading and writing to the last element of a  non-empty list 6Attempting to read or write to the last element of an empty list will result in an t.  [1,2]^._last2A=A lens reading and replacing all but the a last element of a  non-empty list >Attempting to read or write to all but the last element of an empty list will result in an t. [1,2,3,4]^._init[1,2,3]BCObtain a version of the list with the supplied value interspersed. "abcde"^.interspersed ',' "a,b,c,d,e" ' xs^.interspersed a = intersperse a xs CCObtain a version of the list with the supplied value intercalated. DQIndexed traversal of a list. The position in the list is available as the index. E:A traversal for reading and writing to the head of a list MThe position of the head in the original list (0) is available as the index. traverseHead +~ 1 $ [1,2,3][2,2,3] E ::  f => (a -> f a) -> [a] -> f [a]F+A traversal for editing the tail of a list The position of each element in the original list is available as the index. traverseTail +~ 1 $ [1,2,3][1,3,4] F ::  f => (a -> f a) -> [a] -> f [a]G'A traversal the last element in a list QThe position of the last element in the original list is available as the index. traverseLast +~ 1 $ [1,2,3][1,2,4] G ::  f => (a -> f a) -> [a] -> f [a]H2A traversal of all but the last element of a list 8The position of each element is available as the index. traverseInit +~ 1 $ [1,2,3][2,3,3] H ::  f => (a -> f a) -> [a] -> f [a]I&Cons onto the list(s) referenced by a . 'h' ~: _1 $ ("ello","world")("hello","world")   (I ) :: b ->   a [b] -> a -> a  (I ) :: b ->   a [b] -> a -> a  (I ) :: b ->   a [b] -> a -> a  (I ) :: b ->  - a [b] -> a -> a J&Cons onto the list(s) referenced by a  in your monad state   (J) ::  a m => c ->   a [c] -> m ()  (J) ::  a m => c ->   a [c] -> m ()  (J) ::  a m => c ->   a [c] -> m ()  (J) ::  a m => c ->  - a [c] -> m () K&Cons onto the list(s) referenced by a  (or ), returning the result. If you use this with a 3 you will receive back the concatenation of all of 6 the resulting lists instead of an individual result. 'h' <~: _1 $ ("ello","world")("hello",("hello","world"))   (K ) :: b ->   a [b] -> a -> ([b], a)  (K ) :: b ->  - a [b] -> a -> ([b], a)  (K ) :: b ->   a [b] -> a -> ([b], a) L&Cons onto the list(s) referenced by a  (or ) into your monad state,  returning the result. If you use this with a 1, you will receive back the concatenation of all 9 of the resulting lists instead of an individual result.   (L) ::  a m =>   a [c] -> c -> m [c]  (L) ::  a m =>  - a [c] -> c -> m [c]  (L) ::  a m =>   a [c] -> c -> m [c] MFAppend to the target of a list-valued setter by appending to it with (). (-) generalizes this operation to an arbitrary Monoid. :m + Control.Lens"both ++~ "!!!" $ ("hello","world")("hello!!!","world!!!")   (M) ::   a [b] -> [b] -> a -> a  (M) ::  - a [b] -> [b] -> a -> a  (M) ::   a [b] -> [b] -> a -> a  (M) ::   a [b] -> [b] -> a -> a NAppend to the target(s) of a  , -,  or  with () in the current state. (-) generalizes this operation to an arbitrary Monoid.   (N) ::  a m =>   a [b] -> [b] -> m ()  (N) ::  a m =>  - a [b] -> [b] -> m ()  (N) ::  a m =>   a [b] -> [b] -> m ()  (N) ::  a m =>   a [b] -> [b] -> m () O.Append onto the end of the list targeted by a  and return the result. (-) generalizes this operation to an arbitrary Monoid.  When using a K, the result returned is actually the concatenation of all of the results. 3When you do not need the result of the operation, (M) is more flexible. P.Append onto the end of the list targeted by a 8 into the current monadic state, and return the result. (-) generalizes this operation to an arbitrary Monoid.  When using a K, the result returned is actually the concatenation of all of the results. 3When you do not need the result of the operation, (N) is more flexible. >?@ABCDEFGHIJKLMNOP>?@ABCDEFGHIJKLMNOP>?@ABCDEFHGIJKLMONP>?@ABCDEFGHIJKLMNOPportable provisionalEdward Kmett <ekmett@gmail.com>NoneQ (or ) a list of bytes into a    x = x # Q  x = x #  QRTraverse each  in a   R =  Q a D m R ( 0x80) ::  -> S (or ) a list of characters into a  When writing back to the  it is assumed that every 8  lies between '\x00' and '\xff'.   x = x # S  x = x #  ST#Traverse the individual bytes in a  as characters. When writing back to the  it is assumed that every 8  lies between '\x00' and '\xff'.  T =  S .  m T ( 'c') ::  -> QRSTQRSTQRSTQRSTportable provisionalEdward Kmett <ekmett@gmail.com>NoneU (or ) a list of bytes into a    x = x # U  x = x #  UV#Traverse the individual bytes in a   V =  U . D m V ( 0x80) ::  -> W (or ) a list of characters into a  When writing back to the  it is assumed that every 8  lies between '\x00' and '\xff'.   x = x # W  x = x #  WX#Traverse the individual bytes in a  as characters. When writing back to the  it is assumed that every 8  lies between '\x00' and '\xff'.  X =  W a D m X ( 'c') ::  -> UVWXUVWXUVWXUVWX portable provisionalEdward Kmett <ekmett@gmail.com>NoneYTraversals for ByteStrings. Z (or () a list of bytes into a strict or lazy    x = x # Z  x = x #  Z[ (or -) a list of characters into a strict or lazy  When writing back to the  it is assumed that every 8  lies between '\x00' and '\xff'.   x = x # [  x = x #  [\Traverse each  in a strict or lazy   \ =  Z a  traverseList m \ ( 0x80) ::  -> ]2Traverse the individual bytes in a strict or lazy  as characters. When writing back to the  it is assumed that every 8  lies between '\x00' and '\xff'.  ] =  [ .  m ] ( 'c') ::  -> YZ[\]YZ[\]YZ[\]YZ[\]! Rank2Types experimentalEdward Kmett <ekmett@gmail.com>None^ Access the  of a  number ? real :: Functor f => (a -> f a) -> Complex a -> f (Complex a) _ Access the  imaginaryPart of a  number D imaginary :: Functor f => (a -> f a) -> Complex a -> f (Complex a) `This isn't quite a legal lens. Notably the    l ( l b a) = blaw is violated when you set a  value with 0  and non-zero   as the  information is lost. So don' t do that! )Otherwise, this is a perfectly cromulent . a0Traverse both the real and imaginary parts of a  number. N traverseComplex :: Applicative f => (a -> f b) -> Complex a -> f (Complex b) ^_`a^_`a^_`a^_`a" Rank2Types experimentalEdward Kmett <ekmett@gmail.com> TrustworthybLA generic applicative transformation that maps over the immediate subterms. b is to  what  is to  This really belongs in  Data.Data. cNave  using 3. This does not attempt to optimize the traversal. ZThis is primarily useful when the children are immediately obvious, and for benchmarking.   c :: ( a,  b) =>   a b d%Find every occurence of a given type b recursively that doesn' t require # passing through something of type b using , while avoiding traversal . of areas that cannot contain a value of type b. This is e with a more liberal signature. eFind descendants of type aU non-transitively, while avoiding computation of areas that cannot contain values of  type a using . e$ is a useful default definition for  ff performs like d, except when a ~ b&, it returns itself and nothing else.  inlineable  %bcdef     bcdefdcefbbcdef     #portable provisionalEdward Kmett <ekmett@gmail.com>Noneg(Traverse the typed value contained in a 7 where the type required by your function matches that  of the contents of the . b traverseDynamic :: (Applicative f, Typeable a, Typeable b) => (a -> f b) -> Dynamic -> f Dynamic gggg$portable provisionalEdward Kmett <ekmett@gmail.com>Noneh IntSet isn't Foldable, but this Y) can be used to access the members of an . &sumOf members $ setOf folded [1,2,3,4]10iThis * can be used to change the contents of an  by mapping  the elements to new values. Sadly, you can't create a valid  for a Set, because the number of B elements might change but you can manipulate it by reading using [ and  reindexing it via setmap. (over setmapped (+1) (fromList [1,2,3,4])fromList [2,3,4,5]j Construct an  from a , Y, ,  or -. ":m + Data.IntSet.Lens Control.Lens5setOf (folded._2) [("hello",1),("world",2),("!!!",3)]fromList [1,2,3]   setOf ::  a  -> a ->   setOf :: Y a  -> a ->   setOf ::  - a  -> a ->   setOf ::   a  -> a ->   setOf ::   a  -> a ->  hijhijhijhij% Rank2Types experimentalEdward Kmett <ekmett@gmail.com>None k,Modify the target of a monoidally valued by ing another value. :m + Control.Lens"both <>~ "!!!" $ ("hello","world")("hello!!!","world!!!")   (k) ::  c =>  a b c c -> c -> a -> b  (k) ::  c => - a b c c -> c -> a -> b  (k) ::  c =>  a b c c -> c -> a -> b  (k) ::  c =>  a b c c -> c -> a -> b lModify the target(s) of a  , -,  or  by  ing a value.   (l) :: ( a m,  b) =>   a b -> b -> m ()  (l) :: ( a m,  b) =>  - a b -> b -> m ()  (l) :: ( a m,  b) =>   a b -> b -> m ()  (l) :: ( a m,  b) =>   a b -> b -> m () m2 a monoidal value onto the end of the target of a  and  return the result 3When you do not need the result of the operation, (k) is more flexible. n2 a monoidal value onto the end of the target of a  into  your monad's state and return the result. 3When you do not need the result of the operation, (l) is more flexible. oIsomorphism for  pIsomorphism for  qIsomorphism for  0:m + Control.Lens Data.Monoid.Lens Data.Foldableala _all foldMap [True,True]True0:m + Control.Lens Data.Monoid.Lens Data.Foldableala _all foldMap [True,False]FalserIsomorphism for  0:m + Control.Lens Data.Monoid.Lens Data.Foldableala _any foldMap [False,False]False0:m + Control.Lens Data.Monoid.Lens Data.Foldableala _any foldMap [True,False]TruesIsomorphism for  0:m + Control.Lens Data.Monoid.Lens Data.Foldableala _sum foldMap [1,2,3,4]10tIsomorphism for  0:m + Control.Lens Data.Monoid.Lens Data.Foldableala _product foldMap [1,2,3,4]24uIsomorphism for  vIsomorphism for  klmnopqrstuv klmnopqrstuv kmlnopqrstuv klmnopqrstuv&portable provisionalEdward Kmett <ekmett@gmail.com>None wA  that can access the nth element of a . ENote: This is only a legal lens if there is already such an element! xA  is isomorphic to a   m = m # xyA  is isomorphic to a    m = m # yzTraverse the head of a  {Traverse the tail of a  |Traverse the last element of a  }'Traverse all but the last element of a  ~Traverse the first n elements of a  Traverse all but the first n elements of a  'Travere all the elements numbered from i to j of a  wx!y"z{|}~ wxyz{|}~ wxyz{|}~ wx!y"z{|}~'portable provisionalEdward Kmett <ekmett@gmail.com>None# (or $ ) strict %.   # x = x #   $ x = x #   -Traverse the individual characters in strict %. $anyOf text (=='o') $ "hello"^.packedTrue(portable provisionalEdward Kmett <ekmett@gmail.com>NonePack (or unpack) lazy &.   ' x = x #   ( x = x #   (Traverse the individual characters in a &. $ anyOf text (=='c') :: Text -> Bool )portable provisionalEdward Kmett <ekmett@gmail.com>NoneTraversals for strict or lazy % ' (or () strict or lazy %.   ' x = x #   ( x = x #   5Traverse the individual characters in strict or lazy %. )*)**MTPCs provisionalEdward Kmett <ekmett@gmail.com>NoneA  that focuses on the root of a +. A , of the direct descendants of the root of a + 1 indexed by its position in the list of children + Rank2Types experimentalEdward Kmett <ekmett@gmail.com>NoneA   for working with a , of a  value. A   for working with a - of a  value. ,&MPTCs, Rank2Types, LiberalTypeSynonyms provisionalEdward Kmett <ekmett@gmail.com>NoneAccess an element of an array. <Note: The indexed element is assumed to exist in the target ..    arr / i "a arr #  i  arr 0 [(i,e)] "a  i  e  arr :ix 2 .~ 9 $ (listArray (1,5) [4,5,6,7,8] :: Array Int Int)+array (1,5) [(1,4),(2,9),(3,6),(4,7),(5,8)](This setter can be used to derive a new . from an old array by E applying a function to each of the indices to look it up in the old ..  This is a  contravariant .   1 "a  .    "a  . 1   ( b) f arr / i "a arr / f i  2 ( ( b) f arr) "a b An  of the elements of an . , using the 5 index into the array as the index of the traversal. 3 "a  - Rank2Types experimentalEdward Kmett <ekmett@gmail.com>None (Modify the path by adding another path. :m + Control.Lens#both </>~ "!!!" $ ("hello","world")("hello/!!!","world/!!!")   () ::  a b 4 4 -> 4 -> a -> b  () :: - a b 4 4 -> 4 -> a -> b  () ::  a b 4 4 -> 4 -> a -> b  () ::  a b 4 4 -> 4 -> a -> b Modify the target(s) of a  , -,  or  by adding a path.   () ::  a m =>   a 4 -> 4 -> m ()  () ::  a m =>  - a 4 -> 4 -> m ()  () ::  a m =>   a 4 -> 4 -> m ()  () ::  a m =>   a 4 -> 4 -> m () +Add a path onto the end of the target of a  and return the result 3When you do not need the result of the operation, () is more flexible. +Add a path onto the end of the target of a  into  your monad's state and return the result. 3When you do not need the result of the operation, () is more flexible. %Modify the path by adding extension. :m + Control.Lens#both <.>~ "!!!" $ ("hello","world")("hello.!!!","world.!!!")   () ::  a b 4 4 -> 5 -> a -> b  () :: - a b 4 4 -> 5 -> a -> b  () ::  a b 4 4 -> 5 -> a -> b  () ::  a b 4 4 -> 5 -> a -> b Modify the target(s) of a  , -,  or  by adding an extension.   () ::  a m =>   a 4 -> 5 -> m ()  () ::  a m =>  - a 4 -> 5 -> m ()  () ::  a m =>   a 4 -> 5 -> m ()  () ::  a m =>   a 4 -> 5 -> m () 1Add an extension onto the end of the target of a  and return the result 3When you do not need the result of the operation, () is more flexible. 1Add an extension onto the end of the target of a  into  your monad's state and return the result. 3When you do not need the result of the operation, () is more flexible. ,A lens reading and writing to the basename. (basename .~ "filename" $ "path/name.png""path/filename.png"-A lens reading and writing to the directory. !"long/path/name.txt" ^. directory "long/path"-A lens reading and writing to the extension. %extension .~ ".png" $ "path/name.txt""path/name.png"1A lens reading and writing to the full filename. (filename .~ "name.txt" $ "path/name.png""path/name.txt"    .portable provisionalEdward Kmett <ekmett@gmail.com>NoneEvaluate the targets of a  or  into a data structure  according to the given 6.    7 =   =    =      ::   a b -> 6 b -> 6 a   ::   a b -> 6 b -> 6 a   :: (b -> 8 b) -> a -> 8 a) -> 6 b -> 6 a Evaluate the targets of a  or  according into a % data structure according to a given 6 in parallel.  9 =      ::   a b -> 6 b -> 6 a   ::   a b -> 6 b -> 6 a   :: ((b -> 8 b) -> a -> 8 a) -> 6 b -> 6 a  Transform a , Y, ,  or  to 3 first evaluates its argument according to a given 6 before proceeding.    :  ::  t => 6 a -> 6 [a]  Transform a , Y, ,  or  to , evaluate its argument according to a given 6 in parallel with evaluating.    :  ::  t => 6 a -> 6 [a] /portable provisionalEdward Kmett <ekmett@gmail.com>None$Evaluate the elements targeted by a , , -,   or Y" according to the given strategy. ; =  [<0     ;R !"#$%&'()*+,-./012<3456789:;<=>?@ABCDEFGHIJKLM N O P Q R S T U x N V W X Y Z [ \ P ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y y M z { | } ~              v                   1^cdfeghijklmnopqsrut_2]Q>?OLwz{|}8~563     4 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwwxyz{|}~[     !!X!!"""""#$$$%%%%%%%%%%%%&&&&[&&&&&&''(()))**++,,,------------..../      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHFGIJKLMLNOPQRSQTU V W X Y Z [\]^_` ab c d e f g h i j k l m n o p q r s t u v w x y z { | } ~                     WFQQIKASacUVJQ7^ca      !"#$%&'()*+,-./0/123242526789:;<=>?@<A> B CYDYZYEYFYGHISHJ"KLM"N"O"O"P"Q"R"S"T"U"U"V"W"W"X"Y"Z"["\"]"^"_"`"a"b"c"d"e"f"g"h"ijklmnopqrstuvwxwywzw{w|&}&~))Llens-2.8Control.Lens.TraversalControl.Lens.IsomorphicControl.Lens.InternalControl.Lens.IndexedControl.Lens.IndexedGetterControl.Lens.ActionControl.Lens.CombinatorsControl.Lens.TypeControl.Lens.IndexedLensControl.Lens.IndexedFoldControl.Lens.IndexedTraversalControl.Lens.IndexedSetterControl.Lens.TupleControl.Lens.SetterControl.Lens.GetterControl.Lens.Iso Data.Set.LensControl.Lens.RepresentableControl.Lens.ZoomData.HashSet.LensControl.Lens.FoldLanguage.Haskell.TH.LensControl.Lens.PlatedControl.Lens.WithIndexControl.Lens.THGHC.Generics.LensControl.Exception.LensData.Bits.LensData.List.LensData.ByteString.Strict.LensData.ByteString.Lazy.LensData.ByteString.LensData.Complex.LensData.Data.LensData.Dynamic.LensData.IntSet.LensData.Monoid.LensData.Sequence.LensData.Text.Strict.LensData.Text.Lazy.LensData.Text.LensData.Tree.LensData.Typeable.LensData.Array.LensSystem.FilePath.Lens Control.Parallel.Strategies.LensControl.Seq.LensSettableSetterGetter Traversalelement maximumOf minimumOfmapM_ traverseOf_Control.Monad.Trans.State.LazyStateindexedLenscloneZoomzoomControl.Monad.ErrorErrorTControl.Monad.Trans.MaybeMaybeTControl.Monad.Trans.ListListTControl.Monad.WriterWriterTControl.Monad.RWSRWSTControl.Monad.StateStateT backwardsIndexedTraversal IndexedLensFold IndexedFoldIso IndexedGetter Control.Monadjoin Data.Functor<$><$ imaginary Data.ComplexComplex traverseHeadControl.Lens.LensviewsetGettingData.Functor.Compose getComposeCompose%~+~-~*~//~^~^^~**~||~&&~%=+=-=*=//=**=^^=||=&&=%@~ foldMapOfSimpleIndexedLensSimpleIndexedTraversalfoldrOffoldlOfanyOfallOfforOf_mapMOf_forMOf_ concatMapOffindOffoldrOf'foldlOf'foldrMOffoldlMOftoListOf traverseOfforOfmapMOfforMOf mapAccumROf mapAccumLOfmapOfoverData.Traversabletraverse Traversable Data.MonoidMonoidSimpleData.Text.InternalTextData.Functor.IdentityIdentity fmapDefaultData.Distributive distribute DistributiveControl.Monad.Reader.ClasslocalPreludeunfoldr Data.FoldablefoldMapfoldfoldrfoldltoListandoranyallproductsum traverse_Data.Either.Lens traverseLeftfor_forM_ sequence_ maximumByfoldr1foldl1Offoldl1foldr'foldl'foldrMfoldlM Data.List transposeuniplatebiplate Data.Just isNothing mapAccumR Control.Lens<>~<>=<<>~<<>=Data.ByteStringpackunpackData.ByteString.Char8Data.ByteString.LazyData.ByteString.Lazy.Char8Control.Platedplatebase Isomorphism Isomorphic isomorphicisomapfromviaMutator runMutator untaintedFolding getFolding Effective effectiveAccessor runAccessorGettablecoerce EffectRWS getEffectRWSEffect getEffectBazaar _runBazaar ElementOf getElementOfElementOfResultNotFoundFound SearchingMaxNoMaxMinNoMin Sequenced getSequenced Traversed getTraversedIndexing runIndexingIndexingResultContext FocusingErr unfocusingErrErrgetErr FocusingMay unfocusingMayMaygetMay FocusingOn unfocusingOn FocusingPlusunfocusingPlus FocusingWithunfocusingWithFocusing unfocusinggetMingetMaxbazaarduplicateBazaarsell ineffectivenoEffectIndex withIndex IndexableIndexedindex<..>reindex<.>icomposeReifiedIndexedGetterReifyIndexedGetterreflectIndexedGetterIndexedGettingActing MonadicFoldActionperform^!actactsliftAct|><$!><$!SimpleReifiedLens ReifiedLens ReifyLens reflectLensSimpleOverloaded OverloadedLensLikeSimpleLensLike SimpleLenslens%%~%%=resultAtmerged alongside cloneLens<%~<+~<-~<*~~=<~<=<.>~<.>=<<.>~<<.>=basename directory extensionfilenameevalOfparOfafter throughoutseqOfControl.CategoryCategory.$fIsomorphicIsomorphism$fCategoryIsomorphism$fIsomorphic(->)transformers-0.3.0.0GHC.BaseFunctorControl.Applicative ApplicativeConstidfmapghc-prim GHC.TypesInt Data.EitherEither Data.MaybeMaybecomonad-3.0.0.2Control.ComonadComonadmempty$fSettableBackwards$fSettableIdentity$fGettableElementOf$fApplicativeMutator$fFunctorMutator$fSettableMutator$fSettableCompose$fMonoidFolding$fEffectivemrEffect$fEffectivemDualBackwards$fEffectiveIdentityrAccessor$fApplicativeAccessor$fFunctorAccessor$fGettableAccessor$fGettableEffectRWS$fGettableEffect$fGettableCompose$fGettableBackwards$fGettableConst$fApplicativeEffectRWS$fFunctorEffectRWS$fApplicativeEffect$fMonoidEffect$fFunctorEffect$fComonadApplyBazaar$fComonadBazaar$fApplicativeBazaar$fFunctorBazaar$fApplicativeElementOf$fFunctorElementOf$fFunctorElementOfResult $fMonoidMax $fMonoidMin$fMonoidSequenced$fMonoidTraversed$fGettableIndexing$fApplicativeIndexing$fFunctorIndexing$fFunctorIndexingResult$fComonadStorecContext$fComonadContext$fFunctorContext$fApplicativeFocusingErr$fFunctorFocusingErr $fMonoidErr$fApplicativeFocusingMay$fFunctorFocusingMay $fMonoidMay$fApplicativeFocusingOn$fFunctorFocusingOn$fApplicativeFocusingPlus$fFunctorFocusingPlus$fApplicativeFocusingWith$fFunctorFocusingWith$fApplicativeFocusing$fFunctorFocusing$fIndexediIndex$fIndexedi(->)Monad$pure mtl-2.1.2Control.Monad.State.Classstate MonadStateGHC.NumNumGHC.Real FractionalIntegral GHC.FloatFloating GHC.Classes||Bool&&const$fContainskHashSet$fContainskSet$fContainsIntIntSet $fAtkHashMap$fAtkMap $fAtIntIntMapflipNothingmap Data.Tuplefstskip mapAccumLswap$fTraverseMaxkMap$fTraverseMaxIntIntMap$fTraverseMinkMap$fTraverseMinIntIntMap$fField9(,,,,,,,,)(,,,,,,,,)ii'$fField8(,,,,,,,,)(,,,,,,,,)hh'$fField8(,,,,,,,)(,,,,,,,)hh'$fField7(,,,,,,,,)(,,,,,,,,)gg'$fField7(,,,,,,,)(,,,,,,,)gg'$fField7(,,,,,,)(,,,,,,)gg'$fField6(,,,,,,,,)(,,,,,,,,)ff'$fField6(,,,,,,,)(,,,,,,,)ff'$fField6(,,,,,,)(,,,,,,)ff'$fField6(,,,,,)(,,,,,)ff'$fField5(,,,,,,,,)(,,,,,,,,)ee'$fField5(,,,,,,,)(,,,,,,,)ee'$fField5(,,,,,,)(,,,,,,)ee'$fField5(,,,,,)(,,,,,)ee'$fField5(,,,,)(,,,,)ee'$fField4(,,,,,,,,)(,,,,,,,,)dd'$fField4(,,,,,,,)(,,,,,,,)dd'$fField4(,,,,,,)(,,,,,,)dd'$fField4(,,,,,)(,,,,,)dd'$fField4(,,,,)(,,,,)dd'$fField4(,,,)(,,,)dd'$fField3(,,,,,,,,)(,,,,,,,,)cc'$fField3(,,,,,,,)(,,,,,,,)cc'$fField3(,,,,,,)(,,,,,,)cc'$fField3(,,,,,)(,,,,,)cc'$fField3(,,,,)(,,,,)cc'$fField3(,,,)(,,,)cc'$fField3(,,)(,,)cc'$fField2(,,,,,,,,)(,,,,,,,,)bb'$fField2(,,,,,,,)(,,,,,,,)bb'$fField2(,,,,,,)(,,,,,,)bb'$fField2(,,,,,)(,,,,,)bb'$fField2(,,,,)(,,,,)bb'$fField2(,,,)(,,,)bb'$fField2(,,)(,,)bb'$fField2(,)(,)bb'$fField1(,,,,,,,,)(,,,,,,,,)aa'$fField1(,,,,,,,)(,,,,,,,)aa'$fField1(,,,,,,)(,,,,,,)aa'$fField1(,,,,,)(,,,,,)aa'$fField1(,,,,)(,,,,)aa'$fField1(,,,)(,,,)aa'$fField1(,,)(,,)aa'$fField1(,)(,)aa'Char MonadReadercontainers-0.5.0.0 Data.Set.BaseSetOrdreturn<*>>>=mapMFoldable$fRepresentable(->)Eq$fRepresentableIdentityControl.Monad.Trans.RWS.Strict Control.Monad.Trans.State.StrictControl.Monad.Trans.Error$fMagnify(->)(->)Accessorba$fMagnifyIdentityTIdentityTkba$fMagnifyRWSTRWSTEffectRWSba$fMagnifyRWSTRWSTEffectRWSba0$fMagnifyReaderTReaderTEffectba$fZoomErrorTErrorTFocusingErrst$fZoomMaybeTMaybeTFocusingMayst$fZoomListTListTFocusingOnst"$fZoomWriterTWriterTFocusingPlusst#$fZoomWriterTWriterTFocusingPlusst0$fZoomRWSTRWSTFocusingWithst$fZoomRWSTRWSTFocusingWithst0$fZoomIdentityTIdentityTkst$fZoomReaderTReaderTkst$fZoomStateTStateTFocusingst$fZoomStateTStateTFocusingst0unordered-containers-0.2.2.1 Data.HashSetHashSethashable-1.1.2.5 Data.HashableHashableGHC.Listrepeat replicateiterate takeWhile dropWhileTrue sequenceA_asum Alternativemsum MonadPluselemnotElem concatMapconcatlengthheadJust listToMaybelastFalsenullmaximum fromMaybeGHC.ErrerrorminimumOrdering minimumByfor sequenceAforMsequence unwrapMonad WrapMonadscanr1scanl1template-haskellLanguage.Haskell.TH.SyntaxnewNameName$fSubstTypePred $fSubstType[]$fSubstTypeType$fHasTypeVars[]$fHasTypeVarsPred$fHasTypeVarsType$fHasTypeVarsName$fHasTypeVarsTyVarBndr $fHasNameCon $fHasNameName$fHasNameTyVarBndrGHC.ShowShowGHC.ReadReadnegate==OutwithOutinsouts unsafeOuts$fApplicativeOut $fFunctorOut $fPlatedTree $fPlated[]Data.IntMap.Base Data.Map.Basefind$fFunctorWithIndexIntSeq$fFunctorWithIndexInt[]$fTraversableWithIndexkHashMap$fFoldableWithIndexkHashMap$fFunctorWithIndexkHashMap$fTraversableWithIndexkMap$fFoldableWithIndexkMap$fFunctorWithIndexkMap$fTraversableWithIndexIntIntMap$fFoldableWithIndexIntIntMap$fFunctorWithIndexIntIntMap$fTraversableWithIndexIntSeq$fFoldableWithIndexIntSeq$fTraversableWithIndexInt[]$fFoldableWithIndexInt[]freshMap makeIsoLenses getLensFields_lensIso _lensField _lensClass _lensFlags makeIsoTo makeIsoFrom makeIsoBody makeLensBodyplainappArgsappsappsTmakeFieldLensBodymakeFieldLenses unifyTypes GHC.GenericsGenericData.Typeable.InternalTypeable tinplated maybeArg1Of$fGTraversal:.:$fGTraversalM1$fGTraversal:+:$fGTraversal:*:$fGTraversalU1$fGTraversalK1 GHC.Exception Exception SomeException Data.Bits.|.Bits.&.bitSize undefined integer-gmpGHC.Integer.TypeInteger++bytestring-0.10.0.0Data.ByteString.Internal ByteStringGHC.WordWord8Data.ByteString.Lazy.Internal$fIsByteStringByteString$fIsByteStringByteString0realPartpolar magnitudephase Data.DatagmapMDatainlinePerformIOGHC.IOunsafePerformIOFollowerOracle fromOracleAnswerMissFollowHitCacheHitMapDataBox dataBoxKey _dataBoxValstepdataBox sybChildren emptyHitMap insertHitMapfixEqcachereadCacheFollowerinsert2hitTest biplateData uniplateDatapartfollower$fFunctorOracle$fFunctorAnswer Data.DynamicDynamicData.IntSet.BaseIntSetmappendDualEndoAllAnySumProductFirstLast Data.SequenceSeqViewLviewlViewRviewrunviewlunviewr text-0.11.2.3 Data.TextData.Text.Lazy.InternalData.Text.Lazy $fIsTextText $fIsTextText0 Data.TreeTree Data.Typeablecastgcast array-0.4.0.1Data.Array.BaseIArray!//ixmapboundsamapFilePathStringparallel-3.2.0.3Control.Parallel.StrategiesStrategyevalTraversableEvalparTraversablerdeepseq Control.Seq seqFoldable