ʕ      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMN O P Q R S!T!U!V!W"X"Y"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){)|*}*~*++,,---............////01 Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered'A concrete data type for isomorphisms. DThis lets you place an isomorphism inside a container without using ImpredicativeTypes. 7Used to provide overloading of isomorphism application  This is a ) with a canonical mapping to it from the . category of isomorphisms over Haskell types. *Build this morphism out of an isomorphism The intention is that by using #, you can supply both halves of an + 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     from (from l) = l If you imported  from Control.Category, then:  from l . from r = from (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> Safe-Infered%   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 (1 )#when the user attempts to misuse a 2 as a  Getter., 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 Setter, 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> Safe-Infered 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 ::  Traversal a b c d -> IndexedTraversal  a b c d  e :: Lens a b c d ->  IndexedLens  a b c d  e :: Fold a b ->  IndexedFold  a b  e :: Iso a b c d ->  IndexedLens  a b c d  e :: Getter a b ->  IndexedGetter  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> Safe-InferedfUseful for storage. iUsed to consume an  M. jEvery j is a valid  M and Getter. fghijfghijjifghfghijMTPCs, FDs, Rank2 experimentalEdward Kmett <ekmett@gmail.com> Safe-InferedkUsed 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 NO.  q = p import Control.Lens(1,"hello")^!_2.acts.to succ"ifmmp"rApply a  transformer to an m. klmnopqrklmnopqrmpqnrolkklmnopqr Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered$s type s = | tt)Useful for storing lenses in containers. w type w k f a b = | (x k f) a bx type y f a b c d = x (->) f a b c dyMany 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 y 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. z type z f = | (y f){ type { = | }|A | }, | 3 , ... can  be used instead of a },3, ...  whenever the type variables don't change upon setting a value.    !P :: | } (QR a) a  S :: | T3 [a] a .Note: To use this alias in your own code with y f or  2, 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:  U l (V l b a) = b"2) Putting back what you got doesn't change anything:  V l (U l a) a = a.3) Setting twice is the same as setting once:  V l c (V l b a) = V 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 W as if it were a  X or Y. Since every lens is a valid 3, the < traversal laws should also apply to any lenses you create.    l  =    (l f) . l g = Z[ . l (Z\ .  f . g)  type } a b c d = forall f.  f => y f a b c d~Build a } from a getter and a setter. J lens :: Functor 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:  () =    () ::  f => ]) 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)   () :: ]/ 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.  () = ( )It may be useful to think of ($), instead, as having either of the , following more restricted type signatures:   () ::  a m => ]& 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 }. "/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, (^) is more flexible. -Increment the target of a numerically valued } and return the result 2When you do not need the result of the addition, (_) is more flexible. -Decrement the target of a numerically valued } and return the result 5When you do not need the result of the subtraction, (`) is more flexible. ,Multiply the target of a numerically valued } and return the result 8When you do not need the result of the multiplication, (a ) is more  flexible. +Divide the target of a fractionally valued } and return the result. 2When you do not need the result of the division, (b) is more flexible. )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, (c) is more flexible. *Raise the target of a fractionally valued } to an  power  and return the result. 2When you do not need the result of the division, (d) is more flexible. ,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, (e) is more flexible.  Logically  a Boolean valued } and return the result 3When you do not need the result of the operation, (f) is more flexible.  Logically  a Boolean valued } and return the result 3When you do not need the result of the operation, (g) is more flexible. Modify the target of a } into your monad's state by a user supplied ! function and return the result. 3When you do not need the result of the operation, (h) is more flexible. *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, (i ) is more  flexible. 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, (j ) is more  flexible. ,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, (k ) is more  flexible. +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, (l) is more flexible. )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, (m) is more flexible. *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, (n) is more flexible. ,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, (m) is more flexible.  Logically  a Boolean valued } into your monad's state and return  the result. 3When you do not need the result of the operation, (o) is more flexible.  Logically  a Boolean valued } into your monad's state and return  the result. 3When you do not need the result of the operation, (p) is more flexible. &stuvwxyz{|}~&stuvwxyz{|}~&}|~tuvyx{zws$stuvwxyz{|}~"rank 2 types, MPTCs, TFs, flexible provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered 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  q. Adjust the target of an ' returning the intermediate result, or ! adjust all of the targets of an  q 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 (r ) or even (^).   (\<%\@~) :: + i a b c d -> (i -> c -> d) -> a -> (d, b)  (\<%\@~) :: Monoid d =>  q+ 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  q 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 =>  q* 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 =>  q0 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  q 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) =>  q- 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  q 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) =>  q( i a a c d -> (i -> c -> d) -> a -> m d  "rank 2 types, MPTCs, TFs, flexible provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedUseful for storage. Every  is a valid X. Fold an  or  q/ by mapping indices and values to an arbitrary  with access  to the index i.  When you don' t need access to the index then s& is more flexible in what it accepts.  s l =  l .     :: j+ i a c -> (i -> c -> m) -> a -> m   ::  m => - i a c -> (i -> c -> m) -> a -> m   :: t' i a c -> (i -> c -> m) -> a -> m   ::  m =>  u" i a c -> (i -> c -> m) -> a -> m JRight-associative fold of parts of a structure that are viewed through an  or  q with  access to the index i.  When you don' t need access to the index then v& is more flexible in what it accepts.  v l =  l .     :: j5 i a c -> (i -> c -> e -> e) -> e -> a -> e   :: 7 i a c -> (i -> c -> e -> e) -> e -> a -> e   :: t1 i a c -> (i -> c -> e -> e) -> e -> a -> e   ::  u, 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  q 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 =  l .     :: j5 i a c -> (i -> e -> c -> e) -> e -> a -> e   :: 7 i a c -> (i -> e -> c -> e) -> e -> a -> e   :: t1 i a c -> (i -> e -> c -> e) -> e -> a -> e   ::  u, i a c -> (i -> e -> c -> e) -> e -> a -> e 4Return whether or not any element viewed through an  or  q / satisfy a predicate, with access to the index i.  When you don' t need access to the index then x& is more flexible in what it accepts.  x l =  l .     :: j i a c -> (i -> c ->  ) -> a ->    ::  i a c -> (i -> c ->  ) -> a ->    :: t i a c -> (i -> c ->  ) -> a ->    ::  u i a c -> (i -> c ->  ) -> a ->  5Return whether or not all elements viewed through an  or  q / satisfy a predicate, with access to the index i.  When you don' t need access to the index then y& is more flexible in what it accepts.  y l =  l .     :: j i a c -> (i -> c ->  ) -> a ->    ::  i a c -> (i -> c ->  ) -> a ->    :: t i a c -> (i -> c ->  ) -> a ->    ::  u i a c -> (i -> c ->  ) -> a ->  Traverse the targets of an  or  q 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 =  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 => t, i a c -> (i -> c -> f e) -> a -> f ()   ::  f =>  u' i a c -> (i -> c -> f e) -> a -> f () Traverse the targets of an  or  q2 with access to the index, discarding the results  (with the arguments flipped).   =  .  When you don' t need access to the index then z& is more flexible in what it accepts.  z l 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 => t, i a c -> a -> (i -> c -> f e) -> f ()   ::  f =>  u' i a c -> a -> (i -> c -> f e) -> f () *Run monadic actions for each target of an  or  q 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 = 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 => t, i a c -> (i -> c -> m e) -> a -> m ()   ::  m =>  u' i a c -> (i -> c -> m e) -> a -> m () *Run monadic actions for each target of an  or  q with access to the index, 6 discarding the results (with the arguments flipped).   =  .  When you don' t need access to the index then |& is more flexible in what it accepts.  | l 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 => t, i a c -> a -> (i -> c -> m e) -> m ()   ::  m =>  u' i a c -> a -> (i -> c -> m e) -> m () <Concatenate the results of a function of the elements of an  or  q  with access to the index.  When you don' t need access to the index then }' is more flexible in what it accepts.    } l =  l .    =      :: j i a c -> (i -> c -> [e] ) -> a -> [e]   :: " i a c -> (i -> c -> [e] ) -> a -> [e]   :: t i a c -> (i -> c -> [e] ) -> a -> [e]   ::  u i a c -> (i -> c -> [e] ) -> a -> [e] The findOf function takes an  or  q, 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 =  l .     :: j a c -> (i -> c ->  ) -> a ->  (i, c)   ::  a c -> (i -> c ->  ) -> a ->  (i, c)   :: t a c -> (i -> c ->  ) -> a ->  (i, c)   ::  u 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 =  l .     :: j5 i a c -> (i -> c -> e -> e) -> e -> a -> e   :: 7 i a c -> (i -> c -> e -> e) -> e -> a -> e   :: t1 i a c -> (i -> c -> e -> e) -> e -> a -> e   ::  u, 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 =  l .     :: j7 i a c -> (i -> e -> c -> e) -> e -> a -> e   :: 9 i a c -> (i -> e -> c -> e) -> e -> a -> e   :: t3 i a c -> (i -> e -> c -> e) -> e -> a -> e   ::  u. 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 =  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 => t3 i a c -> (i -> c -> e -> m e) -> e -> a -> e   ::  m =>  u. 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 =  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 => t5 i a c -> (i -> e -> c -> m e) -> e -> a -> e   ::  m =>  u0 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 =   .  l    :: j i a c -> a -> [(i,c)]   ::  i a c -> a -> [(i,c)]   :: t i a c -> a -> [(i,c)]   ::  u 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 , j,  or  q.  Obtain an ! by taking elements from another , , j or  q while a predicate holds.  Obtain an # by dropping elements from another , , j or  q while a predicate holds.  "rank 2 types, MPTCs, TFs, flexible provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered type  i = | ( i)Useful for storage. type  i = | ( i)#Every indexed traversal is a valid 3 or  M. 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!     = \   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 =  l 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 =  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 =  l 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 =  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 =  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.    Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered0Traverse the value at the minimum key in a Map. KThe key of the minimum element is available as the index of the traversal. 0Traverse the value at the maximum key in a Map. KThe key of the maximum element is available as the index of the traversal.  "rank 2 types, MPTCs, TFs, flexible provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered type  i = | ( i)Useful for storage. type  i = | ( i)Every  is a valid Setter The 2" 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 =  l .     :: ) i a b c d -> (i -> c -> d) -> a -> b   :: + i a b c d -> (i -> c -> d) -> a -> b   ::  q& 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 =  l .     :: ) i a b c d -> (i -> c -> d) -> a -> b   :: + i a b c d -> (i -> c -> d) -> a -> b   ::  q& 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  =   f g  f h = f (g  h) Equational reasoning:     .  =    .  =  Another way to view sets is that it takes a "semantic editor combinator"  and transforms it into a Setter. Adjust every target of an ,  or  q  with access to the index.  () = /When you do not need access to the index then ()) is more liberal in what it can accept.  l ^ f = l   f   () :: ) i a b c d -> (i -> c -> d) -> a -> b  () :: + i a b c d -> (i -> c -> d) -> a -> b  () ::  q& i a b c d -> (i -> c -> d) -> a -> b /Adjust every target in the current state of an ,  or  q  with access to the index. /When you do not need access to the index then (%=)) is more liberal in what it can accept.  l h f = l   f   () ::  a m => ' i a a c d -> (i -> c -> d) -> m ()  () ::  a m => ) i a a c d -> (i -> c -> d) -> m ()  () ::  a m =>  q$ i a b c d -> (i -> c -> d) -> m ()    Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered,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)   x  :: (c -> ) -> (a, c) ->      :: ( Applicative f, . t) => (a -> f b) -> t (c, a) -> f (t (c, b))  s (  ) :: ( 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' >      !"#$5      !"#$ Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered% 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. NThese are particularly common when talking about monomorphic containers. e.g.   Data.Text.map ::   % 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 Identity, we get nicer error messages.  The only <-like law that can apply to a  l is that   l c ( l b 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  =    l f .  l g =  l (f . g) "These an be stated more directly:    l  =   l f .   . l g = 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 .    =     =    (&) =   )Build a Setter from a map-like function. Your supplied function f is required to satisfy:    f  =   f g  f h = f (g  h) Equational reasoning:     .  =    .  =  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.     =     =     .  =    .  =  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.     =    =     fmapDefault =  traverse   .  =    .  =      :: $ a b c d -> (c -> d) -> a -> b   :: ]' 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.  (&) =  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   :: ] 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 =   f   f = traverse  f import Control.Lens_2 %~ length $ (1,"hello")(1,5)   () :: " a b c d -> (c -> d) -> a -> b  () :: ]% 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 & a =   f ' aimport Control.Lens_1 .~ "hello" $ (42,"world")("hello","world")   () ::  a b c d -> d -> a -> b  () :: ] 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.   () ::  a b c d -> d -> a -> (d, b)  () :: ]# 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)   () :: Num c =>  a b c c -> c -> a -> b  () :: Num c => ] a b c c -> c -> a -> b  () :: Num c => < a b c c -> c -> a -> b  () :: Num c => 3 a b c c -> c -> a -> b /Multiply the target(s) of a numerically valued <, ],  or 3 import Control.Lens_2 *~ 4 $ (1,2)(1,8)   () :: ( c =>  a b c c -> c -> a -> b  () :: ( c => ] a b c c -> c -> a -> b  () :: ( c => < a b c c -> c -> a -> b  () :: ( c => 3 a b c c -> c -> a -> b 0Decrement the target(s) of a numerically valued <, ],  or 3 import Control.Lens_1 -~ 2 $ (1,2)(-1,2)   (-~) :: ( c =>  a b c c -> c -> a -> b  (-~) :: ( c => ] a b c c -> c -> a -> b  (-~) :: ( c => < a b c c -> c -> a -> b  (-~) :: ( c => 3 a b c c -> c -> a -> b -Divide the target(s) of a numerically valued <, ],  or 3   (\/\/~) :: ) c =>  a b c c -> c -> a -> b  (\/\/~) :: ) c => ] a b c c -> c -> a -> b  (\/\/~) :: ) c => < a b c c -> c -> a -> b  (\/\/~) :: ) c => 3 a b c c -> c -> a -> b ,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)-Raise the target(s) of a fractionally valued <,  or 3 to an integral power import Control.Lens_2 ^^~ (-1) $ (1,2)(1,0.5)   () :: () c,  e) =>  a b c c -> e -> a -> b  () :: () c,  e) => ] a b c c -> e -> a -> b  () :: () c,  e) => < a b c c -> e -> a -> b  () :: () c,  e) => 3 a b c c -> e -> a -> b /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)   () :: * c =>  a b c c -> c -> a -> b  () :: * c => ] a b c c -> c -> a -> b  () :: * c => < a b c c -> c -> a -> b  () :: * c => 3 a b c c -> c -> a -> b  Logically  the target(s) of a -valued < or  :m + Control.Lensboth ||~ True $ (False,True) (True,True)both ||~ False $ (False,True) (False,True)   () ::  a b   ->  -> a -> b  () :: ] a b   ->  -> a -> b  () :: < a b   ->  -> a -> b  () :: 3 a b   ->  -> a -> b  Logically  the target(s) of a -valued < or  :m + Control.Lensboth &&~ True $ (False, True) (False,True)both &&~ False $ (False, True) (False,False)   () ::  a b   ->  -> a -> b  () :: ] a b   ->  -> a -> b  () :: < a b   ->  -> a -> b  () :: 3 a b   ->  -> a -> b 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 => ]" a a c d -> d -> m ()   ::  a m => <! a a c d -> d -> m ()   ::  a m => 3 a a c d -> d -> m ()   ::  a m =>  a a c d -> d -> 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 => ]" a a c d -> d -> m ()  () ::  a m => <! a a c d -> d -> m ()  () ::  a m => 3 a a c d -> d -> m ()  () ::  a m =>  a a c d -> d -> 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 => ]) a a c d -> (c -> d) -> m ()  ( ) ::  a m => <( a a c d -> (c -> d) -> m ()  ( ) ::  a m => 3# a a c d -> (c -> d) -> m ()  ( ) ::  a m => & a a c d -> (c -> d) -> m ()  Modify the target(s) of a  <, ],  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) =>  ] 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  <, ],  or 3 by subtracting a value   ( ) :: ( a m, ( b) =>   a b -> b -> m ()  ( ) :: ( a m, ( b) =>  ] 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  <, ],  or 3 by multiplying by value.   ballSpeed     speedMultiplier   ( ) :: ( a m, ( b) =>   a b -> b -> m ()  ( ) :: ( a m, ( b) =>  ] 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  <, ],  or 3 by dividing by a value.   ( ) :: ( a m, ) b) =>   a b -> b -> m ()  ( ) :: ( a m, ) b) =>  ] 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) =>  ] 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) =>  ] 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) =>  ] 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  <, ],  or 3 by taking their logical  with a value   () ::  a m =>   a  ->  -> m ()  () ::  a m =>  ] 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 =>  ] 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 => ] 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 => ] 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> Safe-Infered *Useful for storing getters in containers. Most - combinators are able to be used with both a  or a  X2 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  ]. we also restricted choices of the irrelevant b and  d parameters. If a function accepts a  r a c , then when r is a Monoid, then  you can pass a X (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 X,  since it just ignores the  Applicative. Build a % from an arbitrary Haskell function.   f .  g =  (g . f) a   f = f aimport Control.Lens(0, -5)^._2.to abs5View the value pointed to by a , ] or  <4 or the result of folding over all the results of a  X or 3 that points  at a monoidal values.   .  = import Control.Lensview _2 (1,"hello")"hello"It may be useful to think of " as having these more restrictive  signatures:    ::  a c -> a -> c   :: Monoid m => X a m -> a -> m   ::  ] a c -> a -> c   ::  < a c -> a -> c   :: Monoid m =>  3 a m -> a -> m View the value of a , ],  <5 or the result of folding over the result of mapping  the targets of a X or  3. It may be useful to think of " as having these more restrictive  signatures: import Control.Lensviews _2 length (1,"hello")5    :: ' a c -> (c -> d) -> a -> d   :: Monoid m => X) a c -> (c -> m) -> a -> m   ::  ]# 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 , ] or  <4 or the result of folding over all the results of a  X or 3 that points  at a monoidal values. This is the same operation as , only infix. import Control.Lens_2 ^$ (1, "hello")"hello"   () ::  a c -> a -> c  () :: Monoid m => X a m -> a -> m  () ::  ] 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 X 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 () :m + Data.Complex Control.Lens$((0, 1 :+ 2), 3)^._1._2.to magnitude2.23606797749979   () :: a ->  a c -> c  () :: Monoid m => a -> X a m -> m  () :: a ->  ] a c -> c  () :: a ->  < a c -> c  () :: Monoid m => a ->  3 a m -> m Use the target of a <, ], or  - in the current state, or use a summary of a  X or 3 that points  to a monoidal value.    ::  a m =>  a c -> m c   :: ( a m, Monoid r) => X a r -> m r   ::  a m =>  ] a c -> m c   ::  a m =>  < a c -> m c   :: ( a m, Monoid r) =>  3 a r -> m r  Use the target of a <, ] or  - in the current state, or use a summary of a  X or 3 that  points to a monoidal value.     ::  a m => " a c -> (c -> e) -> m e    :: ( a m, Monoid r) => X$ a c -> (c -> r) -> m r    ::  a m =>  < a c -> (c -> e) -> m e    ::  a m =>  ] a c -> (c -> e) -> m e    :: ( a m, Monoid r) =>  3 a c -> (c -> r) -> m r !Query the target of a <, ] or  - in the current state, or use a summary of a  X or 3 that points  to a monoidal value.   ! :: + a m =>  a c -> m c  ! :: (+ a m, Monoid c) => X a c -> m c  ! :: + a m =>  ] a c -> m c  ! :: + a m =>  < a c -> m c  ! :: (+ a m, Monoid c) =>  3 a c -> m c "Use the target of a <, ] or  - in the current state, or use a summary of a  X or 3 that points  to a monoidal value.   " :: + a m => " a c -> (c -> e) -> m e  " :: (+ a m, Monoid c) => X$ a c -> (c -> e) -> m e  " :: + a m =>  ] 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> Safe-Infered # 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) => x k f a b c d)@Build an isomorphism family from two pairs of inverse functions     () ac ca bd db) = ac   ( () ac ca bd db)) = ca   () ac ca bd db) cd = db . cd . ac   ( () ac ca bd db')) ab = 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) = f   ( (* f g)) = g   () f g) h = g . h . f   ( (* f g')) h = f . h . g  iso :: (a -> b) -> (b -> a) -> | ( a b+ Based on ala from Conor McBride's work on Epigram. Mnemonically, au is a French contraction of  le. 0:m + Control.Lens Data.Monoid.Lens Data.Foldableau _sum foldMap [1,2,3,4]10, 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. -The opposite of working  a Setter is working - an Isomorphism.  - =  .  -' :: Iso a b c d -> (a -> b) -> (c -> d).:This isomorphism can be used to wrap or unwrap a value in .   x^.identity =  x   x   . = x /:This isomorphism can be used to wrap or unwrap a value in    x  / =  x   x   / = x  #$%&'()*+,-./#$%&'()*+,-./(*)+,-/.$%&'# #$%&'()*+,-./portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered0This % 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]1Construct 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 01010101 RankNTypes provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered2GSometimes 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. 5Representable Functors. A  f is 5 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 = 7 f is a valid choice of x for (nearly) every  5 . @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 5  here. 7The representation of a 5  as Lenses 88# is a valid default definition for  for a 5  functor.  8 f m = 6 ' i -> f (m  i) Usage for a 5 Foo:   instance  Foo where   = 8 99# is a valid default definition for  and . for a  5 functor.  9 = 6 .  Usage for a 5 Foo:    instance  Foo where   = 9  ...    instance  Foo where  . = 9  ... ::$ is a valid default definition for (/) for a 5  functor.  : mf ma = 6 ' i -> mf  i ' ma  i Usage for a 5 Foo:   instance  Foo where   = 9  (/) = : ;;+ is a valid default default definition for '(>>=)' for a  representable functor.  ; m f = 6 ' i -> f (m  i)  i Usage for a 5 Foo:   instance  Foo where  . = 9  (0) = ; <A default definition for  for a 5   < wf = 6 ' i ->  ( i) wf Usage for a 5 Foo:   instance  Foo where   = < =A 5 - has a fixed shape. This fills each position  in it with a 2 > A version of 65 that is an isomorphism. Predicativity requires that  we wrap the 7 as a Key , however. ? Map over a 5 functor with access to the } for the  current position ? f m = 6 ' i -> f i (m  i)@ Traverse a 5) functor with access to the current path A Traverse a 5) functor with access to the current path  as a }, discarding the result B Traverse a 5) functor with access to the current path  and a } (and the arguments flipped) C1 over a 5) functor with access to the current path  as a } D1 over a 5) functor with access to the current path  as a }, discarding the result E1 over a 5) functor with access to the current path  as a } (with the arguments flipped) F Fold over a 5) functor with access to the current path  as a } , yielding a  G Fold over a 5) functor with access to the current path  as a }. HAn  that walks an 5  using a 2 for an index. IAn  that walks an 2 5  using a 2 for an index. JAn  for a  5 . 3NB: The 4@ requirement on this instance is a consequence of the choice of } as a 7, it isn't fundamental. 23456789:;<=>?@ABCDEFGHIJ3523456789:;<=>?@ABCDEFGHIJ56789:;<234=>?FG@ABCDEHIJ23456789:;<=>?@ABCDEFGHIJ35 Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedKThis class allows us to use L? 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. LMRun 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:   L ::  a b -> (b -> c) -> a -> c  L ::  c => Fold a b -> (b -> c) -> a -> c  L ::  w  a b -> 6 a w s c -> 6 b w s c  L :: ( w,  c) => Fold a b -> 6 a w s c -> 6 b w s c  ... MThis class allows us to use N$ in, changing the State supplied by Y many different monad transformers, potentially quite deep in a monad transformer stack. N?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!   N ::  m => | } a b -> 7 b m c -> 7 a m c  N :: ( m,  c) => | 3 a b -> 7 b m c -> 7 a m c  N ::  m => | } a b -> 6 r w b m c -> 6 r w a m c  N :: ( m,  c) => | 3 a b -> 6 r w b m c -> 6 r w a m c  N ::  m => | } a b -> 8 e (6 r w b m c) -> 8 e (6 r w a m c)  N :: ( m,  c) => | 3 a b -> 8 e (6 r w b m c) -> 8 e (6 r w a m c)  ... 9 L = KLMN:;<9=>?@ABCDEFGHKLMNKLMNKLMN:;<9=>?@ABCDEFGHportable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedOThis % can be used to change the type of a I 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]PConstruct a set from a , Fold,  Traversal, Lens or Iso. :m + Control.Lens5setOf (folded._2) [("hello",1),("world",2),("!!!",3)]fromList [1,2,3]   setOf :: J c =>  a c -> a -> I c  setOf :: (4 c, J c) => Fold a c -> a -> I c  setOf :: J c => Simple Iso a c -> a -> I c  setOf :: J c => Simple Lens a c -> a -> I c  setOf :: (4 c, J c) => Simple  Traversal a c -> a -> I c OPOPOPOP Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered5Q(Useful for storing folds in containers. TA TI describes how to retrieve multiple values in a way that can be composed % with other lens-like constructions. A T a cC provides a structure with operations very similar to those of the 2  typeclass, see ` and the other T combinators. !By convention, if there exists a foo method that expects a 2 (f c), then there should be a  fooOf method that takes a T a c and a value of type a. A  is a legal T that just ignores the supplied   Unlike a 3 a T is read-only. Since a T cannot be used to write back $ there are no lens laws that apply. U Obtain a T9 by lifting an operation that returns a foldable result. +This can be useful to lift operations from  Data.List and elsewhere into a T. V Obtain a T from any 2. W%Fold by repeating the input forever. K = d WX!A fold that replicates its input n times. L n = d (X n)YITransform 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]Z2Build a fold that unfolds its values from a seed.  = d . Z[x ^. [ f5 Return an infinite fold of repeated applications of f to x. ' toListOf (iterated f) a = iterate f a \ Obtain a T by filtering a }, ], , T or 3. ].This allows you to traverse the elements of a 3 or T in the opposite order. Note: ] should have no impact on a  Setter, } or ]. To change the direction of an ], use from. ^ Obtain a T! by taking elements from another T, }, ],  or 3 while a predicate holds.  M p = d (^ p V))toListOf (takingWhile (<=3) folded) [1..][1,2,3]_ Obtain a T# by dropping elements from another T, }, ],  or 3 while a predicate holds.  N p = d (_ p V),toListOf (droppingWhile (<=3) folded) [1..6][4,5,6]`  = ` V ` =    ` :: % a c -> (c -> r) -> a -> r  ` ::  r => T' a c -> (c -> r) -> a -> r  ` :: | } a c -> (c -> r) -> a -> r  ` :: | ]! a c -> (c -> r) -> a -> r  ` ::  r => | 3 a c -> (c -> r) -> a -> r a  = a V a =    a ::  a m -> a -> m  a ::  m => T a m -> a -> m  a :: | } a m -> a -> m  a :: | ] a m -> a -> m  a ::  m => | 3 a m -> a -> m bIRight-associative fold of parts of a structure that are viewed through a }, , T or 3.   = b V   b :: / a c -> (c -> e -> e) -> e -> a -> e  b :: T1 a c -> (c -> e -> e) -> e -> a -> e  b :: | }* a c -> (c -> e -> e) -> e -> a -> e  b :: | ]+ a c -> (c -> e -> e) -> e -> a -> e  b :: | 3% a c -> (c -> e -> e) -> e -> a -> e cLLeft-associative fold of the parts of a structure that are viewed through a }, , T or 3.   = c V   c :: / a c -> (e -> c -> e) -> e -> a -> e  c :: T1 a c -> (e -> c -> e) -> e -> a -> e  c :: | }* a c -> (e -> c -> e) -> e -> a -> e  c :: | ]+ a c -> (e -> c -> e) -> e -> a -> e  c :: | 3% a c -> (e -> c -> e) -> e -> a -> e d#Extract a list of the targets of a T . See also (e).     = d V  (e) =  d    d ::  a c -> a -> [c]  d :: T a c -> a -> [c]  d :: | } a c -> a -> [c]  d :: | ] a c -> a -> [c]  d :: | 3 a c -> a -> [c] e(A convenient infix (flipped) version of d.   d :: a ->  a c -> [c]  d :: a -> T a c -> [c]  d :: a -> | } a c -> [c]  d :: a -> | ] a c -> [c]  d :: a -> | 3 a c -> [c] f  = f V   f ::  a  -> a ->   f :: T a  -> a ->   f :: | } a  -> a ->   f :: | ] a  -> a ->   f :: | 3 a  -> a ->  g  = g V   g ::  a  -> a ->   g :: T a  -> a ->   g :: | } a  -> a ->   g :: | ] a  -> a ->   g :: | 3 a  -> a ->  h  = h V   h ::  a c -> (c ->  ) -> a ->   h :: T a c -> (c ->  ) -> a ->   h :: | } a b c d -> (c ->  ) -> a ->   h :: | ] a b c d -> (c ->  ) -> a ->   h :: | 3 a b c d -> (c ->  ) -> a ->  i  = i V   i ::  a c -> (c ->  ) -> a ->   i :: T a c -> (c ->  ) -> a ->   i :: | } a c -> (c ->  ) -> a ->   i :: | ] a c -> (c ->  ) -> a ->   i :: | 3 a c -> (c ->  ) -> a ->  j  = j V   j ::  a c -> a -> c  j :: ( c => T a c -> a -> c  j :: | } a c -> a -> c  j :: | ] a c -> a -> c  j :: ( c => | 3 a c -> a -> c k  = k V k _1 :: (a, b) -> a k (V . _1) :: (2 f, ( a) => f (a, b) -> a   k ::  a c -> a -> c  k :: ( c => T a c -> a -> c  k :: | } a c -> a -> c  k :: | ] a c -> a -> c  k :: ( c => | 3 a c -> a -> c lWhen passed a , l can work over a . When passed a T, l requires an .   = l V l _2 :: # f => (c -> f e) -> (c1, c) -> f () l  ::  f => (a -> f b) ->  a c -> f ()bThe rather specific signature of traverseOf_ allows it to be used as if the signature was either:   l ::  f => * a c -> (c -> f e) -> a -> f ()  l ::  f => T, a c -> (c -> f e) -> a -> f ()  l ::  f => | }% a c -> (c -> f e) -> a -> f ()  l ::  f => | ]& a c -> (c -> f e) -> a -> f ()  l ::  f => | 3 a c -> (c -> f e) -> a -> f () m O = m V   m ::  f => * a c -> a -> (c -> f e) -> f ()  m ::  f => T, a c -> a -> (c -> f e) -> f ()  m ::  f => | }% a c -> a -> (c -> f e) -> f ()  m ::  f => | ]& a c -> a -> (c -> f e) -> f ()  m ::  f => | 3 a c -> a -> (c -> f e) -> f () n P = n V   n ::  f => ! a (f ()) -> a -> f ()  n ::  f => T# a (f ()) -> a -> f ()  n ::  f => | } a (f ()) -> a -> f ()  n ::  f => | Iso a (f ()) -> a -> f ()  n ::  f => | 3 a (f ()) -> a -> f () o 7 = o V   o ::  m => * a c -> (c -> m e) -> a -> m ()  o ::  m => T, a c -> (c -> m e) -> a -> m ()  o ::  m => | }% a c -> (c -> m e) -> a -> m ()  o ::  m => | ]& a c -> (c -> m e) -> a -> m ()  o ::  m => | 3 a c -> (c -> m e) -> a -> m () p  = p V   p ::  m => * a c -> a -> (c -> m e) -> m ()  p ::  m => T, a c -> a -> (c -> m e) -> m ()  p ::  m => | }% a c -> a -> (c -> m e) -> m ()  p ::  m => | ]& a c -> a -> (c -> m e) -> m ()  p ::  m => | 3 a c -> a -> (c -> m e) -> m () q  = q V   q ::  m =>  a (m b) -> a -> m ()  q ::  m => T" a (m b) -> a -> m ()  q ::  m => | } a (m b) -> a -> m ()  q ::  m => | ] a (m b) -> a -> m ()  q ::  m => | 3 a (m b) -> a -> m () r1The sum of a collection of actions, generalizing w.  Q = r V   r :: R f =>  a c -> a -> f c  r :: R f => T a c -> a -> f c  r :: R f => | } a c -> a -> f c  r :: R f => | ] a c -> a -> f c  r :: R f => | 3 a c -> a -> f c s1The sum of a collection of actions, generalizing w.  S = s V   s :: T m =>  a c -> a -> m c  s :: T m => T a c -> a -> m c  s :: T m => | } a c -> a -> m c  s :: T m => | ] a c -> a -> m c  s :: T m => | 3 a c -> a -> m c t U = t V   t :: 4 c =>  a c -> c -> a ->   t :: 4 c => T a c -> c -> a ->   t :: 4 c => | } a c -> c -> a ->   t :: 4 c => | ] a c -> c -> a ->   t :: 4 c => | 3 a c -> c -> a ->  u V = u V   u :: 4 c =>  a c -> c -> a ->   u :: 4 c => T a c -> c -> a ->   u :: 4 c => | ] a c -> c -> a ->   u :: 4 c => | } a c -> c -> a ->   u :: 4 c => | 3 a c -> c -> a ->  v W = v V   v ::  a c -> (c -> [e] ) -> a -> [e]  v :: T a c -> (c -> [e] ) -> a -> [e]  v :: | } a c -> (c -> [e] ) -> a -> [e]  v :: | ] a c -> (c -> [e] ) -> a -> [e]  v :: | 3 a c -> (c -> [e] ) -> a -> [e] w   X = w V  w =     w ::  a [e] -> a -> [e]  w :: T a [e] -> a -> [e]  w :: | ] a [e] -> a -> [e]  w :: | } a [e] -> a -> [e]  w :: | 3 a [e] -> a -> [e] x;Note: this can be rather inefficient for large containers.  Y = x Vimport Control.LenslengthOf _1 ("hello",())1 x (V . V) :: 2 f => f (g a) ->    x ::  a c -> a ->   x :: T a c -> a ->   x :: | } a c -> a ->   x :: | ] a c -> a ->   x :: | 3 a c -> a ->  yPerform a safe Z of a T or 3 or retrieve [ the result  from a  or } . See also (z).  \ . ] = y V   y ::  a c -> a ->  c  y :: T a c -> a ->  c  y :: | } a c -> a ->  c  y :: | ] a c -> a ->  c  y :: | 3 a c -> a ->  c zPerform a safe Z of a T or 3 or retrieve [ the result  from a  or }.  When using a 3 as a partial }, or a T as a partial  this can be a convenient $ way to extract the optional value.  (z) =  y   (z ) :: a ->  a c ->  c  (z ) :: a -> T a c ->  c  (z ) :: a -> | } a c ->  c  (z ) :: a -> | ] a c ->  c  (z ) :: a -> | 3 a c ->  c {Perform a safe ^ of a T or 3 or retrieve [ the result  from a  or }.   { ::  a c -> a ->  c  { :: T a c -> a ->  c  { :: | } a c -> a ->  c  { :: | ] a c -> a ->  c  { :: | 3 a c -> a ->  c |Returns _ if this T or 3( has no targets in the given container. Note: | on a valid ], } or  should always return `  a = | V/This may be rather inefficient compared to the a check of many containers. import Control.LensnullOf _1 (1,2)False | (V . _1 . V) :: 2 f => f (g a, b) ->    | ::  a c -> a ->   | :: T a c -> a ->   | :: | ] a c -> a ->   | :: | } a c -> a ->   | :: | 3 a c -> a ->  }2Obtain the maximum element (if any) targeted by a T or 3 Note: maximumOf on a valid ], } or  will always return [ a value.  b = c (d empty) . } V   } ::  a c -> a ->  c  } :: - c => T a c -> a ->  c  } :: | ] a c -> a ->  c  } :: | } a c -> a ->  c  } :: - c => | 3 a c -> a ->  c ~2Obtain the minimum element (if any) targeted by a T or 3 Note: minimumOf on a valid ], } or  will always return [ a value.  e = c (d empty) . ~ V   ~ ::  a c -> a ->  c  ~ :: - c => T a c -> a ->  c  ~ :: | ] a c -> a ->  c  ~ :: | } a c -> a ->  c  ~ :: - c => | 3 a c -> a ->  c 2Obtain the maximum element (if any) targeted by a T, 3, }, ],  or ( according to a user supplied ordering.   cmp = c (d empty) .  V cmp    ::  a c -> (c -> c -> f ) -> a ->  c   :: T a c -> (c -> c -> f ) -> a ->  c   :: | ] a c -> (c -> c -> f ) -> a ->  c   :: | } a c -> (c -> c -> f ) -> a ->  c   :: | 3 a c -> (c -> c -> f ) -> a ->  c 2Obtain the minimum element (if any) targeted by a T, 3, }, ]  or ( according to a user supplied ordering.  D minimumBy cmp = fromMaybe (error "empty") . minimumByOf folded cmp    ::  a c -> (c -> c -> f ) -> a ->  c   :: T a c -> (c -> c -> f ) -> a ->  c   :: | ] a c -> (c -> c -> f ) -> a ->  c   :: | } a c -> (c -> c -> f ) -> a ->  c   :: | 3 a c -> (c -> c -> f ) -> a ->  c The  function takes a } (or , ], T, 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   :: T a c -> (c ->  ) -> a ->  c   :: | ] a c -> (c ->  ) -> a ->  c   :: | } a c -> (c ->  ) -> a ->  c   :: | 3 a c -> (c ->  ) -> a ->  c  A variant of b4 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 = g f . d l  =  V    :: * a c -> (c -> c -> c) -> a -> c   :: T, a c -> (c -> c -> c) -> a -> c   :: | ]& 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 cQ 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 =  l f . ]  =  V    :: * a c -> (c -> c -> c) -> a -> c   :: T, a c -> (c -> c -> c) -> a -> c   :: | ]& 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.   =  V    :: / a c -> (c -> e -> e) -> e -> a -> e   :: T1 a c -> (c -> e -> e) -> e -> a -> e   :: | ]+ 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.   =  V    :: / a c -> (e -> c -> e) -> e -> a -> e   :: T1 a c -> (e -> c -> e) -> e -> a -> e   :: | ]+ 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.   =  V    ::  m => 3 a c -> (c -> e -> m e) -> e -> a -> m e   ::  m => T5 a c -> (c -> e -> m e) -> e -> a -> m e   ::  m => | ]/ 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.   =  V    ::  m => 3 a c -> (e -> c -> m e) -> e -> a -> m e   ::  m => T5 a c -> (e -> c -> m e) -> e -> a -> m e   ::  m => | ]/ 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 7QRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~7QRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~7TzeUVZ[\]WXY^_`abcdhifgjklmnopqrsvwtux|y{}~QRS5QRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered type SimpleReifiedTraversal = |  A form of 4 that can be stored monomorphically in a container.  type SimpleTraversal = | A  can be used directly as a 2 or a T (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 ] as a , and composition of a  (or } or ] ) with a  (or } or ])  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  =    (t f) . t g = Z[ . t (Z\ .  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 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 =  ( l)   h =     =      :: ]# 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.    i =   =     l =  l id   l = l id     :: ] 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.  1 =      :: ]) 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    j =     l =  ( l)     :: ]) 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    k =     l =  l id   l = l . l m     :: ] 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:   =  &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 .   =  ' accumulates state from right to left.    :: ]9 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 .   =  ' accumulates state from left to right.    :: ]9 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 n over an arbitrary  or }.  n =      :: ]* 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 o over an arbitrary  or }.  o =     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 ]. +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.  =  %This is the traversal that just doesn't return anything   ::  f => (c -> f d) -> a -> f 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 :   = 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 X 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 p. Has a q Extract (or modify) the q 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. rstuvwxyz{|  rstuvwxyz{| Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered: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 (4,-,},~,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 (4,-,},~,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. d biplate =  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.  = d  Provided for compatibility with uniplate.   = d  :: T a b -> a -> [b]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.    :: | ] 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 => | ] 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 => | ] 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   ::  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.  :: T a a -> a -> [a]Given a T that knows how to find O parts of a container retrieve them and all of their descendants, recursively. Given a T~ 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 T. d l =  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)  =  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 b -> (b -> b) -> a -> a   :: |  a b -> (b -> b) -> a -> a 2Recurse one level into the parts delimited by one , using another.   b l =  (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 =  (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.  = 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.   =   ::  m => |  a b => (b -> m b) -> a -> m a2Recurse one level into the parts delimited by one , using another with  effects.   = ()  ::  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 = b    :: ( f, Plated' c) => |  a b -> (b -> f b) -> a -> f 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 l#, but is provided for consistency.   = l  ::  f => T a b => (b -> f b) -> a -> f ()2Recurse one level into the parts delimited by one T, using another with ; effects, without reconstructing the structure behind you.   b l = l (b  l)  ::  f => T a b -> T b b -> (b -> f c) -> a -> f ()ARecurse one level into the parts of the structure delimited by a  with monadic effects.   b = l (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)  =  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.   =   ::  m => |  a b => (b -> m b) -> a -> m a2Recurse one level into the parts delimited by one &, using another with monadic effects.   b l =  (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 =  (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)  = mapMOf_' mRecurse one level into a structure using a user specified recursion scheme and monadic effects. This is just o#, but is provided for consistency.   = o  ::  m => T a b => (b -> m b) -> a -> m ()2Recurse one level into the parts delimited by one &, using another with monadic effects.   b l = o (b  l)  ::  m => T a b -> T b b -> (b -> m b) -> a -> m ()ARecurse one level into the parts of the structure delimited by a  with monadic effects.   b = o (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]   =  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 =  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.   =     :: | 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 =  (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.  :: T a a -> (a -> [r] -> r) -> a -> rKPerform a fold-like computation on each value, technically a paramorphism.  =  !Fold the immediate children of a  container.  z c f = b  (c  f) z The original uniplate% combinator, implemented in terms of  as 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 Y!  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.    :: | ] a b -> a -> | } a [b]   :: | } a b -> a -> | } a [b]   :: |  a b -> a -> |  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! >::= Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered#A  with an additional index. 2An instance must satisfy a (modified) form of the  laws:    ( ) =    ( f)   g =  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.  =  . 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.  =  . 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.  =  . 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.  =  . 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 =  l .     :: 7 i a c -> (i -> e -> c -> e) -> e -> a -> e   :: 9 i a c -> (i -> e -> c -> e) -> e -> a -> e   :: t3 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 =  (i -> f i . g i)   (_ 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 T9 by lifting an operation that returns a foldable result. +This can be useful to lift operations from  Data.List and elsewhere into a T. 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.  =  . +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).   =   When you don' t need access to the index then O& is more flexible in what it accepts. O 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 o& is more flexible in what it accepts.  =  . *Run monadic actions for each target of an  or  with access to the index, 6 discarding the results (with the arguments flipped).   =   When you don' t need access to the index then p& is more flexible in what it accepts. p l 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 W& is more flexible in what it accepts.   W =  .    =  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.  =  . 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.  =  . 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.  =  . .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.  =   . 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)   h 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 1( is more liberal in what it can accept. 1 =  . 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).   j a =  a .    =    Generalizes  to add access to the index. ' accumulates state from right to left.  =  .  Generalizes  to add access to the index. ' accumulates state from left to right.  =  . PAccess the element of an indexed container where the index matches a predicate. :m + 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. 0!!)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. )Handle singleton constructors specially. 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. #      !"#$%&'#      !"#$%&'#"%#&$' !            !"#$%&' Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./23456789:;<=>?@ABCDEFGHIJKLMNQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'GHC experimentalEdward Kmett <ekmett@gmail.com> Safe-Infered(Used to traverse  data by uniplate. );Convert from the data type to its representation (or back) '"hello"^.generic.from generic :: String"hello"*;Convert from the data type to its representation (or back) +A   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! ()*+()*+)*+( ()*+Control.Exception provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered,Traverse the strongly typed  contained in ) where the type of your function matches  the desired .   traverseException :: ( f,  a,  b) $ => (a -> f b) ->  -> f  ,,,,LiberalTypeSynonyms experimentalEdward Kmett <ekmett@gmail.com> Safe-Infered -Bitwise  the target(s) of a } or  _2 |~ 6 $ ("hello",3) ("hello",7)   (|~) ::  c =>  a b c c -> c -> a -> b  (|~) ::  c => ( a b c c -> c -> a -> b  (|~) ::  c => } a b c c -> c -> a -> b  (|~) :: ('Monoid c',  c) =>  a b c c -> c -> a -> b .Bitwise  the target(s) of a } or  _2 &~ 7 $ ("hello",254) ("hello",6)   (&~) ::  c =>  a b c c -> c -> a -> b  (&~) ::  c => ( a b c c -> c -> a -> b  (&~) ::  c => } a b c c -> c -> a -> b  (&~) :: ('Monoid c',  c) =>  a b c c -> c -> a -> b /Modify the target(s) of a | },  or  by computing its bitwise  with another value.   (&=):: ( a m,  b) => |  a b -> b -> m ()  (&=):: ( a m,  b) => | ( a b -> b -> m ()  (&=):: ( a m,  b) => | } a b -> b -> m ()  (&=):: ( a m,  b) => |  a b -> b -> m () 0Modify the target(s) of a | },  or  by computing its bitwise  with another value.   (|=):: ( a m,  b) => |  a b -> b -> m ()  (|=):: ( a m,  b) => | ( a b -> b -> m ()  (|=):: ( a m,  b) => | } a b -> b -> m ()  (|=):: ( a m,  b) => |  a b -> b -> m () 1Bitwise  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))   (<|~) ::  c => ( a b c c -> c -> a -> (c, b)  (<|~) ::  c => } a b c c -> c -> a -> (c, b)  (<|~) :: ( c, ' Monoid c) =>  a b c c -> c -> a -> (c, b) 2Bitwise  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))   (<&~) ::  c => ( a b c c -> c -> a -> (c, b)  (<&~) ::  c => } a b c c -> c -> a -> (c, b)  (<&~) :: ( c, ' Monoid c) =>  a b c c -> c -> a -> (c, b) 3Modify 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 4Modify 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 5FThis lens can be used to access the value of the nth bit in a number. 5 n is only a legal } into b if 0 <= n <  ( :: b)  16^.bitAt 4True 15^.bitAt 4False6*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. -./0123456 -./0123456 -.120/4356 -./0123456portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered7,A lens reading and writing to the head of a  non-empty list [1,2,3]^._head18,A lens reading and writing to the tail of a  non-empty list _tail .~ [3,4,5] $ [1,2] [1,3,4,5]94A lens reading and writing to the last element of a  non-empty list  [1,2]^._last2:=A lens reading and replacing all but the a last element of a  non-empty list [1,2,3,4]^._init[1,2,3];CObtain a version of the list with the supplied value interspersed. "abcde"^.interspersed ',' "a,b,c,d,e" ' xs^.interspersed a = intersperse a xs <BObtain a version of the list with the supplied value intercalated =QIndexed traversal of a list. The position in the list is available as the index. ><The 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] = traverseHead :: Applicative f => (a -> f a) -> [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] = traverseTail :: Applicative f => (a -> f a) -> [a] -> f [a] @%Traverse 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] = traverseLast :: Applicative f => (a -> f a) -> [a] -> f [a] A,Traverse 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] = traverseInit :: Applicative f => (a -> f a) -> [a] -> f [a] B&Cons onto the list(s) referenced by a . 'h' ~: _1 $ ("ello","world")("hello","world")   (B ) :: b -> |  a [b] -> a -> a  (B ) :: b -> |  a [b] -> a -> a  (B ) :: b -> | } a [b] -> a -> a  (B ) :: b -> | ( a [b] -> a -> a C&Cons onto the list(s) referenced by a  in your monad state   (C) ::  a m => c -> |  a [c] -> m ()  (C) ::  a m => c -> |  a [c] -> m ()  (C) ::  a m => c -> | } a [c] -> m ()  (C) ::  a m => c -> | ( a [c] -> m () D&Cons onto the list(s) referenced by a }, returning the result. 'h' <~: _1 $ ("ello","world")("hello",("hello","world"))   (\<~: ) :: b -> | } a [b] -> a -> (b, a)  (\<~: ) :: b -> | ( a [b] -> a -> (b, a) E&Cons onto the list(s) referenced by a }. into your monad state, returning the result.   (\<=:) ::  a m => | } a [c] -> c -> m ()  (\<=:) ::  a m => | ( a [c] -> c -> m () 789:;<=>?@ABCDE789:;<=>?@ABCDE789:;<=>?A@BCDE789:;<=>?@ABCDEportable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedF (or ) a list of bytes into a    x = x  F  x = x   FGTraverse each  in a   G =  F a = h G ( 0x80) ::  -> H (or ) a list of characters into a  When writing back to the  it is assumed that every %  lies between '\x00' and '\xff'.   x = x  H  x = x   HI#Traverse the individual bytes in a  as characters. When writing back to the  it is assumed that every %  lies between '\x00' and '\xff'.  I =  H .  h I ( 'c') ::  -> FGHIFGHIFGHIFGHIportable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedJ (or ) a list of bytes into a    x = x  J  x = x   JK#Traverse the individual bytes in a   K =  J . = h K ( 0x80) ::  -> L (or ) a list of characters into a  When writing back to the  it is assumed that every %  lies between '\x00' and '\xff'.   x = x  L  x = x   LM#Traverse the individual bytes in a  as characters. When writing back to the  it is assumed that every %  lies between '\x00' and '\xff'.  M =  L a = h M ( 'c') ::  -> JKLMJKLMJKLMJKLM portable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedNTraversals for ByteStrings. O (or () a list of bytes into a strict or lazy    x = x  O  x = x   OP (or -) a list of characters into a strict or lazy  When writing back to the  it is assumed that every %  lies between '\x00' and '\xff'.   x = x  P  x = x   PQTraverse each  in a strict or lazy   Q =  O a  traverseList h Q ( 0x80) ::  -> R2Traverse the individual bytes in a strict or lazy  as characters. When writing back to the  it is assumed that every %  lies between '\x00' and '\xff'.  R =  P .  h R ( 'c') ::  -> NOPQRNOPQRNOPQRNOPQR! Rank2Types experimentalEdward Kmett <ekmett@gmail.com> Safe-InferedS Access the  of a  number ? real :: Functor f => (a -> f a) -> Complex a -> f (Complex a) T Access the  imaginaryPart of a  number D imaginary :: Functor f => (a -> f a) -> Complex a -> f (Complex a) UThis 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 }. V0Traverse both the real and imaginary parts of a  number. N traverseComplex :: Applicative f => (a -> f b) -> Complex a -> f (Complex b) STUVSTUVSTUVSTUV" Rank2Types experimentalEdward Kmett <ekmett@gmail.com> TrustworthyWLA generic applicative transformation that maps over the immediate subterms. W is to  what  is to  This really belongs in  Data.Data. XNave  using 3. This does not attempt to optimize the traversal. ZThis is primarily useful when the children are immediately obvious, and for benchmarking.   X :: ( a,  b) => |  a b Y%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 Z with a more liberal signature. ZFind descendants of type aU non-transitively, while avoiding computation of areas that cannot contain values of  type a using . Z$ is a useful default definition for  [[ performs like Y, except when a ~ b&, it returns itself and nothing else. WXYZ[WXYZ[YXZ[WWXYZ[#portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered\(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 \\\\$ Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered]/Traverse the value at the minimum key in a Map :The key of the minimum element is available as the index. ^/Traverse the value at the maximum key in a Map ]^]^]^]^%portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered_ IntSet isn't Foldable, but this T) can be used to access the members of an . &sumOf members $ setOf folded [1,2,3,4]10`This * 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 V and  reindexing it via setmap. (over setmapped (+1) (fromList [1,2,3,4])fromList [2,3,4,5]a Construct an  from a , T, , } or (. ":m + Data.IntSet.Lens Control.Lens5setOf (folded._2) [("hello",1),("world",2),("!!!",3)]fromList [1,2,3]   setOf ::  a  -> a ->   setOf :: T a  -> a ->   setOf :: | ( a  -> a ->   setOf :: | } a  -> a ->   setOf :: |  a  -> a ->  _`a_`a_`a_`a& Rank2Types experimentalEdward Kmett <ekmett@gmail.com> Safe-Infered b,Modify the target of a monoidally valued by ing another value. :m + Control.Lens"both <>~ "!!!" $ ("hello","world")("hello!!!","world!!!")   (b) ::  c =>  a b c c -> c -> a -> b  (b) ::  c => ( a b c c -> c -> a -> b  (b) ::  c => } a b c c -> c -> a -> b  (b) ::  c =>  a b c c -> c -> a -> b cModify the target(s) of a | }, (,  or  by  ing a value.   (c) :: ( a m,  b) => |  a b -> b -> m ()  (c) :: ( a m,  b) => | ( a b -> b -> m ()  (c) :: ( a m,  b) => | } a b -> b -> m ()  (c) :: ( a m,  b) => |  a b -> b -> m () d2 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, (b) is more flexible. e2 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, (c) is more flexible. fIsomorphism for  gIsomorphism for  hIsomorphism for  0:m + Control.Lens Data.Monoid.Lens Data.Foldableau _all foldMap [True,True]True0:m + Control.Lens Data.Monoid.Lens Data.Foldableau _all foldMap [True,False]FalseiIsomorphism for  0:m + Control.Lens Data.Monoid.Lens Data.Foldableau _any foldMap [False,False]False0:m + Control.Lens Data.Monoid.Lens Data.Foldableau _any foldMap [True,False]TruejIsomorphism for  0:m + Control.Lens Data.Monoid.Lens Data.Foldableau _sum foldMap [1,2,3,4]10kIsomorphism for  0:m + Control.Lens Data.Monoid.Lens Data.Foldableau _product foldMap [1,2,3,4]24lIsomorphism for  mIsomorphism for  bcdefghijklm bcdefghijklm bdcefghijklm bcdefghijklm'portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered nA } that can access the nth element of a . ENote: This is only a legal lens if there is already such an element! oA  is isomorphic to a   m = m  opA  is isomorphic to a   m = m  pqTraverse the head of a  rTraverse the tail of a  sTraverse the last element of a  t'Traverse all but the last element of a  uTraverse the first n elements of a  vTraverse all but the first n elements of a  w'Travere all the elements numbered from i to j of a  nopqrstuvw nopqrstuvw nopqrstuvw nopqrstuvw(portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferedx (or  ) strict .    x = x  x   x = x   x y-Traverse the individual characters in strict . $anyOf text (=='o') $ "hello"^.packedTruexyxyxyxy)portable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedzPack (or unpack) lazy .    x = x  z   x = x   z {(Traverse the individual characters in a . $ anyOf text (=='c') :: Text -> Bool z{z{z{z{*portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered|Traversals 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> Safe-InferedA } 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> Safe-InferedA |  for working with a  of a  value. A |  for working with a  of a  value. -&MPTCs, Rank2Types, LiberalTypeSynonyms provisionalEdward Kmett <ekmett@gmail.com> Safe-InferedAccess an element of an array. <Note: The indexed element is assumed to exist in the target .  arr  i = arr   i arr  [(i,e)] =  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 .   =  .   =  .   ( b) f arr  i = arr  f i  ( ( b) f arr) = bAn  of the elements of an  , using the 5 index into the array as the index of the traversal.  =  . Rank2Types experimentalEdward Kmett <ekmett@gmail.com> Safe-Infered (Modify the path by adding another path. :m + Control.Lens#both </>~ "!!!" $ ("hello","world")("hello/!!!","world/!!!")   () ::  a b   ->  -> a -> b  () :: ( a b   ->  -> a -> b  () :: } a b   ->  -> a -> b  () ::  a b   ->  -> a -> b Modify the target(s) of a | }, (,  or  by adding a path.   () ::  a m => |  a  ->  -> m ()  () ::  a m => | ( a  ->  -> m ()  () ::  a m => | } a  ->  -> m ()  () ::  a m => |  a  ->  -> 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   ->  -> a -> b  () :: ( a b   ->  -> a -> b  () :: } a b   ->  -> a -> b  () ::  a b   ->  -> a -> b Modify the target(s) of a | }, (,  or  by adding an extension.   () ::  a m => |  a  ->  -> m ()  () ::  a m => | ( a  ->  -> m ()  () ::  a m => | } a  ->  -> m ()  () ::  a m => |  a  ->  -> 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> Safe-InferedEvaluate the targets of a } or  into a data structure " according to the given strategy.     =   =    =     evalOf :: | } a b ->  b ->  a  evalOf :: |  a b ->  b ->  a  evalOf :: (b ->  b) -> a ->  a) ->  b ->  a Evaluate the targets of a } or  according into a % data structure according to a given  in parallel.   =     parOf :: | } a b ->  b ->  a  parOf :: |  a b ->  b ->  a  parOf :: ((b ->  b) -> a ->  a) ->  b ->  a  Transform a }, T, ,  or  to < first evaluates its argument according to a given strategy before proceeding.      ::  t =>  a ->  [a]  Transform a }, T, ,  or  to 5 evaluate its argument according to a given strategy in parallel with evaluating.      ::  t =>  a ->  [a] 0portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered$Evaluate the elements targeted by a }, , (,   or T" according to the given strategy.  =  V1      ; !"#$%&'()<*+,-./0123456789:;<=>?@ABCDEFGHIJKLtMNOP Q R S M T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l u q m n o p q r s t u v w x y z { | } ~   r                   2V^_a`bcdefghijklnmpoWYU]>?XLsvwxy8z{|}56~34      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijkklmnopqrstuvwxyz{|}~S     !!P!!"""""#$v$w%%%&&&&&&&&&&&&''''S''''''(())***++,,---............////0      !"#$%&'()*+,-./012345678978:;<=>=?@ABCDEFGHIJKLM N O P Q R S T U V W X Y 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 yz{|}~;7==IKAN}=7J       QQRQQQN"" !"#$%&'()*+,-./.0.1.2.345454464747*8*9:;<=<>?@A?@B?@C?@D?@E?@FGHIJKLJKMJKNJKOJKPJQRSlens-2.6Control.Lens.TraversalControl.Lens.IsomorphicControl.Lens.InternalControl.Lens.IndexedControl.Lens.IndexedGetterControl.Lens.ActionControl.Lens.TypeControl.Lens.IndexedLensControl.Lens.IndexedFoldControl.Lens.IndexedTraversal Data.Map.LensControl.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.IntMap.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.LensSettableSetter Traversalelement maximumOf minimumOfmapM_ traverseOf_Control.Monad.Trans.State.LazyStateindexedLenscloneZoomzoomControl.Monad.ErrorErrorTControl.Monad.Trans.MaybeMaybeTControl.Monad.Trans.ListListTControl.Monad.WriterWriterTControl.Monad.RWSRWSTControl.Monad.StateStateT backwards IndexedFold Control.Monadjoin imaginary Data.ComplexComplex traverseHeadControl.Lens.LensviewsetGettingFoldGetterData.Functor.Compose getComposeComposeIso%~+~-~*~//~^~^^~**~||~&&~%=+=-=*=//=**=^^=||=&&=IndexedTraversal%@~ foldMapOfSimpleIndexedLensSimpleIndexedTraversalfoldrOffoldlOfanyOfallOfforOf_mapMOf_forMOf_ concatMapOffindOffoldrOf'foldlOf'foldrMOffoldlMOftoListOf IndexedLens traverseOfforOfmapMOfforMOf mapAccumROf mapAccumLOfmapOfoverData.Traversabletraverse Traversable Data.MonoidMonoidSimpleData.Text.InternalText fmapDefaultbothData.Distributive distribute DistributiveControl.Monad.Reader.ClasslocalPreludeunfoldr Data.FoldablefoldMapfoldfoldrfoldltoListandoranyallproductsum traverse_Data.Either.Lens traverseLeftforM_ sequence_ maximumByfoldr1foldl1Offoldl1foldr'foldl'foldrMfoldlM Data.List transposeuniplatebiplate Data.Just isNothingData.Functor.IdentityIdentity IndexedGetter mapAccumR Control.LensData.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^!actactsliftActSimpleReifiedLens ReifiedLens ReifyLens reflectLensSimpleOverloaded OverloadedLensLikeSimpleLensLike SimpleLenslens%%~%%=resultAtmerged alongside cloneLens<%~<+~<-~<*~~<>=<<>~<<>=_dual_endo_all_any_sum_product_firstordinalviewLviewR traverseTo traverseFrom traverseSlicepackedtextIsTextrootbranches_cast_gcastixixmapped traverseArray~=<~<=<.>~<.>=<<.>~<<.>=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(->)Monadpure mtl-2.1.2Control.Monad.State.Classstate MonadStateGHC.RealIntegral GHC.Classes||&&const$fContainskHashSet$fContainskSet$fContainsIntIntSet $fAtkHashMap$fAtkMap $fAtIntIntMapBoolflipNothingmap Data.Tuplefst mapAccumL$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<$$GHC.NumNum Fractional GHC.FloatFloating MonadReadercontainers-0.4.2.1Data.SetSetOrdreturn<*>>>=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.0 Data.HashSetHashSethashable-1.1.2.5 Data.HashableHashableGHC.Listrepeat replicate takeWhile dropWhilefor_ sequenceA_asum Alternativemsum MonadPluselemnotElem concatMapconcatlengthheadJust listToMaybelastTrueFalsenullmaximum fromMaybeGHC.ErrerrorminimumOrderingfor sequenceAforMsequence unwrapMonad WrapMonadscanr1scanl1template-haskellLanguage.Haskell.TH.SyntaxnewNameName$fSubstTypePred $fSubstType[]$fSubstTypeType$fHasTypeVars[]$fHasTypeVarsPred$fHasTypeVarsType$fHasTypeVarsName$fHasTypeVarsTyVarBndr $fHasNameCon $fHasNameName$fHasNameTyVarBndrGHC.ShowShowGHC.ReadRead Data.Functor<$>negate==$fApplicativeOut $fFunctorOut $fPlatedTree $fPlated[] Data.IntMapData.Mapfind$fFunctorWithIndexIntSeq$fFunctorWithIndexInt[]$fTraversableWithIndexkHashMap$fFoldableWithIndexkHashMap$fFunctorWithIndexkHashMap$fTraversableWithIndexkMap$fFoldableWithIndexkMap$fFunctorWithIndexkMap$fTraversableWithIndexIntIntMap$fFoldableWithIndexIntIntMap$fFunctorWithIndexIntIntMap$fTraversableWithIndexIntSeq$fFoldableWithIndexIntSeq$fTraversableWithIndexInt[]$fFoldableWithIndexInt[] GHC.GenericsGenericData.Typeable.InternalTypeable$fGTraversal:.:$fGTraversalM1$fGTraversal:+:$fGTraversal:*:$fGTraversalU1$fGTraversalK1 GHC.Exception Exception SomeException Data.Bits.|.Bits.&.bitSize undefined integer-gmpGHC.Integer.TypeIntegerbytestring-0.9.2.1Data.ByteString.Internal ByteStringGHC.WordWord8Data.ByteString.Lazy.Internal$fIsByteStringByteString$fIsByteStringByteString0realPartpolar magnitudephase Data.DatagmapMData$fFunctorOracle$fFunctorAnswer Data.DynamicDynamic Data.IntSetIntSetmappendDualEndoAllAnySumProductFirstLast Data.SequenceSeqViewLviewlViewRviewr text-0.11.2.3 Data.TextData.Text.Lazy.InternalData.Text.Lazy $fIsTextText $fIsTextText0 Data.TreeTree Data.Typeablecastgcast array-0.4.0.0Data.Array.BaseIArray!//ixmapboundsamapGHC.IOFilePathStringparallel-3.2.0.3Control.Parallel.StrategiesevalTraversableStrategyEvalparTraversablerdeepseq Control.Seq seqFoldable