a1      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ !!!!!!!!!!""""####$$$$$%%%%&'''(((((((())))))))))))))))************++++++++++,,--...//001111111111122222222222222 3 3 3 4 44444444444555568 Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred'A concrete data type for isomorphisms. DThis lets you place an isomorphism inside a container without using ImpredicativeTypes. 7Used to provide overloading of isomorphism application  This is a ) with a canonical mapping to it from the . category of isomorphisms over Haskell types. *Build this morphism out of an isomorphism The intention is that by using #, you can supply both halves of an + isomorphism, but k can be instantiated to (->), so you can freely use * the resulting isomorphism as a function. MMap a morphism in the target category using an isomorphism between morphisms  in Hask. Invert an isomorphism. ENote to compose an isomorphism and receive an isomorphism in turn you'll need to use     ( l) "a lIf you imported  from Control.Category, then:  l   r "a  (r  l)Convert from an  back to any  value. WThis is useful when you need to store an isomoprhism as a data type inside a container 6 and later reconstitute it as an overloaded function.  ! ! Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Trustworthy, A basic non-empty list zipper OAll combinators assume the invariant that the length stored matches the number P of elements in list of items to the left, and the list of items to the left is  stored reversed.   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 (7 )#when the user attempts to misuse a 8 as a  9., 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 :. Ta.k.a. indexed Cartesian store comonad, indexed Kleene store comonad, or an indexed FunList.  *http://twanvl.nl/blog/haskell/non-regular1 " a b t is isomorphic to 9data Bazaar a b t = Buy t | Trade (Bazaar a b (b -> t)) a,  and to exists s. (s, : s t a b). A " is like a :2 that has already been applied to some structure. Where a % a b t holds an a and a function from b to  t, a " a b t holds N as and a function from N  bs to t. Mnemonically, a "0 holds many stores and you can easily add more. This is a final encoding of ". %0The indexed store can be used to characterize a ;  and is used by < % a b t is isomorphic to  Znewtype Context a b t = Context { runContext :: forall f. Functor f => (a -> f b) -> f t },  and to exists s. (s, ; s t a b). A % is like a ;4 that has already been applied to a some structure. ' Used for = * Used for > -Used internally by ? and the like. 0Used internally by @ and the like. 3Applicative composition of AB ) with a #, used  by C 6The result of 3 8Used by D to E into FG ;Make a monoid out of * for error handling >Used by D to E into FG AMake a monoid out of + for error handling DUsed by D to E into HI or JK GUsed by D to E into LM. JUsed by D to E into NO MUsed by D to E into PQ PObtain the minimum. QObtain the maximum RAGiven an action to run for each matched pair, traverse a bazaar. R :: : (" a b t) t a bS" is an indexed ,. T A trivial ". U.A convenient antonym that is used internally. VThe - equivalent for a  % #. W*How many entries are there in this level? X.Pull the non-emtpy list zipper left one entry YLPull the non-empty list zipper left one entry, stopping at the first entry. Z8Pull the non-empty list zipper all the way to the left. [8Pul the non-empty list zipper all the way to the right.  NB:6, when given an infinite list this may not terminate. \0Pull the non-empty list zipper right one entry. ]LPull the non-empty list zipper right one entry, stopping at the last entry. ^ This is a Lens# targeting the value that we would .! from the non-empty list zipper.  view ^ "a . ^ :: R ; (  a) a_<Zip a non-empty list zipper back up, and return the result. /S 0so you can pass our a 8, into combinators from other lens libraries  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_123456789/0:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefgW  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_WMNOJKLGHIDEFABC>?@;<=89:67345012-./*,+P')(Q%&"#$RST !UV WXYZ[\]^_b    !"#$%&')(*,+-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_123456789/0:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefgT Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Trustworthy6hijklmnopqrstuvwxyz{|}~6hijklmnopqrstuvwxyz{|}~6hijklmnopqrstuvwxyz{|}~"rank 2 types, MPTCs, TFs, flexible provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred `YA function with access to a index. This constructor may be useful when you need to store  a c in a container to avoid ImpredicativeTypes. c*Type alias for passing around polymorphic d functions that can be called b or  directly as a function dbPermit overloading of function application for things that also admit a notion of a key or index. Provides overloading for d functions. eBuild a function from an d function f Compose an d' function with a non-indexed function. Mnemonically, the <* points to the index we want to preserve. g'Compose a non-indexed function with an d function. Mnemonically, the >* points to the index we want to preserve. hRemap the index. iComposition of d functions Mnemonically, the < and >: points to the fact that we want to preserve the indices. jComposition of d> functions with a user supplied function for combining indexs kRTransform an Traversal into an IndexedTraversal, a Fold into an IndexedFold, etc.   k :: : s t a b ->  U ) s t a b  k :: ; s t a b ->  V ) s t a b  k :: W s t -> X ) s t  k :: Y s t a b ->  V ) s t a b  k :: 9 s t -> Z ) s t a b CUsing an equality witness to avoid potential overlapping instances  and aid dispatch. `abcdefghijk `abcdefghijk dec`abifgjhk `abcdefghijkrank 2 types, MPTCs experimentalEdward Kmett <ekmett@gmail.com> Safe-InferredlUseful for storage. oUsed to consume an X. pEvery p is a valid X and Getter. lmnoplmnoppolmnlmnopportable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferredqA strict version of ([\) for monads. (+1) <$!> [1,2,3,4] [2,3,4,5]rA strict version of ([]) for monads. () <$! [1,2,3,4] [(),(),(),()]qrqrqrqrMTPCs, FDs, Rank2 experimentalEdward Kmett <ekmett@gmail.com> Safe-Inferred sUsed to evaluate an u. tA t is a Fold enriched with access to a  for side-effects. Every Fold can be used as a t(, that simply ignores the access to the . You can compose a t with another t using ( ) from the Prelude. uAn u is a Getter enriched with access to a  for side-effects. Every Getter can be used as an u You can compose an u with another u using ( ) from the Prelude. v Perform an u.  perform = flip (^!) w Perform an u and modify the result. x Perform an u &["hello","world"]^!folded.act putStrLnhelloworldy Construct an u from a monadic side-effect zA self-running u, analogous to ^_.  z = y (1,"hello")^!_2.acts.to succ"ifmmp"{Apply a  transformer to an u. stuvwxyz{ stuvwxyz{ uyzvw{xts stuvwxyz{ Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred)| type | =  }})Useful for storing lenses in containers. type  k f s a =  ( k f) s a type  f s t a b =  (->) f s t a bMany combinators that accept a  can also accept a  : in limited situations. 'They do so by specializing the type of # that they require of the  caller. If a function accepts a  f s t a b for some # f,  then they may be passed a .  Further, if f is an %, they may also be passed a  :. type  f =  ( f) type  =  A  ,  : , ... can  be used instead of a ,:, ...  whenever the type variables don't change upon setting a value.    %` ::   (ab a) a  (c ::  d: [a] a .Note: To use this alias in your own code with  f or  8, 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:  e l (f l b a) "a b"2) Putting back what you got doesn't change anything:  f l (e l a) a "a a.3) Setting twice is the same as setting once:  f l c (f l b a) "a f 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 8 or  :. You can also use a  for g as if it were a  W or 9. Since every lens is a valid :, the 7 traversal laws are required of any lenses you create:    l  "a   ( (l f)  l g "a hi  l (hj  ( f  g)  type  s t a b = forall f. # f =>  f s t a bBuild a  from a getter and a setter.  :: #9 f => (s -> a) -> (s -> b -> t) -> (a -> f b) -> s -> f t(') 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 :, it can edit the  targets of the  Traversals+, extracting an applicative summary of its  actions. 8For all that the definition of this combinator is just:  () "a    () :: # f => Y) s t a b -> (a -> f b) -> s -> f t  () :: # f => ( s t a b -> (a -> f b) -> s -> f t  () :: % f => :# s t a b -> (a -> f b) -> s -> f t DIt may be beneficial to think about it as if it had these even more  restrictive types, however: When applied to a :, it can edit the  targets of the  Traversals-, extracting a supplemental monoidal summary  of its actions, by choosing  f = ((,) m)   () :: Y/ s t a b -> (a -> (r, b)) -> s -> (r, t)  () :: . s t a b -> (a -> (r, b)) -> s -> (r, t)  () :: Monoid m => :) s t a b -> (a -> (m, b)) -> s -> (m, t) Modify the target of a + in the current state returning some extra  information of type r or modify all targets of a  :( in the current state, extracting extra  information of type r/ and return a monoidal summary of the changes.  () "a ( )It may be useful to think of ($), instead, as having either of the , following more restricted type signatures:   () ::  s m => Y' s s a b -> (a -> (r, b)) -> m r  () ::  s m => & s s a b -> (a -> (r, b)) -> m r  () :: ( s m, Monoid r) => :! s s a b -> (a -> (r, b)) -> m r 9Merge two lenses, getters, setters, folds or traversals.   "a       :: 9 s a -> 9 s' a -> 9 (* s s') a   :: W s a -> W s' a -> W (* s s') a   ::   s a ->   s' a ->   (* s s') a   ::  : s a ->  : s' a ->  : (* s s') a   ::  8 s a ->  8 s' a ->  8 (* s s') a  This is a  that updates either side of an *', where both sides have the same type.   "a   Left 12^.chosen12Right "hello"^.chosen"hello"chosen *~ 10 $ Right 2Right 20 makes a  from two other lenses.  ::  s t a b ->  s' t' a' b' ->  (s,s') (t,t') (a,a') (b,b') Cloning a ! is one way to make sure you aren't given  something weaker, such as a : and can be D used as a way to pass around lenses that have to be monomorphic in f. !Note: This only accepts a proper . c\"Costate Comonad Coalgebra is equivalent of Java's member variable update technology for Haskell\" -- @PLT_Borat on Twitter Modify the target of a  and return the result 2When you do not need the result of the addition, (k) is more flexible.   () :: ) s t a b -> (a -> b) -> s -> (b, t)  () :: Y* s t a b -> (a -> b) -> s -> (b, t)  () :: Monoid b => :$ s t a b -> (a -> b) -> s -> (b, t) -Increment the target of a numerically valued  and return the result 2When you do not need the result of the addition, (l) is more flexible.   () ::  a =>   s a -> a -> s -> (a, s)  () ::  a =>  Y s a -> a -> s -> (a, s) -Decrement the target of a numerically valued  and return the result 5When you do not need the result of the subtraction, (m) is more flexible.   () ::  a =>   s a -> a -> s -> (a, s)  () ::  a =>  Y s a -> a -> s -> (a, s) ,Multiply the target of a numerically valued  and return the result 8When you do not need the result of the multiplication, (n ) is more  flexible.   () ::  b =>   s a -> a -> a -> (s, a)  () ::  b =>  Y s a -> a -> a -> (s, a)) +Divide the target of a fractionally valued  and return the result. 2When you do not need the result of the division, (o) is more flexible.   () ::  b =>   s a -> a -> a -> (s, a)  () ::  b =>  Y s a -> a -> a -> (s, a)) )Raise the target of a numerically valued  to a non-negative   power and return the result 2When you do not need the result of the division, (p) is more flexible.   () :: ( b,  e) =>   s a -> e -> a -> (a, s)  () :: ( b,  e) =>  Y s a -> e -> a -> (a, s) *Raise the target of a fractionally valued  to an  power  and return the result. 2When you do not need the result of the division, (q) is more flexible.   () :: ( b,  e) =>   s a -> e -> a -> (a, s)  () :: ( b,  e) =>  Y s a -> e -> a -> (a, s) ,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, (r) is more flexible.   () ::  a =>   s a -> a -> s -> (a, s)  () ::  a =>  Y s a -> a -> s -> (a, s)  Logically  a Boolean valued  and return the result 3When you do not need the result of the operation, (s) is more flexible.   () ::   s  ->  -> s -> (, s)  () ::  Y s  ->  -> s -> (, s)  Logically  a Boolean valued  and return the result 3When you do not need the result of the operation, (t) is more flexible.   () ::   s  ->  -> s -> (, s)  () ::  Y s  ->  -> s -> (, s) Modify the target of a , but return the old value. 2When you do not need the result of the addition, (k) is more flexible.   () :: ) s t a b -> (a -> b) -> s -> (b, t)  () :: Y* s t a b -> (a -> b) -> s -> (b, t)  () :: Monoid b => :$ s t a b -> (a -> b) -> s -> (b, t) Modify the target of a , but return the old value. %When you do not need the old value, (k) is more flexible.   () :: " s t a b -> b -> s -> (a, t)  () :: Y# s t a b -> b -> s -> (a, t)  () :: Monoid b => : s t a b -> b -> s -> (a, t) Modify the target of a  into your monad's state by a user supplied ! function and return the result. When applied to a :D, it this will return a monoidal summary of all of the intermediate  results. 3When you do not need the result of the operation, (u) is more flexible.   () ::  s m =>   s a -> (a -> a) -> m a  () ::  s m =>  Y s a -> (a -> a) -> m a  () :: ( s m, Monoid a) =>  Traveral s a -> (a -> a) -> m a *Add to the target of a numerically valued  into your monad's state  and return the result. 2When you do not need the result of the addition, (v ) is more  flexible.   () :: ( s m,  a) =>   s a -> a -> m a  () :: ( s m,  a) =>  Y s a -> a -> m a 1Subtract from the target of a numerically valued  into your monad's  state and return the result. 5When you do not need the result of the subtraction, (w ) is more  flexible.   () :: ( s m,  a) =>   s a -> a -> m a  () :: ( s m,  a) =>  Y s a -> a -> m a ,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, (x ) is more  flexible.   () :: ( s m,  a) =>   s a -> a -> m a  () :: ( s m,  a) =>  Y s a -> a -> m a +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, (y) is more flexible.   () :: ( s m,  a) =>   s a -> a -> m a  () :: ( s m,  a) =>  Y s a -> a -> m a )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, (z) is more flexible.   () :: ( s m,  a,  e) =>   s a -> e -> m a  () :: ( s m,  a,  e) =>  Y s a -> e -> m a *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, ({) is more flexible.   () :: ( s m,  b,  e) =>   s a -> e -> m a  () :: ( s m,  b,  e) =>  Y s a -> e -> m a ,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, (z) is more flexible.   () :: ( s m,  a) =>   s a -> a -> m a  () :: ( s m,  a) =>  Y s a -> a -> m a  Logically  a Boolean valued  into your monad's state and return  the result. 3When you do not need the result of the operation, (|) is more flexible.   () ::  s m =>   s  ->  -> m   () ::  s m =>  Y s  ->  -> m   Logically  a Boolean valued  into your monad's state and return  the result. 3When you do not need the result of the operation, (}) is more flexible.   () ::  s m =>   s  ->  -> m   () ::  s m =>  Y s  ->  -> m  Modify the target of a  into your monad's state by a user supplied  function and return the old value that was replaced. When applied to a :B, it this will return a monoidal summary of all of the old values  present. 3When you do not need the result of the operation, (u) is more flexible.   () ::  s m =>   s a -> (a -> a) -> m a  () ::  s m =>  Y s a -> (a -> a) -> m a  () :: ( s m, Monoid b) =>  Traveral s a -> (a -> a) -> m a Modify the target of a  into your monad's state by a user supplied  function and return the old value that was replaced. When applied to a :B, it this will return a monoidal summary of all of the old values  present. 3When you do not need the result of the operation, (u) is more flexible.   () ::  s m =>   s a -> (a -> a) -> m a  () ::  s m =>  Y s a -> (a -> a) -> m a  () :: ( s m, Monoid t) =>  Traveral s a -> (a -> a) -> m a ,Run a monadic action, and set the target of  to its result.    () ::  s m => Y s s a b -> m b -> m b  () ::  s m =>  s s a b -> m b -> m b (NB: This is limited to taking an actual  than admitting a : because 5 there are potential loss of state issues otherwise. +|}~+|}~+}~|)|}~ "rank 2 types, MPTCs, TFs, flexible provisionalEdward Kmett <ekmett@gmail.com> Trustworthy 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 /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. !Map.fromList [(1,"hello")] ^.at 1 Just "hello"at 1 ?~ "hello" $ Map.emptyfromList [(1,"hello")] type  i =  ( i)Every  is a valid  and a valid  U. Adjust the target of an ' returning the intermediate result, or ! adjust all of the targets of an  U 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 (~ ) or even (k).   () :: + i s t a b -> (i -> a -> b) -> s -> (b, t)  () :: Monoid b =>  U+ i s t a b -> (i -> a -> b) -> s -> (b, t) Adjust the target of an & returning a supplementary result, or ! adjust all of the targets of an  U and return a monoidal summary . of the supplementary results and the answer.  () = b   () :: # f => / i s t a b -> (i -> a -> f b) -> s -> f t  () :: # f =>  U* i s t a b -> (i -> a -> f b) -> s -> f t ]In particular, it is often useful to think of this function as having one of these even more  restrictive type signatures   () :: 5 i s t a b -> (i -> a -> (r, b)) -> s -> (r, t)  () :: Monoid r =>  U0 i s t a b -> (i -> a -> (r, b)) -> s -> (r, t) Adjust the target of an & returning a supplementary result, or ! adjust all of the targets of an  U within the current state, and 9 return a monoidal summary of the supplementary results.  l  f =  (l  f)   () ::  s m 2 i s s a b -> (i -> a -> (r, b)) -> s -> m r  () :: ( s m, Monoid r) =>  U- i s s a b -> (i -> a -> (r, b)) -> s -> m r Adjust the target of an ' returning the intermediate result, or ! adjust all of the targets of an  U within the current state, and 8 return a monoidal summary of the intermediate results.   () ::  s m ( i s s a b -> (i -> a -> b) -> m b  () :: ( s m, Monoid b) =>  U# i s s a b -> (i -> a -> b) -> m b HThis lens can be used to change the result of a function but only where $ the arguments match the key given. ,let f = (+1) % resultAt 3 .~ 8 in (f 2, f 3)(3,8) "rank 2 types, MPTCs, TFs, flexible provisionalEdward Kmett <ekmett@gmail.com> Trustworthy type  i =  ( i)Useful for storage. Allows $ of the value at the largest index. & of the element at the largest index. Allows " the value at the smallest index. ) of the element with the smallest index. type  i =  ( i)#Every indexed traversal is a valid : or X. The d constraint is used to allow an  to be used directly as a :. The :" laws are still required to hold. Traversal with an index. NB: When you don'8t need access to the index then you can just apply your   directly as a function!     "a b   l =  l   =      :: / i s t a b -> (i -> a -> f b) -> s -> f t   :: * i s t a b -> (i -> a -> f b) -> s -> f t 3Traverse with an index (and the arguments flipped)     l a "a  l a     "a  .      :: / i s t a b -> s -> (i -> a -> f b) -> f t   :: * i s t a b -> s -> (i -> a -> f b) -> f t HMap each element of a structure targeted by a lens to a monadic action, Q evaluate these actions from left to right, and collect the results, with access  its position.  When you don't need access to the index mapMOf( is more liberal in what it can accept.   l "a  l      ::  m => / i s t a b -> (i -> a -> m b) -> s -> m t   ::  m => * i s t a b -> (i -> a -> m b) -> s -> m t HMap each element of a structure targeted by a lens to a monadic action, Q evaluate these actions from left to right, and collect the results, with access + its position (and the arguments flipped).     l a "a  l a     "a        ::  m => / i s t a b -> s -> (i -> a -> m b) -> m t   ::  m => * i s t a b -> s -> (i -> a -> m b) -> m t  Generalizes  to an arbitrary  with access to the index. ' accumulates state from right to left.   l "a  l      :: ? i s t a b -> (i -> s -> a -> (s, b)) -> s -> s -> (s, t)   :: : i s t a b -> (i -> s -> a -> (s, b)) -> s -> s -> (s, t)  Generalizes  to an arbitrary  with access to the index. ' accumulates state from left to right.   l "a  l      :: ? i s t a b -> (i -> s -> a -> (s, b)) -> s -> s -> (s, t)   :: : i s t a b -> (i -> s -> a -> (s, b)) -> s -> s -> (s, t) Access the element of an & where the index matches a predicate. Oover (iwhereOf (indexed traverse) (>0)) reverse $ ["He","was","stressed","o_O"]["He","saw","desserts","O_o"]    ::  IndexedFold i s a -> (i -> ) ->  IndexedFold i s a   ::  IndexedGetter i s a -> (i -> ) ->  IndexedFold i s a   ::  i s a -> (i -> ) ->  i s a   ::  i s a -> (i -> ) ->  i s a   :: SimpleIndexedSetter i s a -> (i -> ) -> SimpleIndexedSetter i s a +Traverse the value at a given key in a map  k =  k f This provides a  Traversal) that checks a predicate on a key before ( allowing you to traverse into a value.  "rank 2 types, MPTCs, TFs, flexible provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred type  i =  ( i)Useful for storage. type  i =  ( i)Every  is a valid Setter The 8" laws are still required to hold. Map with index. /When you do not need access to the index, then mapOf( is more liberal in what it can accept.   l "a  l      :: ) i s t a b -> (i -> a -> b) -> s -> t   ::  V+ i s t a b -> (i -> a -> b) -> s -> t   ::  U& i s t a b -> (i -> a -> b) -> s -> t %Map with index. This is an alias for . /When you do not need access to the index, then over( is more liberal in what it can accept.   l "a  l      :: ) i s t a b -> (i -> a -> b) -> s -> t   ::  V+ i s t a b -> (i -> a -> b) -> s -> t   ::  U& i s t a b -> (i -> a -> b) -> s -> t  Build an  from an imap-like function. Your supplied function f is required to satisfy:    f  "a   f g  f h "a f (g  h) Equational reasoning:       "a      "a  Another way to view sets is that it takes a "semantic editor combinator"  and transforms it into a Setter. Adjust every target of an ,  V or  U  with access to the index.  () "a /When you do not need access to the index then ()) is more liberal in what it can accept.  l k f "a l   f   () :: ) i s t a b -> (i -> a -> b) -> s -> t  () ::  V+ i s t a b -> (i -> a -> b) -> s -> t  () ::  U& i s t a b -> (i -> a -> b) -> s -> t /Adjust every target in the current state of an ,  V or  U  with access to the index. /When you do not need access to the index then (u)) is more liberal in what it can accept.  l u f "a l   f   () ::  s m => ' i s s a b -> (i -> a -> b) -> m ()  () ::  s m =>  V) i s s a b -> (i -> a -> b) -> m ()  () ::  s m =>  U$ i s t a b -> (i -> a -> b) -> m ()    Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred type  =  A  s t a b is almost a 2. It can be composed on the left of other lenses,  you can use  to promote it to a ), and it provides a minimalist lens-like ^ interface. They can be used in an API where you need to pass around lenses inside containers ! or as monadic results. Unlike a }. they can be composed and used directly, but & they are slightly lower performance. A -specific version of () A -specific version of f A -specific version of () A -specific version of (k) A -specific version of () A -specific version of () A -specific version of (u) Modify the target of a  and return the result. Modify the target of a  into your monad';s state by a user supplied function and return the result. Modify the target of a > in the current monadic state, returning an auxillary result. Replace the target of a  and return the new value. Replace the target of a 8 in the current monadic state, returning the new value.   Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred,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 _2 .~ "hello" $ (1,(),3,4)(1,"hello",3,4)     :: (s -> ) -> (a, s) ->      :: ( Applicative f, . t) => (a -> f b) -> t (s, a) -> f (t (s, b))   (  ) :: ( t, ! m) => (s -> m) -> t (b, s) -> m )Provides access to 1st field of a tuple. @Access the 1st field of a tuple (and possibly change its type).  (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-Inferred* type  = R :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 = R A Simple Setter is just a  that doesn't change the types. IThese are particularly common when talking about monomorphic containers. e.g.   Data.Text.map ::    type  = R  Running a % instantiates it to a concrete type. WWhen consuming a setter directly to perform a mapping, you can use this type, but most + user code will not need to use this type.  By choosing   rather than , we get nicer error messages.  The only ;-like law that can apply to a  l is that   l y ( l x a) "a  l y aYou can't view a 3 in general, so the other two laws are irrelevant.  However, two # laws apply to a :     l  "a    l f   l g "a  l (f  g) "These an be stated more directly:    l pure "a pure  l f .  . l g "a l (f .  . g) You can compose a  with a ; or a : using () from the Prelude ! and the result is always only a  and nothing more. ;This setter can be used to map over all of the values in a #.    ( "a     "a    (<$) "a   over mapped (+1) [1,2,3][2,3,4]set mapped () [1,2,3] [(),(),()]#mapped.mapped %~ (+1) $ [[1,2],[3]] [[2,3],[4]]=over (mapped._2) length [("hello","world"),("leaders","!!!")][("hello",5),("leaders",3)]9This setter can be used to modify all of the values in a . ,You sometimes have to use this, rather than , because due to  temporary insanity # is not a superclass of .     "a   over lifted (+1) [1,2,3][2,3,4])Build a Setter from a map-like function. Your supplied function f is required to satisfy:    f  "a   f g  f h "a f (g  h) Equational reasoning:       "a      "a  Another way to view  is that it takes a "semantic editor combinator"  and transforms it into a . Modify the target of a ; or all the targets of a  or :  with a function.    ( "a     "a       "a      "a  over mapped (*10) [1,2,3] [10,20,30]over _1 show (10,20) ("10",20)Another way to view " is to say that it transformers a  into a  "semantic editor combinator".  ::  s t a b -> (a -> b) -> s -> tModify the target of a ; or all the targets of a  or : ' with a function. This is an alias for # that is provided for consistency.     "a   ( "a     fmapDefault "a  traverse     "a      "a  mapOf mapped (+1) [1,2,3,4] [2,3,4,5]mapOf _1 (+1) (1,2)(2,2)mapOf both (+1) (1,2)(2,3)    :: $ s t a b -> (a -> b) -> s -> t   :: Y' s t a b -> (a -> b) -> s -> t   :: ;& s t a b -> (a -> b) -> s -> t   :: :! s t a b -> (a -> b) -> s -> t Replace the target of a ; or all of the targets of a   or : with a constant value.  (<$) "a  set _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.    ::  s t a b -> b -> s -> t   :: Y s t a b -> b -> s -> t   :: ; s t a b -> b -> s -> t   :: : s t a b -> b -> s -> t Modifies the target of a ; or all of the targets of a  or  : with a user supplied function. This is an infix version of     ( f "a   f   f "a traverse  f _2 %~ length $ (1,"hello")(1,5)traverse %~ (+1) $ [1,2,3][2,3,4]_2 %~ (+1) $ (3,4)(3,5)9traverse.traverse %~ length $ [["hello","world"],["!!!"]] [[5,5],[3]]   () :: " s t a b -> (a -> b) -> s -> t  () :: Y% s t a b -> (a -> b) -> s -> t  () :: ;$ s t a b -> (a -> b) -> s -> t  () :: : s t a b -> (a -> b) -> s -> t Replace the target of a ; or all of the targets of a   or : with a constant value. This is an infix version of !, provided for consistency with ()  f <$ a "a   f  a_1 .~ "hello" $ (42,"world")("hello","world")   () ::  s t a b -> b -> s -> t  () :: Y s t a b -> b -> s -> t  () :: ; s t a b -> b -> s -> t  () :: : s t a b -> b -> s -> t Set the target of a ;, : or  to  a value.  l  t "a  l ( t)   () ::  s t a (+ b) -> b -> s -> t  () :: Y s t a (+ b) -> b -> s -> t  () :: ; s t a (+ b) -> b -> s -> t  () :: : s t a (+ b) -> b -> s -> t 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  t directly is a good idea. -_3 <.~ "world" $ ("good","morning","vietnam")$("world",("good","morning","world"))import Data.Map as MapK_2.at "hello" <.~ Just "world" $ (42,Map.fromList [("goodnight","gracie")])G(Just "world",(42,fromList [("goodnight","gracie"),("hello","world")]))   () ::  s t a b -> b -> s -> (b, t)  () :: Y# s t a b -> b -> s -> (b, t)  () :: ;" s t a b -> b -> s -> (b, t)  () :: : s t a b -> b -> s -> (b, t) Set to  a value with pass-through WThis is mostly present for consistency, but may be useful for for chaining assignments AIf you do not need a copy of the intermediate result, then using l  d directly is a good idea. import Data.Map as MapF_2.at "hello" <?~ "world" $ (42,Map.fromList [("goodnight","gracie")])B("world",(42,fromList [("goodnight","gracie"),("hello","world")]))   () ::  s t a b -> (+ b) -> s -> (b, t)  () :: Y s t a (+ b) -> b -> s -> (b, t)  () :: ; s t a (+ b) -> b -> s -> (b, t)  () :: : s t a (+ b) -> b -> s -> (b, t) 0Increment the target(s) of a numerically valued ;,  or : _1 +~ 1 $ (1,2)(2,2)both +~ 2 $ (5,6)(7,8)   () :: Num a => R  s a -> a -> s -> s  () :: Num a => R Y s a -> a -> s -> s  () :: Num a => R ; s a -> a -> s -> s  () :: Num a => R : s a -> a -> s -> s  /Multiply the target(s) of a numerically valued ;, Y,  or : _2 *~ 4 $ (1,2)(1,8)mapped *~ 2 $ Just 24Just 48   ( ) ::  a => R  s a -> a -> s -> s  ( ) ::  a => R Y s a -> a -> s -> s  ( ) ::  a => R ; s a -> a -> s -> s  ( ) ::  a => R : s a -> a -> s -> s  0Decrement the target(s) of a numerically valued ;, Y,  or : _1 -~ 2 $ (1,2)(-1,2)"mapped.mapped -~ 1 $ [[4,5],[6,7]] [[3,4],[5,6]]   ( ) ::  a => R  s a -> a -> s -> s  ( ) ::  a => R Y s a -> a -> s -> s  ( ) ::  a => R ; s a -> a -> s -> s  ( ) ::  a => R : s a -> a -> s -> s  -Divide the target(s) of a numerically valued ;, Y,  or : _2 //~ 2 $ ("Hawaii",10)("Hawaii",5.0)   ( ) ::  a => R  s a -> a -> s -> s  ( ) ::  a => R Y s a -> a -> s -> s  ( ) ::  a => R ; s a -> a -> s -> s  ( ) ::  a => R : s a -> a -> s -> s  ,Raise the target(s) of a numerically valued ;,  or :" to a non-negative integral power _2 ^~ 2 $ (1,3)(1,9)   ( ) :: ( a,  e) => R  s a -> e -> s -> s  ( ) :: ( a,  e) => R Y s a -> e -> s -> s  ( ) :: ( a,  e) => R ; s a -> e -> s -> s  ( ) :: ( a,  e) => R : s a -> e -> s -> s  -Raise the target(s) of a fractionally valued ;,  or : to an integral power _2 ^^~ (-1) $ (1,2)(1,0.5)   ( ) :: ( a,  e) => R  s a -> e -> s -> s  ( ) :: ( a,  e) => R Y s a -> e -> s -> s  ( ) :: ( a,  e) => R ; s a -> e -> s -> s  ( ) :: ( a,  e) => R : s a -> e -> s -> s /Raise the target(s) of a floating-point valued ;,  or : to an arbitrary power. _2 **~ pi $ (1,3)(1,31.54428070019754)   () ::  a => R  s a -> a -> s -> s  () ::  a => R Y s a -> a -> s -> s  () ::  a => R ; s a -> a -> s -> s  () ::  a => R : s a -> a -> s -> s  Logically  the target(s) of a -valued ; or  both ||~ True $ (False,True) (True,True)both ||~ False $ (False,True) (False,True)   () :: R  s  ->  -> s -> s  () :: R Y s  ->  -> s -> s  () :: R ; s  ->  -> s -> s  () :: R : s  ->  -> s -> s  Logically  the target(s) of a -valued ; or  both &&~ True $ (False, True) (False,True)both &&~ False $ (False, True) (False,False)   () :: R  s  ->  -> s -> s  () :: R Y s  ->  -> s -> s  () :: R ; s  ->  -> s -> s  () :: R : s  ->  -> s -> s Replace the target of a ; or all of the targets of a  or : in our monadic 2 state with a new value, irrespective of the old. This is an alias for ().    ::  s m => R Y s a -> a -> m ()   ::  s m => R ; s a -> a -> m ()   ::  s m => R : s a -> a -> m ()   ::  s m => R  s a -> a -> m () Replace the target of a ; or all of the targets of a  or : in our monadic 2 state with a new value, irrespective of the old. This is an infix version of .    () ::  s m => R Y s a -> a -> m ()  () ::  s m => R ; s a -> a -> m ()  () ::  s m => R : s a -> a -> m ()  () ::  s m => R  s a -> a -> 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 : in our monadic state.   () ::  s m => R Y s a -> (a -> a) -> m ()  () ::  s m => R ; s a -> (a -> a) -> m ()  () ::  s m => R : s a -> (a -> a) -> m ()  () ::  s m => R  s a -> (a -> a) -> m () Replace the target of a ; or all of the targets of a  or : in our monadic  state with ' a new value, irrespective of the old.   () ::  s m => R Y s (+ a) -> a -> m ()  () ::  s m => R ; s (+ a) -> a -> m ()  () ::  s m => R : s (+ a) -> a -> m ()  () ::  s m => R  s (+ a) -> a -> m () Modify the target(s) of a R ;, Y,  or : by adding a value  Example:   $ fresh :: MonadState Int m => m Int  fresh = do    1  use     () :: ( s m,  a) => R  s a -> a -> m ()  () :: ( s m,  a) => R Y s a -> a -> m ()  () :: ( s m,  a) => R ; s a -> a -> m ()  () :: ( s m,  a) => R : s a -> a -> m () Modify the target(s) of a R ;, Y,  or : by subtracting a value   () :: ( s m,  a) => R  s a -> a -> m ()  () :: ( s m,  a) => R Y s a -> a -> m ()  () :: ( s m,  a) => R ; s a -> a -> m ()  () :: ( s m,  a) => R : s a -> a -> m () Modify the target(s) of a R ;, Y,  or : by multiplying by value.   () :: ( s m,  a) => R  s a -> a -> m ()  () :: ( s m,  a) => R Y s a -> a -> m ()  () :: ( s m,  a) => R ; s a -> a -> m ()  () :: ( s m,  a) => R : s a -> a -> m () Modify the target(s) of a R ;, Y,  or : by dividing by a value.   () :: ( s m,  a) => R  s a -> a -> m ()  () :: ( s m,  a) => R Y s a -> a -> m ()  () :: ( s m,  a) => R ; s a -> a -> m ()  () :: ( s m,  a) => R : s a -> a -> m () ,Raise the target(s) of a numerically valued ;,  or :# to a non-negative integral power.   () :: ( s m,  a,  e) => R  s a -> e -> m ()  () :: ( s m,  a,  e) => R Y s a -> e -> m ()  () :: ( s m,  a,  e) => R ; s a -> e -> m ()  () :: ( s m,  a,  e) => R : s a -> e -> m () ,Raise the target(s) of a numerically valued ;,  or : to an integral power.   () :: ( s m,  a,  e) => R  s a -> e -> m ()  () :: ( s m,  a,  e) => R Y s a -> e -> m ()  () :: ( s m,  a,  e) => R ; s a -> e -> m ()  () :: ( s m,  a,  e) => R : s a -> e -> m () ,Raise the target(s) of a numerically valued ;,  or : to an arbitrary power   () :: ( s m,  a) => R  s a -> a -> m ()  () :: ( s m,  a) => R Y s a -> a -> m ()  () :: ( s m,  a) => R ; s a -> a -> m ()  () :: ( s m,  a) => R : s a -> a -> m () Modify the target(s) of a R ;, Y,  or : by taking their logical  with a value   () ::  s m => R  s  ->  -> m ()  () ::  s m => R Y s  ->  -> m ()  () ::  s m => R ; s  ->  -> m ()  () ::  s m => R : s  ->  -> m () Modify the target(s) of a R ;, 'Iso,  or : by taking their logical  with a value   () ::  s m => R  s  ->  -> m ()  () ::  s m => R Y s  ->  -> m ()  () ::  s m => R ; s  ->  -> m ()  () ::  s m => R : s  ->  -> m () 6Run a monadic action, and set all of the targets of a ;,  or : to its result.    () ::  s m => Y s s a b -> m b -> m ()  () ::  s m => ; s s a b -> m b -> m ()  () ::  s m => : s s a b -> m b -> m ()  () ::  s m =>  s s a b -> m b -> 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 :. 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   () ::  s m =>  s s a b -> b -> m b  () ::  s m => Y s s a b -> b -> m b  () ::  s m => ; s s a b -> b -> m b  () ::  s m => : s s a b -> b -> m b  Set  a value with pass-through XThis is useful for chaining assignment without round-tripping through your monad stack.  do x <- at foo <*?= 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   ( ) ::  s m =>  s s a (+ b) -> b -> m b  ( ) ::  s m => Y s s a (+ b) -> b -> m b  ( ) ::  s m => ; s s a (+ b) -> b -> m b  ( ) ::  s m => : s s a (+ b) -> b -> m b ,      .       .       *       Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Trustworthy!*Useful for storing getters in containers. $Most %- combinators are able to be used with both a % or a  W2 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 ;, : and  Y. we also restricted choices of the irrelevant t and  b parameters. If a function accepts a $ r s t a b , then when r is a Monoid, then  you can pass a W (or  :&), 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 -> s).  Moreover, a % can be used directly as a W,  since it just ignores the  Applicative. &^Passes the result of the left side to the function on the right side (forward pipe operator).  This is the flipped version of (+), which is more common in languages like F# as (|>) where it is needed e for inference. Here it is supplied for notational convenience and given a precedence that allows it  to be nested inside uses of (). "hello" % length % succ6'A version of (=) with much tighter precedence that can be interleaved with (,) "hello"^%length5import Data.List.Lens%("hello","world")^._1^%reverse^._head'o'(Build a %% from an arbitrary Haskell function.  ( f . ( g = ( (g . f) a , ( f = f a("hello","world")^.to snd"world" 5^.to succ6(0, -5)^._2.to abs5)View the value pointed to by a %, Y or  ;4 or the result of folding over all the results of a  W or : that points  at a monoidal values.  ) . ( = view _2 (1,"hello")"hello"view (to succ) 56&view (_2._1) ("hello",("world","!!!"))"world"It may be useful to think of )) as having one of these more restrictive  signatures:   ) :: % s a -> s -> a  ) :: Monoid m => W s m -> s -> m  ) :: R Y s a -> s -> a  ) :: R ; s a -> s -> a  ) :: Monoid m => R : s m -> s -> m *View the value of a %, Y,  ;5 or the result of folding over the result of mapping  the targets of a W or  :. It may be useful to think of *" as having these more restrictive  signatures:  * l f = ) (l  ( f)views _2 length (1,"hello")5   * :: %' s a -> (a -> r) -> s -> r  * :: Monoid m => W) s a -> (a -> m) -> s -> m  * :: R Y# s a -> (a -> r) -> s -> r  * :: R ;" s a -> (a -> r) -> s -> r  * :: Monoid m => R : s a -> (a -> m) -> s -> m +View the value pointed to by a %, Y or  ;4 or the result of folding over all the results of a  W or : that points  at a monoidal values. This is the same operation as ), only infix.  ( f + x = f x_2 ^$ (1, "hello")"hello"   (+) :: % s a -> s -> a  (+) :: Monoid m => W s m -> s -> m  (+) :: R Y s a -> s -> a  (+) :: R ; s a -> s -> a  (+) :: Monoid m => R : s m -> s -> m ,View the value pointed to by a % or ; or the - result of folding over all the results of a W or  :# 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 () ("hello","world")^._2"world"import Data.Complex$((0, 1 :+ 2), 3)^._1._2.to magnitude2.23606797749979   (,) :: s -> % s a -> a  (,) :: Monoid m => s -> W s m -> m  (,) :: s -> R Y s a -> a  (,) :: s -> R ; s a -> a  (,) :: Monoid m => s -> R : s m -> m -Use the target of a ;, Y, or  %- in the current state, or use a summary of a  W or : that points  to a monoidal value.   - ::  s m => % s a -> m a  - :: ( s m, Monoid r) => W s r -> m r  - ::  s m => R Y s a -> m a  - ::  s m => R ; s a -> m a  - :: ( s m, Monoid r) => R : s r -> m r .Use the target of a ;, Y or  %- in the current state, or use a summary of a  W or : that  points to a monoidal value.   . ::  s m => %" s a -> (a -> r) -> m r  . :: ( s m, Monoid r) => W$ s a -> (a -> r) -> m r  . ::  s m => R ; s a -> (a -> r) -> m r  . ::  s m => R Y s a -> (a -> r) -> m r  . :: ( s m, Monoid r) => R : s a -> (a -> r) -> m r /Query the target of a ;, Y or  %- in the current state, or use a summary of a  W or : that points  to a monoidal value.   / ::  s m => % s a -> m a  / :: ( s m, Monoid a) => W s a -> m a  / ::  s m => R Y s a -> m a  / ::  s m => R ; s a -> m a  / :: ( s m, Monoid a) => R : s a -> m a 0Use the target of a ;, Y or  %- in the current state, or use a summary of a  W or : that points  to a monoidal value.   0 ::  s m => %" s a -> (a -> r) -> m r  0 :: ( s m, Monoid a) => W$ s a -> (a -> r) -> m r  0 ::  s m => R Y s a -> (a -> r) -> m r  0 ::  s m => R ; s a -> (a -> r) -> m r  0 :: ( s m, Monoid a) => R : s a -> (a -> r) -> m r !"#$%&'()*+,-./0!"#$%&'()*+,-./0%$(,+&')*-./0!"#!"#$%&'()*+,-./0 Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred 1 type 1 =  22/Useful for storing isomorphisms in containers. 5 type 5 =  66EIsomorphism 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 ((),)  type 6 s t a b = forall k f. ( k, # f) =>  k f s t a b7@Build an isomorphism family from two pairs of inverse functions    ) (7 sa as tb bt) "a sa  ) ( (7 sa as tb bt)) "a as   (7 sa as tb bt) ab "a bt  ab  sa   ( (7 ac ca bd db' )) ab "a bd  ab  ca  8isos :: (s -> a) -> (a -> s) -> (t -> b) -> (b -> t) -> 6 s t a b8<Build a simple isomorphism from a pair of inverse functions    ) (8 f g) "a f  ) ( (8 f g)) "a g   (7 f g) h "a g  h  f   ( (8 f g' )) h "a f  h  g  iso :: (s -> a) -> (a -> s) ->  6 s a9 Based on ala from Conor McBride's work on Epigram. #:m + Data.Monoid.Lens Data.Foldableala _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 9" with an extra function argument. ;The opposite of working  a Setter is working ; an Isomorphism.  ; =    ; :: 6 s t a b -> (s -> t) -> a -> b<:This isomorphism can be used to wrap or unwrap a value in ".   x^.identity "a " x  " x ,  < "a x =:This isomorphism can be used to wrap or unwrap a value in &   x , = "a & x  & x ,  = "a x >CComposition with this isomorphism is occasionally useful when your ,  : or 6 has a constraint on an unused 3 argument to force that argument to agree with the # type of a used argument and avoid ScopedTypeVariables or other ugliness. 123456789:;<=>123456789:;<=>6879:;=<>23451 123456789:;<=> Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred?*This is a commonly-used infix alias for a R 6 @*This is a commonly-used infix alias for a R :. A*This is a commonly used infix alias for a R ;. ?@A?@AA@??@Aportable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferredBThis % can be used to change the type of a  by mapping  the elements to new values. Sadly, you can't create a valid : for a , but you can  manipulate it by reading using  and reindexing it via B. (over setmapped (+1) (fromList [1,2,3,4])fromList [2,3,4,5]CConstruct a set from a %, W, :, ; or Y. 5setOf (folded._2) [("hello",1),("world",2),("!!!",3)]fromList [1,2,3]   C :: % s a -> s ->  a  C ::  a => W s a -> s ->  a  C :: R Y s a -> s ->  a  C :: R ; s a -> s ->  a  C ::  a => R : s a -> s ->  a BCBCBCBC non-portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred D type D =  IE A concrete IB, suitable for storing in a container or extracting an embedding. G,Used to provide overloading of projections. IA I is a  Traversal% that can also be turned around with L to obtain a % JCompose projections. K Reflect a I. LTurn a I around to get an embedding MBuild a I N Convert an 6 to a I. #Ideally we would be able to use an 6 directly as a I!, but this opens a can of worms. DEFGHIJKLMN DEFGHIJKLMN IGHKLEFMJND DEFGHIJKLMN Rank2Types provisionalEdward Kmett <ekmett@gmail.com> TrustworthyOThis class allows us to use P? part of the environment, changing the environment supplied by + many different monad transformers. Unlike RG this can change the environment of a deeply nested monad transformer.  Also, unlike R", this can be used with any valid %, but cannot be used with a  Traversal or Fold. PMRun 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:   P :: % s a -> (a -> r) -> s -> r  P :: $ c => Fold s a -> (a -> r) -> s -> r  P :: $ w % s t ->  s w st c ->  t w st c  P :: ($ w, $ c) => Fold s t ->  s w st c ->  t w st c  ... QThis class allows us to use R$ in, changing the State supplied by Y many different monad transformers, potentially quite deep in a monad transformer stack. R?Run a monadic action in a larger state than it was defined in,  using a   or  :. 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 : 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!   R ::  m =>   s t ->  t m a ->  s m a  R :: ( m, $ c) =>  : s t ->  t m c ->  s m c  R ::  m =>   s t ->  r w t m c ->  r w s m c  R :: ( m, $ c) =>  : s t ->  r w t m c ->  r w s m c  R ::  m =>   s t ->  e ( r w t m c) ->  e ( r w s m c)  R :: ( m, $ c) =>  : s t ->  e ( r w t m c) ->  e ( r w s m c)  ...  P = *OPQROPQROPQROPQRportable provisionalEdward Kmett <ekmett@gmail.com>NoneSThis % can be used to change the type of a  by mapping  the elements to new values. Sadly, you can't create a valid : for a Set, but you can  manipulate it by reading using folded and reindexing it via S. (over setmapped (+1) (fromList [1,2,3,4])fromList [2,3,4,5]TConstruct a set from a %, W, :, ; or Y. 5setOf (folded._2) [("hello",1),("world",2),("!!!",3)]fromList [1,2,3]   T ::  a => % s a -> s ->  a  T :: ( a,  a) => W s a -> s ->  a  T ::  a => R Y s a -> s ->  a  T ::  a => R ; s a -> s ->  a  T :: ( a,  a) => R : s a -> s ->  a STSTSTST Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred5U(Useful for storing folds in containers. XA XI describes how to retrieve multiple values in a way that can be composed % with other lens-like constructions. A X s aC provides a structure with operations very similar to those of the   typeclass, see d and the other X combinators. !By convention, if there exists a foo method that expects a  (f a), then there should be a  fooOf method that takes a X s a and a value of type s. A % is a legal X that just ignores the supplied $  Unlike a : a X is read-only. Since a X cannot be used to write back $ there are no lens laws that apply. Y Obtain a X9 by lifting an operation that returns a foldable result. +This can be useful to lift operations from  Data.List and elsewhere into a X. Z Obtain a X from any . [%Fold by repeating the input forever.  "a h [\!A fold that replicates its input n times.   n "a h (\ n)]ITransform a fold into a fold that loops over its elements over and over. +take 6 $ toListOf (cycled traverse) [1,2,3] [1,2,3,1,2,3]^2Build a fold that unfolds its values from a seed.  "a h . ^_x ^. _ f5 Return an infinite fold of repeated applications of f to x. h (_ f) a "a   f a` Obtain a X- that can be composed with to filter another , Y, %, X (or :) Note: This is not a legal :M, unless you are very careful not to invalidate the predicate on the target. *As a counter example, consider that given evens = `   the second : law is violated:  over evens    over evens   /= over evens (    ),So, in order for this to qualify as a legal  TraversalL you can only use it for actions that preserve the result of the predicate! ` :: (a -> ) -> X a aa.This allows you to traverse the elements of a : or X in the opposite order.  This will demote an  U or X to a regular : or X, + repectively; to preserve the indices, use  instead. Note: a should have no impact on a %, 8,  or Y. To change the direction of an Y, use . b Obtain a X! by taking elements from another X, , Y, % or : while a predicate holds.    p "a h (b p Z))toListOf (takingWhile (<=3) folded) [1..][1,2,3]c Obtain a X# by dropping elements from another X, , Y, % or : while a predicate holds.   p "a h (c p Z),toListOf (droppingWhile (<=3) folded) [1..6][4,5,6]-toListOf (droppingWhile (<=3) folded) [1,6,1][6,1]d  = d Z d "a *   d :: %% s a -> (a -> r) -> s -> r  d :: $ r => X' s a -> (a -> r) -> s -> r  d ::   s a -> (a -> r) -> s -> r  d ::  Y! s a -> (a -> r) -> s -> r  d :: $ r =>  : s a -> (a -> r) -> s -> r e  = e Z e "a )   e :: % s m -> s -> m  e :: $ m => X s m -> s -> m  e ::   s m -> s -> m  e ::  Y s m -> s -> m  e :: $ m =>  : s m -> s -> m fIRight-associative fold of parts of a structure that are viewed through a , %, X or :.   "a f Z   f :: %/ s a -> (a -> r -> r) -> r -> s -> r  f :: X1 s a -> (a -> r -> r) -> r -> s -> r  f ::  * s a -> (a -> r -> r) -> r -> s -> r  f ::  Y+ s a -> (a -> r -> r) -> r -> s -> r  f ::  :% s a -> (a -> r -> r) -> r -> s -> r gLLeft-associative fold of the parts of a structure that are viewed through a , %, X or :.   "a g Z   g :: %/ s a -> (r -> a -> r) -> r -> s -> r  g :: X1 s a -> (r -> a -> r) -> r -> s -> r  g ::  * s a -> (r -> a -> r) -> r -> s -> r  g ::  Y+ s a -> (r -> a -> r) -> r -> s -> r  g ::  :% s a -> (r -> a -> r) -> r -> s -> r h#Extract a list of the targets of a X . See also (i).    "a h Z  (i) "a  h i(A convenient infix (flipped) version of h. [[1,2],[3]]^..traverse.traverse[1,2,3] (1,2)^..both[1,2]    xs "a xs i Z  (i) "a  h    (i ) :: s -> % s a -> [a]  (i ) :: s -> X s a -> [a]  (i ) :: s ->   s a -> [a]  (i ) :: s ->  Y s a -> [a]  (i ) :: s ->  : s a -> [a] jReturns  if every target of a X is . andOf both (True,False)FalseandOf both (True,True)True  "a j Z   j :: % s  -> s ->   j :: X s  -> s ->   j ::   s  -> s ->   j ::  Y s  -> s ->   j ::  : s  -> s ->  kReturns  if any target of a X is . orOf both (True,False)TrueorOf both (False,False)False  "a k Z   k :: % s  -> s ->   k :: X s  -> s ->   k ::   s  -> s ->   k ::  Y s  -> s ->   k ::  : s  -> s ->  lReturns  if any target of a X satisfies a predicate. anyOf both (=='x') ('x','y')Trueimport Data.Data.Lens=anyOf biplate (== "world") (((),2::Int),"hello",("world",11))True  "a l Z   l :: % s a -> (a ->  ) -> s ->   l :: X s a -> (a ->  ) -> s ->   l ::   s a -> (a ->  ) -> s ->   l ::  Y s a -> (a ->  ) -> s ->   l ::  : s a -> (a ->  ) -> s ->  mReturns  if every target of a X satisfies a predicate. allOf both (>=3) (4,5)TrueallOf folded (>=2) [1..10]False  "a m Z   m :: % s a -> (a ->  ) -> s ->   m :: X s a -> (a ->  ) -> s ->   m ::   s a -> (a ->  ) -> s ->   m ::  Y s a -> (a ->  ) -> s ->   m ::  : s a -> (a ->  ) -> s ->  n4Calculate the product of every number targeted by a X productOf both (4,5)20productOf folded [1,2,3,4,5]120  "a n Z   n :: % s a -> s -> a  n ::  a => X s a -> s -> a  n ::   s a -> s -> a  n ::  Y s a -> s -> a  n ::  a =>  : s a -> s -> a o0Calculate the sum of every number targeted by a X. sumOf both (5,6)11sumOf folded [1,2,3,4]10!sumOf (folded.both) [(1,2),(3,4)]10import Data.Data.Lens8sumOf biplate [(1::Int,[]),(2,[(3::Int,4::Int)])] :: Int10  "a o Z   o _1 :: (a, b) -> a  o (Z . _1) :: ( f,  a) => f (a, b) -> a    o :: % s a -> s -> a  o ::  a => X s a -> s -> a  o ::   s a -> s -> a  o ::  Y s a -> s -> a  o ::  a =>  : s a -> s -> a p&Traverse over all of the targets of a X (or %), computing an % (or #) -based answer,  but unlike # do not construct a new structure. p generalizes   to work over any X. When passed a %, p can work over any #, but when passed a X, p requires  an %. +traverseOf_ both putStrLn ("hello","world")helloworld  "a p Z   p _2 :: ## f => (c -> f r) -> (d, c) -> f ()  p  :: % f => (a -> f b) -> * a c -> f () !The rather specific signature of p6 allows it to be used as if the signature was any of:   p :: # f => %* s a -> (a -> f r) -> s -> f ()  p :: % f => X, s a -> (a -> f r) -> s -> f ()  p :: # f =>  % s a -> (a -> f r) -> s -> f ()  p :: # f =>  Y& s a -> (a -> f r) -> s -> f ()  p :: % f =>  : s a -> (a -> f r) -> s -> f () q&Traverse over all of the targets of a X (or %), computing an % (or #) -based answer,  but unlike # do not construct a new structure. q generalizes   to work over any X. When passed a %, q can work over any #, but when passed a X, q requires  an %.   "a q Z!The rather specific signature of q6 allows it to be used as if the signature was any of:   q :: # f => %* s a -> s -> (a -> f r) -> f ()  q :: % f => X, s a -> s -> (a -> f r) -> f ()  q :: # f =>  % s a -> s -> (a -> f r) -> f ()  q :: # f =>  Y& s a -> s -> (a -> f r) -> f ()  q :: % f =>  : s a -> s -> (a -> f r) -> f () r&Evaluate each action in observed by a X: on a structure from left to right, ignoring the results.   "a r Z   r :: # f => %! s (f ()) -> s -> f ()  r :: % f => X# s (f ()) -> s -> f ()  r :: # f =>   s (f ()) -> s -> f ()  r :: # f =>  Iso s (f ()) -> s -> f ()  r :: % f =>  : s (f ()) -> s -> f () sMap each target of a Xh on a structure to a monadic action, evaluate these actions from left to right, and ignore the results.  ? "a s Z   s ::  m => %* s a -> (a -> m r) -> s -> m ()  s ::  m => X, s a -> (a -> m r) -> s -> m ()  s ::  m =>  % s a -> (a -> m r) -> s -> m ()  s ::  m =>  Y& s a -> (a -> m r) -> s -> m ()  s ::  m =>  : s a -> (a -> m r) -> s -> m () tt is s$ with two of its arguments flipped.   "a t Z   t ::  m => %* s a -> s -> (a -> m r) -> m ()  t ::  m => X, s a -> s -> (a -> m r) -> m ()  t ::  m =>  % s a -> s -> (a -> m r) -> m ()  t ::  m =>  Y& s a -> s -> (a -> m r) -> m ()  t ::  m =>  : s a -> s -> (a -> m r) -> m () u-Evaluate each monadic action referenced by a X> on the structure from left to right, and ignore the results.   "a u Z   u ::  m => % s (m a) -> s -> m ()  u ::  m => X" s (m a) -> s -> m ()  u ::  m =>   s (m a) -> s -> m ()  u ::  m =>  Y s (m a) -> s -> m ()  u ::  m =>  : s (m a) -> s -> m () v1The sum of a collection of actions, generalizing {.   "a v Z   v ::  f => % s a -> s -> f a  v ::  f => X s a -> s -> f a  v ::  f =>   s a -> s -> f a  v ::  f =>  Y s a -> s -> f a  v ::  f =>  : s a -> s -> f a w1The sum of a collection of actions, generalizing {.   "a w Z   w ::  m => % s a -> s -> m a  w ::  m => X s a -> s -> m a  w ::  m =>   s a -> s -> m a  w ::  m =>  Y s a -> s -> m a  w ::  m =>  : s a -> s -> m a x/Does the element occur anywhere within a given X of the structure? %elemOf both "hello" ("hello","world")True  "a x Z   x ::  a => % s a -> a -> s ->   x ::  a => X s a -> a -> s ->   x ::  a =>   s a -> a -> s ->   x ::  a =>  Y s a -> a -> s ->   x ::  a =>  : s a -> a -> s ->  y3Does the element not occur anywhere within a given X of the structure?   "a y Z   y ::  a => % s a -> a -> s ->   y ::  a => X s a -> a -> s ->   y ::  a =>  Y s a -> a -> s ->   y ::  a =>   s a -> a -> s ->   y ::  a =>  : s a -> a -> s ->  z)Map a function over all the targets of a X5 of a container and concatenate the resulting lists.   "a z Z   z :: % s a -> (a -> [r] ) -> s -> [r]  z :: X s a -> (a -> [r] ) -> s -> [r]  z ::   s a -> (a -> [r] ) -> s -> [r]  z ::  Y s a -> (a -> [r] ) -> s -> [r]  z ::  : s a -> (a -> [r] ) -> s -> [r] {+Concatenate all of the lists targeted by a X into a longer list. concatOf both ("pan","ama")"panama"    "a { Z  { "a )    { :: % s [r] -> s -> [r]  { :: X s [r] -> s -> [r]  { ::  Y s [r] -> s -> [r]  { ::   s [r] -> s -> [r]  { ::  : s [r] -> s -> [r] |;Note: this can be rather inefficient for large containers.   "a | ZlengthOf _1 ("hello",())1 | (Z . Z) ::  f => f (g a) -> )   | :: % s a -> s -> )  | :: X s a -> s -> )  | ::   s a -> s -> )  | ::  Y s a -> s -> )  | ::  : s a -> s -> ) }Perform a safe  of a X or : or retrieve  the result  from a % or  . See also (~).     "a } Z   } :: % s a -> s -> + a  } :: X s a -> s -> + a  } ::   s a -> s -> + a  } ::  Y s a -> s -> + a  } ::  : s a -> s -> + a ~Perform a safe  of a X or : or retrieve  the result  from a % or .  When using a : as a partial , or a X as a partial % this can be a convenient $ way to extract the optional value.  (~) "a  }   (~ ) :: s -> % s a -> + a  (~ ) :: s -> X s a -> + a  (~ ) :: s ->   s a -> + a  (~ ) :: s ->  Y s a -> + a  (~ ) :: s ->  : s a -> + a Perform a safe  of a X or : or retrieve  the result  from a % or .    :: % s a -> s -> + a   :: X s a -> s -> + a   ::   s a -> s -> + a   ::  Y s a -> s -> + a   ::  : s a -> s -> + a Returns  if this X or :( has no targets in the given container. Note:  on a valid Y,  or % should always return     "a  Z/This may be rather inefficient compared to the   check of many containers. nullOf _1 (1,2)False  (Z  _1  Z) ::  f => f (g a, b) ->     :: % s a -> s ->    :: X s a -> s ->    ::  Y s a -> s ->    ::   s a -> s ->    ::  : s a -> s ->  2Obtain the maximum element (if any) targeted by a X or : Note: maximumOf on a valid Y,  or % will always return  a value.  ! "a " (# empty)   Z    :: % s a -> s -> + a   ::  a => X s a -> s -> + a   ::  Y s a -> s -> + a   ::   s a -> s -> + a   ::  a =>  : s a -> s -> + a 2Obtain the minimum element (if any) targeted by a X or : Note: minimumOf on a valid Y,  or % will always return  a value.  $ "a " (# empty)   Z    :: % s a -> s -> + a   ::  a => X s a -> s -> + a   ::  Y s a -> s -> + a   ::   s a -> s -> + a   ::  a =>  : s a -> s -> + a 2Obtain the maximum element (if any) targeted by a X, :, , Y,  or %( according to a user supplied ordering.   cmp "a " (# empty)   Z cmp    :: % s a -> (a -> a -> % ) -> s -> + a   :: X s a -> (a -> a -> % ) -> s -> + a   ::  Y s a -> (a -> a -> % ) -> s -> + a   ::   s a -> (a -> a -> % ) -> s -> + a   ::  : s a -> (a -> a -> % ) -> s -> + a 2Obtain the minimum element (if any) targeted by a X, :, , Y  or %( according to a user supplied ordering.  & cmp "a " (# empty)   Z cmp    :: % s a -> (a -> a -> % ) -> s -> + a   :: X s a -> (a -> a -> % ) -> s -> + a   ::  Y s a -> (a -> a -> % ) -> s -> + a   ::   s a -> (a -> a -> % ) -> s -> + a   ::  : s a -> (a -> a -> % ) -> s -> + a The  function takes a  (or %, Y, X, or :), O a predicate and a structure and returns the leftmost element of the structure  matching the predicate, or ' if there is no such element.    :: % s a -> (a ->  ) -> s -> + a   :: X s a -> (a ->  ) -> s -> + a   ::  Y s a -> (a ->  ) -> s -> + a   ::   s a -> (a ->  ) -> s -> + a   ::  : s a -> (a ->  ) -> s -> + a  A variant of f4 that has no base case and thus may only be applied K to lenses and structures such that the lens views at least one element of  the structure.     l f "a ( f  h l   "a  Z     :: %* s a -> (a -> a -> a) -> s -> a   :: X, s a -> (a -> a -> a) -> s -> a   ::  Y& s a -> (a -> a -> a) -> s -> a   ::  % s a -> (a -> a -> a) -> s -> a   ::  : s a -> (a -> a -> a) -> s -> a  A variant of gQ that has no base case and thus may only be applied to lenses and strutures such < that the lens views at least one element of the structure.     l f "a  l f .    "a  Z     :: %* s a -> (a -> a -> a) -> s -> a   :: X, s a -> (a -> a -> a) -> s -> a   ::  Y& s a -> (a -> a -> a) -> s -> a   ::  % s a -> (a -> a -> a) -> s -> a   ::  : s a -> (a -> a -> a) -> s -> a 6Strictly fold right over the elements of a structure.   "a  Z    :: %/ s a -> (a -> r -> r) -> r -> s -> r   :: X1 s a -> (a -> r -> r) -> r -> s -> r   ::  Y+ s a -> (a -> r -> r) -> r -> s -> r   ::  * s a -> (a -> r -> r) -> r -> s -> r   ::  :% s a -> (a -> r -> r) -> r -> s -> r NFold over the elements of a structure, associating to the left, but strictly.   "a  Z    :: %/ s a -> (r -> a -> r) -> r -> s -> r   :: X1 s a -> (r -> a -> r) -> r -> s -> r   ::  Y+ s a -> (r -> a -> r) -> r -> s -> r   ::  * s a -> (r -> a -> r) -> r -> s -> r   ::  :% s a -> (r -> a -> r) -> r -> s -> r IMonadic fold over the elements of a structure, associating to the right,  i.e. from right to left.   "a  Z    ::  m => %3 s a -> (a -> r -> m r) -> r -> s -> m r   ::  m => X5 s a -> (a -> r -> m r) -> r -> s -> m r   ::  m =>  Y/ s a -> (a -> r -> m r) -> r -> s -> m r   ::  m =>  . s a -> (a -> r -> m r) -> r -> s -> m r   ::  m =>  :) s a -> (a -> r -> m r) -> r -> s -> m r HMonadic fold over the elements of a structure, associating to the left,  i.e. from left to right.   "a  Z    ::  m => %3 s a -> (r -> a -> m r) -> r -> s -> m r   ::  m => X5 s a -> (r -> a -> m r) -> r -> s -> m r   ::  m =>  Y/ s a -> (r -> a -> m r) -> r -> s -> m r   ::  m =>  . s a -> (r -> a -> m r) -> r -> s -> m r   ::  m =>  :) s a -> (r -> a -> m r) -> r -> s -> m r 8UVWXYZ[\]^_`abcdefghijklmnopqrs)tuvwxyz{|}~7UVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~7X~iYZ^_`a[\]bcdefghlmjknopqrstuvwz{xy|}UVW6UVWXYZ[\]^_`abcdefghijklmnopqrs)tuvwxyz{|}~ Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred type SimpleReifiedTraversal =   A form of 4 that can be stored monomorphically in a container.  type SimpleTraversal =  A  can be used directly as a 8 or a X (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 Y as a , and composition of a  (or  or Y ) with a  (or  or Y)  using (.) forms a valid . The laws for a Traversal t3 follow from the laws for Traversable as stated in "#The Essence of the Iterator Pattern".    t  "a   ( (t f)  t g "a hi  t (hj  ( 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. 0This function is only provided for consistency,  is strictly more general.   "a This yields the obvious law:   "a      :: Y) s t a b -> (a -> f b) -> s -> f t   :: ( s t a b -> (a -> f b) -> s -> f t   :: # s t a b -> (a -> f b) -> s -> f t  A version of ( with the arguments flipped, such that:   l "a  ( l)   * "a   0This function is only provided for consistency,  is strictly more general.     "a      :: Y# s t a b -> s -> (a -> f b) -> f t   :: # s t a b -> s -> (a -> f b) -> f t   :: # s t a b -> s -> (a -> f b) -> f t FEvaluate each action in the structure from left to right, and collect  the results.    + "a   "a     l "a  l id "a l id     :: Y s t (f b) b -> s -> f t   ::  s t (f b) b -> s -> f t   :: % f =>  s t (f b) b -> s -> f t HMap each element of a structure targeted by a lens to a monadic action, E evaluate these actions from left to right, and collect the results.  , "a      :: Y) s t a b -> (a -> m b) -> s -> m t   :: ( s t a b -> (a -> m b) -> s -> m t   ::  m => # s t a b -> (a -> m b) -> s -> m t  is a flipped version of $, consistent with the definition of -.    - "a     l "a  ( l)      :: Y) s t a b -> s -> (a -> m b) -> m t   :: ( s t a b -> s -> (a -> m b) -> m t   ::  m => # s t a b -> s -> (a -> m b) -> m t USequence the (monadic) effects targeted by a lens in a container from left to right.    . "a     l "a  l id   l "a / . l 0     :: Y s t (m b) b -> s -> m t   ::  s t (m b) b -> s -> m t   ::  m =>  s t (m b) b -> s -> m t This generalizes  to an arbitrary . Note: F handles ragged inputs more intelligently, but for non-ragged inputs:   "a  &transposeOf traverse [[1,2,3],[4,5,6]][[1,4],[2,5],[3,6]] Since every  is a , we can use this as a form of  monadic strength as well:  _2 :: (b, [a] ) -> [(b, a)]This generalizes  to an arbitrary .   "a  ' accumulates state from right to left.    :: YA s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)   :: @ s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)   :: ; s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t) This generalizes  to an arbitrary .   "a  ' accumulates state from left to right.    :: YA s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)   :: @ s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)   :: ; s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t) This permits the use of 1 over an arbitrary  or .  1 "a      :: Y* s t a a -> (a -> a -> a) -> s -> t   :: ) s t a a -> (a -> a -> a) -> s -> t   :: $ s t a a -> (a -> a -> a) -> s -> t This permits the use of 2 over an arbitrary  or .  2 "a      :: Y* s t a a -> (a -> a -> a) -> s -> t   :: ) s t a a -> (a -> a -> a) -> s -> t   :: $ s t a a -> (a -> a -> a) -> s -> t 4Traverse both parts of a tuple with matching types. both *~ 10 $ (1,2)(10,20)"over both length ("hello","world")(5,5)("hello","world")^.both "helloworld"Apply a different  or X to each side of a tuple. .("hello",["world","!!!"])^..beside id traverse["hello","world","!!!"]3A traversal for tweaking the left-hand value of an *: over traverseLeft (+1) (Left 2)Left 3 over traverseLeft (+1) (Right 2)Right 2!Right 42 ^.traverseLeft :: String""Left "hello" ^.traverseLeft"hello" traverseLeft :: % f => (a -> f b) -> * a c -> f (* b c)$traverse the right-hand value of an *:   "a Unfortunately the instance for   (* c) is still missing from base,  so this can' t just be   over traverseRight (+1) (Left 2)Left 2!over traverseRight (+1) (Right 2)Right 3Right "hello" ^.traverseRight"hello"(Left "hello" ^.traverseRight :: [Double][] traverseRight :: % f => (a -> f b) -> * c a -> f (* c a)Visit the first n targets of a , X, Getter or . Visit all but the first n targets of a , X, Getter or . A 2 is completely characterized by its behavior on a ".  Cloning a ! is one way to make sure you aren't given  something weaker, such as a W 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 ". Flet foo l a = (view (cloneTraversal l) a, set (cloneTraversal l) 10 a)foo both ("hello","world")("helloworld",(10,10))  ::  (" a b) s t a b ->  s t a b33 Rank2Types experimentalEdward Kmett <ekmett@gmail.com> TrustworthyLA generic applicative transformation that maps over the immediate subterms.  is to  what 4 is to 5 This really belongs in  Data.Data. Nave  using 63. This does not attempt to optimize the traversal. ZThis is primarily useful when the children are immediately obvious, and for benchmarking. %Find every occurence of a given type a recursively that doesn' t require # passing through something of type a using 6, while avoiding traversal . of areas that cannot contain a value of type a. This is  with a more liberal signature. Find descendants of type aU non-transitively, while avoiding computation of areas that cannot contain values of  type a using 6. $ is a useful default definition for   performs like , except when s ~ a&, it returns itself and nothing else. 7 inlineable 8 %9:;<=>?@ABCDEFGHIJKLM7NOPQRSTUVW9:;<=@?>ABCDEFGHIJKLM7NOPQRSTUVWTemplateHaskell 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 X. Has a Y Extract (or modify) the Y 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. Z[\]^_`abcd  Z[\]^_`abcd"rank 2 types, MPTCs, TFs, flexible provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred#Useful for storage. Every  is a valid W. Fold an  or  U/ by mapping indices and values 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.   l "a  l      :: p+ i a s -> (i -> s -> m) -> a -> m   :: $ m => - i a s -> (i -> s -> m) -> a -> m   ::  ' i a s -> (i -> s -> m) -> a -> m   :: $ m =>  " i a s -> (i -> s -> m) -> a -> m JRight-associative fold of parts of a structure that are viewed through an  or  U with  access to the index i.  When you don' t need access to the index then & is more flexible in what it accepts.   l "a  l      :: p5 i s a -> (i -> a -> r -> r) -> r -> s -> r   :: 7 i s a -> (i -> a -> r -> r) -> r -> s -> r   ::  1 i s a -> (i -> a -> r -> r) -> r -> s -> r   ::  , i s a -> (i -> a -> r -> r) -> r -> s -> r MLeft-associative fold of the parts of a structure that are viewed through an  or  U with  access to the index i.  When you don' t need access to the index then & is more flexible in what it accepts.   l "a  l      :: p5 i s a -> (i -> r -> a -> r) -> r -> s -> r   :: 7 i s a -> (i -> r -> a -> r) -> r -> s -> r   ::  1 i s a -> (i -> r -> a -> r) -> r -> s -> r   ::  , i s a -> (i -> r -> a -> r) -> r -> s -> r 4Return whether or not any element viewed through an  or  U / satisfy a predicate, with access to the index i.  When you don' t need access to the index then & is more flexible in what it accepts.   l "a  l      :: p i s a -> (i -> a ->  ) -> s ->    ::  i s a -> (i -> a ->  ) -> s ->    ::   i s a -> (i -> a ->  ) -> s ->    ::   i s a -> (i -> a ->  ) -> s ->  5Return whether or not all elements viewed through an  or  U / satisfy a predicate, with access to the index i.  When you don' t need access to the index then & is more flexible in what it accepts.   l "a  l      :: p i s a -> (i -> a ->  ) -> s ->    ::  i s a -> (i -> a ->  ) -> s ->    ::   i s a -> (i -> a ->  ) -> s ->    ::   i s a -> (i -> a ->  ) -> s ->  Traverse the targets of an  or  U 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 "a  itraverseOf l      :: # f => p0 i s a -> (i -> a -> f r) -> s -> f ()   :: % f => 2 i s a -> (i -> a -> f r) -> s -> f ()   :: # f =>  , i s a -> (i -> a -> f r) -> s -> f ()   :: % f =>  ' i s a -> (i -> a -> f r) -> s -> f () Traverse the targets of an  or  U2 with access to the index, discarding the results  (with the arguments flipped).   "a    When you don' t need access to the index then & is more flexible in what it accepts.   l a "a  l a      :: # f => p0 i s a -> s -> (i -> a -> f r) -> f ()   :: % f => 2 i s a -> s -> (i -> a -> f r) -> f ()   :: # f =>  , i s a -> s -> (i -> a -> f r) -> f ()   :: % f =>  ' i s a -> s -> (i -> a -> f r) -> f () *Run monadic actions for each target of an  or  U with access to the index,  discarding the results.  When you don' t need access to the index then & is more flexible in what it accepts.   l "a imapMOf l      ::  m => p0 i s a -> (i -> a -> m r) -> s -> m ()   ::  m => 2 i s a -> (i -> a -> m r) -> s -> m ()   ::  m =>  , i s a -> (i -> a -> m r) -> s -> m ()   ::  m =>  ' i s a -> (i -> a -> m r) -> s -> m () *Run monadic actions for each target of an  or  U with access to the index, 6 discarding the results (with the arguments flipped).   "a    When you don' t need access to the index then & is more flexible in what it accepts.   l a "a iforMOf l a      ::  m => p0 i s a -> s -> (i -> a -> m r) -> m ()   ::  m => 2 i s a -> s -> (i -> a -> m r) -> m ()   ::  m =>  , i s a -> s -> (i -> a -> m r) -> m ()   ::  m =>  ' i s a -> s -> (i -> a -> m r) -> m () <Concatenate the results of a function of the elements of an  or  U  with access to the index.  When you don' t need access to the index then ' is more flexible in what it accepts.     l "a  l     "a      :: p i s a -> (i -> a -> [r] ) -> s -> [r]   :: " i s a -> (i -> a -> [r] ) -> s -> [r]   ::   i s a -> (i -> a -> [r] ) -> s -> [r]   ::   i s a -> (i -> a -> [r] ) -> s -> [r] The findOf function takes an  or  U, a predicate that is also T supplied the index, a structure and returns the left-most element of the structure  matching the predicate, or ' if there is no such element.  When you don' t need access to the index then & is more flexible in what it accepts.   l "a  l      :: p s a -> (i -> a ->  ) -> s -> + (i, a)   ::  s a -> (i -> a ->  ) -> s -> + (i, a)   ::   s a -> (i -> a ->  ) -> s -> + (i, a)   ::   s a -> (i -> a ->  ) -> s -> + (i, a) Strictly< fold right over the elements of a structure with an index.  When you don' t need access to the index then & is more flexible in what it accepts.   l "a  l      :: p5 i s a -> (i -> a -> r -> r) -> r -> s -> r   :: 7 i s a -> (i -> a -> r -> r) -> r -> s -> r   ::  1 i s a -> (i -> a -> r -> r) -> r -> s -> r   ::  , i s a -> (i -> a -> r -> r) -> r -> s -> r RFold over the elements of a structure with an index, associating to the left, but strictly.  When you don' t need access to the index then & is more flexible in what it accepts.   l "a  l      :: p7 i s a -> (i -> r -> a -> r) -> r -> s -> r   :: 9 i s a -> (i -> r -> a -> r) -> r -> s -> r   ::  3 i s a -> (i -> r -> a -> r) -> r -> s -> r   ::  . i s a -> (i -> r -> a -> r) -> r -> s -> r CMonadic fold right over the elements of a structure with an index.  When you don' t need access to the index then & is more flexible in what it accepts.   l "a  l      ::  m => p7 i s a -> (i -> a -> r -> m r) -> r -> s -> r   ::  m => 9 i s a -> (i -> a -> r -> m r) -> r -> s -> r   ::  m =>  3 i s a -> (i -> a -> r -> m r) -> r -> s -> r   ::  m =>  . i s a -> (i -> a -> r -> m r) -> r -> s -> r VMonadic fold over the elements of a structure with an index, associating to the left.  When you don' t need access to the index then & is more flexible in what it accepts.   l "a  l      ::  m => p9 i s a -> (i -> r -> a -> m r) -> r -> s -> r   ::  m => ; i s a -> (i -> r -> a -> m r) -> r -> s -> r   ::  m =>  5 i s a -> (i -> r -> a -> m r) -> r -> s -> r   ::  m =>  0 i s a -> (i -> r -> a -> m r) -> r -> s -> r .Extract the key-value pairs from a structure.  When you don'1t need access to the indices in the result, then h& is more flexible in what it accepts.  h l "a e f   l    :: p i s a -> s -> [(i,a)]   ::  i s a -> s -> [(i,a)]   ::   i s a -> s -> [(i,a)]   ::   i s a -> s -> [(i,a)] JTransform an indexed fold into a fold of both the indices and the values.     ::  i s a -> Fold s (i, a)   :: SimpleIndexedLens i s a -> Getter s (i, a)   :: SimpleIndexedTraversal i s a -> Fold s (i, a) 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.     :: IndexedTraversal i s t a b ->  Traversal s t (i, a) (j, b) .Change made to the indices will be discarded. 6Transform an indexed fold into a fold of the indices.    ::  i s a -> Fold s i   :: SimpleIndexedLens i s a -> Getter s i   :: SimpleIndexedTraversal i s a -> Fold s i  Obtain an  by filtering an  V, p, or . When passed an  U, sadly the result is not a legal  U. See filtered for a related counter-example. (Reverse the order of the elements of an  or  U.  This has no effect on an  V, p, or  .  Obtain an ! by taking elements from another ,  V, p or  U while a predicate holds.  Obtain an # by dropping elements from another ,  V, p or  U while a predicate holds.  Obtain an  by splitting another ,  V, p or  U, according to the given splitting strategy.    :: g (i, a) ->  i s a ->  [i] s [a]  Obtain an  by splitting another ,  V, p or  U on the given delimiter. Equivalent to   h  i.    :: ( i,  a) => [(i, a)] ->  i s a ->  [i] s [a]  Obtain an  by splitting another ,  V, p or  U on any of the given elements. Equivalent to   h  j.    :: ( i,  a) => [(i, a)] ->  i s a ->  [i] s [a]  Obtain an  by splitting another ,  V, p or  U- on elements satisfying the given predicate. Equivalent to   h  k  l.    :: (i -> a -> ) ->  i s a ->  [i] s [a]  Obtain an  by splitting another ,  V, p or  U0 into chunks terminated by the given delimiter. Equivalent to   h  i.    :: ( i,  a) => [(i, a)] ->  i s a ->  [i] s [a]  Obtain an  by splitting another ,  V, p or  U6 into chunks terminated by any of the given elements. Equivalent to   m  h  j.    :: ( i,  a) => [(i, a)] ->  i s a ->  [i] s [a]  Obtain an  by splitting another ,  V, p or  U into words9, with word boundaries indicated by the given predicate. Equivalent to   n  h  k  l.    :: (i -> a -> ) ->  i s a ->  [i] s [a]  Obtain an  by splitting another ,  V, p or  U into lines9, with line boundaries indicated by the given predicate. Equivalent to   m  h  k  l.    :: (i -> a -> ) ->  i s a ->  [i] s [a]  Obtain an  by splitting another ,  V, p or  U into length-n pieces.    :: ) ->  i s a ->  [i] s [a]  Obtain an  by splitting another ,  V, p or  U# into chunks of the given lengths.    ::  n => [n] ->  i s a ->  [i] s [a]  Obtain an  by splitting another ,  V, p or  U+ into chunks of the given lengths. Unlike  , the output = will always be the same length as the first input argument.    ::  n => [n] ->  i s a ->  [i] s [a] &o n%%$o RankNTypes provisionalEdward Kmett <ekmett@gmail.com> Safe-InferredGSometimes you need to store a path lens into a container, but at least  at this time, ImpredicativePolymorphism in GHC is somewhat lacking. *This type provides a way to, say, store a [] of paths. Representable Functors. A # f is  if it is isomorphic to (x -> a) E for some x. Nearly all such functors can be represented by choosing x to be ? the set of lenses that are polymorphic in the contents of the #,  that is to say x =  f is a valid choice of x for (nearly) every   #. @Note: Some sources refer to covariant representable functors as ) corepresentable functors, and leave the " representable" name to 1 contravariant functors (those are isomorphic to (a -> x) for some x). LAs the covariant case is vastly more common, and both are often referred to = as representable functors, we choose to call these functors   here. The representation of a  # as Lenses # is a valid default definition for ( for a   functor.   f m =   i -> f (m , i) Usage for a  Foo:   instance # Foo where  ( =  # is a valid default definition for  and p for a   functor.   =  .  Usage for a  Foo:    instance % Foo where   =   ...    instance  Foo where  p =   ... $ is a valid default definition for (q) for a   functor.   mf ma =   i -> mf , i  ma , i Usage for a  Foo:   instance % Foo where   =   (q) =  + is a valid default default definition for '(>>=)' for a  representable functor.   m f =   i -> f (m , i) , i Usage for a  Foo:   instance  Foo where  p =   (r) =  A default definition for  for a  #   wf =   i -> ( (, i) wf Usage for a  Foo:   instance  Foo where   =  A  #- has a fixed shape. This fills each position  in it with a   A version of 5 that is an isomorphism. Predicativity requires that  we wrap the  as a Key , however.  Map over a  functor with access to the  for the  current position  f m =   i -> f i (m , i) Traverse a ) functor with access to the current path  Traverse a ) functor with access to the current path  as a , discarding the result  Traverse a ) functor with access to the current path  and a  (and the arguments flipped) , over a ) functor with access to the current path  as a  , over a ) functor with access to the current path  as a , discarding the result , over a ) functor with access to the current path  as a  (with the arguments flipped)  Fold over a ) functor with access to the current path  as a  , yielding a $  Fold over a ) functor with access to the current path  as a . An  that walks an  # using a  for an index. An  that walks an   # using a  for an index. An  for a   #. sNB: The @ requirement on this instance is a consequence of the choice of  as a , it isn't fundamental. stst Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred<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 (,,u,v,6,w)    instance  Expr where   f (Neg e) = Neg x f e   f (Add a b) = Add x f a q 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 (,,u,v,6,w)    instance  (Tree a) where   f (Bin l r) = Bin x f l q f r   _ t =  t or    instance 6 a =>  (Tree a) where   =  <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 ignored/, though those usecases are much better served < in most cases by using the existing lens combinators! e.g. h  "a   ignored. )This same ability to explicitly pass the  in question is why there is no  analogue to uniplate's Biplate. UMoreover, since we can allow custom traversals, we implement reasonable defaults for A polymorphic data types, that only traverse into themselves, and not their  polymorphic arguments. . of the immediate children of this structure. *The default definition finds no children. 'Extract the immediate descendants of a  container.  "a h  Provided for compatibility with uniplate.   "a h  :: X s a -> s -> [a]LRewrite by applying a rule everywhere you can. Ensures that the rule cannot $ be applied anywhere in the result:  propRewrite r x = y ( . 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 z 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 = y ( . 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 z g a3 which performs both rewrites until a fixed point.    ::  Y 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.    ::  a =>  Y s a -> (a -> + a) -> s -> s   ::  a =>   s a -> (a -> + a) -> s -> s   ::  a =>   s a -> (a -> + a) -> s -> s   ::  a =>   s a -> (a -> + a) -> s -> s NRewrite recursively over part of a larger structure using a specified setter.    ::  a =>  Y s a ->  Y a a -> (a -> + a) -> s -> s   ::  a =>   s a ->   a a -> (a -> + a) -> s -> s   ::  a =>   s a ->   a a -> (a -> + a) -> s -> s   ::  a =>   s a ->   a a -> (a -> + a) -> s -> s 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.  :: X a a -> a -> [a]Given a X that knows how to find O parts of a container retrieve them and all of their descendants, recursively. Given a X~ 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 X. h l "a  l ignored<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 .    ::  a =>   s a -> (a -> a) -> s -> s   ::  a =>   s a -> (a -> a) -> s -> s 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.    ::   s a ->   a a -> (a -> a) -> s -> s   ::   s a ->   a a -> (a -> a) -> s -> s 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,  a) =>   s a -> (a -> m a) -> s -> m s8Transform 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 =>   s a ->   a a -> (a -> m a) -> s -> m s +Recurse one level into a structure. (a.k.a composOp from Bjrn Bringert's compos)   "a   TRecurse one level into a structure using a user specified recursion scheme. This is , but it is supplied here ( for consistency with the uniplate API.    "a      ::   s a -> (a -> a) -> s -> s    ::   s a -> (a -> a) -> s -> s  2Recurse one level into the parts delimited by one , using another.    b l "a  (b  l)     ::   s a ->   a a -> (a -> a) -> s -> s    ::   s a ->   a a -> (a -> a) -> s -> s  ARecurse one level into the parts of the structure delimited by a .    b "a  (b  )   ::  a =>  s t -> (t -> t) -> s -> s +Recurse one level into a structure with an % effect, this is , but it is supplied ( for consistency with the uniplate API.   "a ORecurse one level into a structure using a user specified recursion scheme and % effects. This is , but it is supplied ( for consistency with the uniplate API.   "a   :: % m =>   s a => (a -> m a) -> s -> m s2Recurse one level into the parts delimited by one , using another with % effects.   "a ()  :: % f =>   s a ->   a a -> (a -> f a) -> s -> f sARecurse one level into the parts of the structure delimited by a  with % effects.   b "a b    :: (% f, Plated' a) =>   s a -> (a -> f a) -> s -> f s  "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 p#, but is provided for consistency.   "a p  :: % f => X s a => (a -> f r) -> s -> f ()2Recurse one level into the parts delimited by one X, using another with %; effects, without reconstructing the structure behind you.   b l "a p (b  l)  :: % f => X s a -> X a a -> (a -> f r) -> s -> f ()ARecurse one level into the parts of the structure delimited by a  with monadic effects.   b "a p (b  )  :: (% f,  a) =>   s a -> (a -> f r) -> s -> f ()ARecurse one level into a structure with a monadic effect. (a.k.a  composOpM from Bjrn Bringert's compos)  "a  hRecurse one level into a structure using a user specified recursion scheme and monadic effects. This is  , but it is 1 supplied for consistency with the uniplate API.   "a   ::  m =>   s a => (a -> m a) -> s -> m s2Recurse one level into the parts delimited by one &, using another with monadic effects.   b l "a  (b  l)  ::  m =>   s a ->   a a -> (a -> m a) -> s -> m sARecurse one level into the parts of the structure delimited by a  with monadic effects.   b "a  (b . )  :: ( m,  a) =>   s a -> (a -> m a) -> s -> m s?Descend one level into a structure with monadic effects (a.k.a  composOpM from Bjrn Bringert's compos)  "a mapMOf_' mRecurse one level into a structure using a user specified recursion scheme and monadic effects. This is just s#, but is provided for consistency.   "a s  ::  m => X s a => (a -> m a) -> s -> m ()2Recurse one level into the parts delimited by one &, using another with monadic effects.   b l "a s (b  l)  ::  m => X s a -> X a a -> (a -> m a) -> s -> m ()ARecurse one level into the parts of the structure delimited by a  with monadic effects.   b "a s (b  )  :: ( m,  a) =>   s a -> (a -> m r) -> b -> m ()`Return a list of all of the editable contexts for every location in the structure, recursively.    propUniverse x =  x == e pos ( x)  propId x = y (| x) [extract w | w <-  x]   "a  wReturn a list of all of the editable contexts for every location in the structure, recursively, using a user-specified  to walk each layer.    propUniverse l x =  l x == e pos ( l x)  propId l x = y (| x) [extract w | w <-  l x]   ::   a a -> a -> [% a a]{Return a list of all of the editable contexts for every location in the structure in an areas indicated by a user supplied , recursively using .   b "a   b   ::  a =>   s a -> s -> [% a a s] {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.   ::   s a ->   a a -> s -> [% a a s]!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 | e pos (! l x)  propId x = y (| 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 | e pos (" l x)  propId l x = y (| x) [extract w | w <- " l x]    " ::  Iso s a -> s -> [% a a s]  " ::   s a -> s -> [% a a s]  " ::   s a -> s -> [% a a s] # An alias for "7, provided for consistency with the other combinators.  # "a "   # ::  Iso s a -> s -> [% a a s]  # ::   s a -> s -> [% a a s]  # ::   s a -> s -> [% a a s] $IExtract one level of holes from a container in a region specified by one , using another.  $ b l "a " (b  l)   $ ::  Iso s a ->  Iso a a -> s -> [% a a s]  $ ::   s a ->   a a -> s -> [% a a s]  $ ::   s a ->   a a -> s -> [% a a s] %KPerform a fold-like computation on each value, technically a paramorphism. % :: X a a -> (a -> [r] -> r) -> a -> r&KPerform a fold-like computation on each value, technically a paramorphism. & "a % '!Fold the immediate children of a  container. ' z c f = f  (c  f) z( The original uniplate% combinator, implemented in terms of  as a .  ( "a ) 1The resulting lens is safer to use as it ignores 'over-application'. and deals gracefully with under-application, ( but it is only a proper lens if you don't change the list ! )) 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.   ) ::  Y s a ->   s [a]  ) ::   s a ->   s [a]  ) ::   s a ->   s [a] ** turns a  into a uniplate (or biplate ) family.  If you do not need the types of s and t) 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 b's as you were  given a's, then the reconstruction of t will result in an error!   * :: Y s t a b ->  s t [a] [b]  * ::  s t a b ->  s t [a] [b]  * ::  s t a b ->  s t [a] [b] +A  to 4'Control.Lens.Getter.view'/'Control.Lens.Setter.set' the nth element + a ,  or Y. +Attempts to access beyond the range of the  will cause an error. ,[[1],[3,4]]^.elementOf (traverse.traverse) 13, Access the nth element of a  container. +Attempts to access beyond the range of the  will cause an error. , "a + B      !"#$%&'()*+,}~<      !"#$%&'()*+,<      !"#$&%',+()*A      !"#$%&'()*+,}~ non-portable experimentalEdward Kmett <ekmett@gmail.com> Trustworthy -A - is a recorded path through the  Traversal chain of a .. .This enables us to pull the 3 back up to the 1. + is used internally in the definition of a .. /=This represents the type a zipper will have when it is fully / back up. 0This is the type of a .. It visually resembes a 'breadcrumb trail' as Q used in website navigation. Each breadcrumb in the trail represents a level you  can move up to. FThis type operator associates to the left, so you can use a type like  1 0 (,) 0  0 to represent a zipper from (,) down to  that has an intermediate  crumb for the  containing the . 1This is used to represent the 1 of the .. Every . starts with 1. e.g. 1 0 a is the trivial zipper. 2This ! views the current target of the 3. 3 Construct a 3 that can explore anything. 4"Return the index into the current  Traversal. ? (4 l) l = Just'5 Move the 3 5@, closing the current level and focusing on the parent element. 6 Pull the 3 6 within the current  Traversal. 7Try to pull the 3 one entry to the 6. If the entry to the left doesn't exist, then stay still. 8 Pull the entry one entry to the 8 9Try to pull the 3 one entry to the 8. If the entry doesn't exist, then stay still. :Try to pull the 3 n entries to the 8 , returning '- if you pull too far and run out of entries. Passing a negative n will move -n entries to the 6. ;Try to pull the 3 n entries to the 6 , returning '- if you pull too far and run out of entries. <Try to pull the 3 n entries to the 69. Stopping at the first entry if you run out of entries. Passing a negative n will move to -nN entries the right, and will return the last entry if you run out of entries. =Try to pull the 3 n entries to the 88. Stopping at the last entry if you run out of entries. kPassing a negative number will move to the left and will return the first entry if you run out of entries. >;Returns the number of siblings at the current level in the 3.  > z  1NB: If the current  TraversalE targets an infinite number of elements then this may not terminate. ? Move the 3$ horizontally to the element in the nIth position in the current level. (absolutely indexed, starting with the A as 0)  This returns ' if the target element doesn' t exist. ? n = : n . A@ Move the 3$ horizontally to the element in the nIth position of the current level. (absolutely indexed, starting with the A as 0) %If the element at that position doesn'+t exist, then this will clamp to the range 0 <= n < > z and return the element there. A.Move to the left-most position of the current  Traversal. B/Move to the right-most position of the current  Traversal. CStep down into a  . This is a constrained form of E for when you know  there is precisely one target.   C ::   b c -> (a :> b) -> a :> b :> c  C ::  Iso! b c -> (a :> b) -> a :> b :> c DStep down into the A entry of a  Traversal.   D ::   Traversal( b c -> (a :> b) -> Maybe (a :> b :> c)  D ::  - b c -> (a :> b) -> Maybe (a :> b :> c)  D ::  Iso. b c -> (a :> b) -> Maybe (a :> b :> c) EUnsafely step down into a  Traversal that is assumed to be non-empty. HIf this invariant is not met then this will usually result in an error!    E ::   Traversal b c -> (a :> b) -> a :> b :> c  E ::  % b c -> (a :> b) -> a :> b :> c  E ::  Iso& b c -> (a :> b) -> a :> b :> c =You can reason about this function as if the definition was:  E l "a fromJust  D lMbut it is lazier in such a way that if this invariant is violated, some code I can still succeed if it is lazy enough in the use of the focused value. F-Close something back up that you opened as a 3. 5This is used to peel off the path information from a 8 for use when saving the current path for later replay. GSave the current path as as a - we can play back later. H?Restore ourselves to a previously recorded position precisely. +If the position does not exist, then fail. I5Restore ourselves to a previously recorded position. $When moving left to right through a  Traversal0, if this will clamp at each level to the range 0 <= k < width, b so the only failures will occur when one of the sequence of downward traversals find no targets. J5Restore ourselves to a previously recorded position. pThis assumes that nothing has been done in the meantime to affect the existence of anything on the entire path. FMotions left or right are clamped, but all traversals included on the - are assumed to be non-empty. ,Violate these assumptions at your own risk. --./0123456789:;<=>?@ABCDEFGHIJ-./0123456789:;<=>?@ABCDEFGHIJ10325CDE67;<A89:=B?@4>F/.-GHIJ&-./0123456789:;<=>?@ABCDEFGHIJ Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Trustworthy#KA  with an additional index. 2An instance must satisfy a (modified) form of the  laws:   L ( ) "a   ( (L f)  L g "a  getCompose  L (i -> Compose  ( (f i)  g i) LTraverse an indexed container. M<A container that supports folding with an additional index. N2Fold a container by mapping value to an arbitrary $ with access to the index i.  When you don' t need access to the index then & is more flexible in what it accepts.  "a N  OHRight-associative fold of an indexed container with access to the index i.  When you don' t need access to the index then & is more flexible in what it accepts.  "a O  PGLeft-associative fold of an indexed container with access to the index i.  When you don' t need access to the index then & is more flexible in what it accepts.  "a P  QStrictlyF fold right over the elements of a structure with access to the index i.  When you don' t need access to the index then & is more flexible in what it accepts.  "a Q  RRFold over the elements of a structure with an index, associating to the left, but strictly.  When you don' t need access to the index then & is more flexible in what it accepts.   l "a  l      :: Z7 i a c -> (i -> e -> c -> e) -> e -> a -> e   :: 9 i a c -> (i -> e -> c -> e) -> e -> a -> e   ::  3 i a c -> (i -> e -> c -> e) -> e -> a -> e   :: . i a c -> (i -> e -> c -> e) -> e -> a -> e SA # with an additional index. .Instances must satisfy a modified form of the # laws:   T f  T g "a T (i -> f i . g i)  T (_ a -> a) "a  TMap with access to the index. UThe  for a S.  If you don'!t need access to the index, then mapped& is more flexible in what it accepts. VThe  of a M container. W Obtain a X9 by lifting an operation that returns a foldable result. +This can be useful to lift operations from  Data.List and elsewhere into a X. XaReturn 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.  = X  Y`Return whether or not all elements in a container satisfy a predicate, with access to the index i.  When you don' t need access to the index then & is more flexible in what it accepts.  "a Y  Z+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 = L  [+Traverse elements with access to the index i7, discarding the results (with the arguments flipped).  [ "a  Z When you don' t need access to the index then & is more flexible in what it accepts.  a "a [ a  \*Run monadic actions for each target of an  or  with access to the index,  discarding the results.  When you don' t need access to the index then s& is more flexible in what it accepts.  "a g  ]*Run monadic actions for each target of an  or  with access to the index, 6 discarding the results (with the arguments flipped).  ] "a  \ When you don' t need access to the index then t& is more flexible in what it accepts. t l a "a  l a  ^hConcatenate the results of a function of the elements of an indexed container with access to the index.  When you don' t need access to the index then & is more flexible in what it accepts.    "a ^ .   ^ "a N _xSearches a container with a predicate that is also supplied the index, returning the left-most element of the structure  matching the predicate, or ' if there is no such element.  When you don' t need access to the index then & is more flexible in what it accepts.  "a _  `CMonadic fold right over the elements of a structure with an index.  When you don' t need access to the index then & is more flexible in what it accepts.  "a `  aVMonadic fold over the elements of a structure with an index, associating to the left.  When you don' t need access to the index then & is more flexible in what it accepts.  "a a  b.Extract the key-value pairs from a structure.  When you don'1t need access to the indices in the result, then & is more flexible in what it accepts.  "a  f  bcIFold a container with indices returning both the indices and the values. d:Fold a container with indices returning only the indices. eThe  of a K container. f3Traverse with an index (and the arguments flipped)   * a "a f a    f "a  L g5Map each element of a structure to a monadic action, Q evaluate these actions from left to right, and collect the results, with access  the index.  When you don't need access to the index ,( is more liberal in what it can accept. , "a g  h5Map each element of a structure to a monadic action, Q evaluate these actions from left to right, and collect the results, with access + its position (and the arguments flipped).   - a "a h a    h "a  g i Generalizes  to add access to the index. ' accumulates state from right to left.  "a i  j Generalizes  to add access to the index. ' accumulates state from left to right.  "a j  kPAccess the element of an indexed container where the index matches a predicate. Bover (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. 5KLMNOPQRSTUVWXYZ[\]^_`abcdefghijk!KLMNOPQRSTUVWXYZ[\]^_`abcdefghijk!STUMNOPQRVWXYZ[\]^_`abcdKLefghijk.KLMNOPQRSTUVWXYZ[\]^_`abcdefghijkTemplateHaskell experimentalEdward Kmett <ekmett@gmail.com> Trustworthyl+This configuration describes the options we',ll be using to make isomorphisms or lenses. nFlags for lens construction zOnly Generate valid   lenses. {HEnables the generation of partial lenses, generating runtime errors for L every constructor that does not have a valid definition for the lens. This L occurs when the constructor lacks the field, or has multiple fields mapped  to the same lens. |5In the situations that a lens would be partial, when { is M used, this flag instead causes traversals to be generated. Only one can be C used, and if neither are, then compile-time errors are generated. })Handle singleton constructors specially. ~When building a singleton 6 (or ') for a record constructor, build both  the 6 (or ,) for the record and the one for the field. Use 6 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. KIndicate whether or not to supply the signatures for the generated lenses. UDisabling this can be useful if you want to provide a more restricted type signature 1 or if you want to supply hand-written haddocks. SLens to access the convention for naming top level isomorphisms in our lens rules. =Defaults to lowercasing the first letter of the constructor. CLens to access the convention for naming fields in our lens rules. MDefaults to stripping the _ off of the field name, lowercasing the name, and  rejecting the field if it doesn't start with an '_'. JRetrieve options such as the name of the class and method to put in it to . build a class around monomorphic data types. JRetrieve options such as the name of the class and method to put in it to . build a class around monomorphic data types. Default lens rules JRules for making fairly simple partial lenses, ignoring the special cases > for isomorphisms and traversals, and not making any classes. ERules for making lenses and traversals that precompose another lens. 1Rules for making an isomorphism from a data type EBuild lenses (and traversals) with a sensible default configuration. ' makeLenses = makeLensesWith lensRules ZMake lenses and traversals for a type, and create a class when the type has no arguments. e.g.   " data Foo = Foo { _fooX, _fooY :: ) }   ''Foo  will create    class HasFoo t where  foo ::   t Foo ! instance HasFoo Foo where foo =   fooX, fooY :: HasFoo t =>   t )  ) makeClassy = makeLensesWith classyRules 'Make a top level isomorphism injecting into the type. dThe supplied name is required to be for a type with a single constructor that has a single argument e.g.    newtype List a = List [a]  makeIso ''List  will create    list :: Iso [a] [b] (List a) (List b)  # makeIso = makeLensesWith isoRules >Derive lenses and traversals, specifying explicit pairings of (fieldName, lensName). qIf you map multiple names to the same label, and it is present in the same constructor then this will generate a . e.g. < makeLensesFor [("_foo", "fooLens"), ("baz", "lbaz")] ''Foo 9 makeLensesFor [("_barX", "bar"), ("_barY", "bar)] ''Bar JDerive lenses and traversals, using a named wrapper class, and specifying  explicit pairings of (fieldName, traversalName). Example usage: K makeClassyFor "HasFoo" "foo" [("_foo", "fooLens"), ("bar", "lbar")] ''Foo *Build lenses with a custom configuration. ZGiven a set of names, build a map from those names to a set of fresh names based on them. Given  8 newtype Cxt b => Foo a b c d = Foo { _baz :: Bar a b } This will generate: N foo :: (Cxt b, Cxt f) => Iso (Foo a b c d) (Foo e f g h) (Bar a b) (Bar e f) : foo = isomorphic (\f a -> (\(Foo b) -> b) <$> f (Foo a)) 1 (\f (Foo a) -> fmap Foo (f a))  {-# INLINE foo #-} Gets 2[(lens name, (constructor name, field name, type))] from a record constructor 9lmnopqrstuvwxyz{|}~0surrounding cxt driven by the data type context data/newtype constructor name args 'lmnopqrstuvwxyz{|}~'lmnyxwvutsrqpoz{|}~)lmn yxwvutsrqpoz{|}~ Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred* `abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>DEFGHIJKLMNOPQRUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~GHC experimentalEdward Kmett <ekmett@gmail.com> Safe-InferredUsed 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 w 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-InferredTraverse the strongly typed  contained in ) where the type of your function matches  the desired .   exception :: ( Applicative f,  a,  b)  => (a -> f b) ->  -> f  !LiberalTypeSynonyms experimentalEdward Kmett <ekmett@gmail.com> Safe-Inferred Bitwise  the target(s) of a  or  _2 |~ 6 $ ("hello",3) ("hello",7)   () ::  a =>  s t a a -> a -> s -> t  () ::  a => 6 s t a a -> a -> s -> t  () ::  a =>  s t a a -> a -> s -> t  () :: ('Monoid a',  a) =>  s t a a -> a -> s -> t Bitwise  the target(s) of a  or  _2 &~ 7 $ ("hello",254) ("hello",6)   () ::  a =>  s t a a -> a -> s -> t  () ::  a => 6 s t a a -> a -> s -> t  () ::  a =>  s t a a -> a -> s -> t  () :: ('Monoid a',  a) =>  s t a a -> a -> s -> t Modify the target(s) of a  ,  or  by computing its bitwise  with another value.   () :: ( s m,  a) =>   s a -> a -> m ()  () :: ( s m,  a) =>  6 s a -> a -> m ()  () :: ( s m,  a) =>   s a -> a -> m ()  () :: ( s m,  a) =>   s a -> a -> m () Modify the target(s) of a  ,  or  by computing its bitwise  with another value.   () :: ( s m,  a) =>   s a -> a -> m ()  () :: ( s m,  a) =>  6 s a -> a -> m ()  () :: ( s m,  a) =>   s a -> a -> m ()  () :: ( s m,  a) =>   s a -> a -> m () Bitwise  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))   () ::  a => 6 s t a a -> a -> s -> (a, t)  () ::  a =>  s t a a -> a -> s -> (a, t)  () :: ( a, ' Monoid a) =>  s t a a -> a -> s -> (a, t) Bitwise  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))   () ::  a => 6 s t a a -> a -> s -> (a, t)  () ::  a =>  s t a a -> a -> s -> (a, t)  () :: ( a, ' Monoid a) =>  s t a a -> a -> s -> (a, t) Modify the target(s) of a   (or ) by computing its bitwise  with another value, N returning the result (or a monoidal summary of all of the results traversed)   () :: ( s m,  a) =>   s a -> a -> m a  () :: ( s m,  a, Monoid a) =>   s a -> a -> m a Modify the target(s) of a  , (or ) by computing its bitwise  with another value, N returning the result (or a monoidal summary of all of the results traversed)   () :: ( s m,  a) =>   s a -> a -> m a  () :: ( s m,  a, Monoid a) =>   s a -> a -> m a FThis lens can be used to access the value of the nth bit in a number.  n is only a legal  into b if 0 <= n <  ( :: b)  16^.bitAt 4True 15^.bitAt 4False*Traverse over all bits in a numeric type. ,The bit position is available as the index. import Data.Word"toListOf traverseBits (5 :: Word8)/[True,False,True,False,False,False,False,False]If you supply this an , the result will  be an infinite $ that can be productively consumed.    "portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred (or ) a list of bytes into a    x = x ,   x = x ,  Traverse each  in a    =   g e l  (| 0x80) ::  ->  (or ) a list of characters into a  When writing back to the  it is assumed that every   lies between '\x00' and '\xff'.   x = x ,   x = x ,  #Traverse the individual bytes in a  as characters. When writing back to the  it is assumed that every   lies between '\x00' and '\xff'.   =   .  l  (| 'c') ::  -> #portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred (or ) a list of bytes into a    x = x ,   x = x ,  #Traverse the individual bytes in a    =   . e l  (| 0x80) ::  ->  (or ) a list of characters into a  When writing back to the  it is assumed that every   lies between '\x00' and '\xff'.   x = x ,   x = x ,  #Traverse the individual bytes in a  as characters. When writing back to the  it is assumed that every   lies between '\x00' and '\xff'.   =   g e l  (| 'c') ::  -> $portable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferredTraversals for ByteStrings.  (or () a list of bytes into a strict or lazy    x = x ,   x = x ,   (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 ,   x = x ,  Traverse each  in a strict or lazy    =   g  traverseList l  (| 0x80) ::  -> 2Traverse 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'.   =   .  l  (| 'c') ::  -> % Rank2Types experimentalEdward Kmett <ekmett@gmail.com> Safe-Inferred Access the  of a  number (1.0 :+ 0.0)^.real1.0  :: # f => (a -> f a) ->  a -> f ( a) Access the  imaginaryPart of a  number (0.0 :+ 1.0)^.imaginary1.0  :: # f => (a -> f a) ->  a -> f ( a)This isn't quite a legal lens. Notably the  ) l ( l b a) = blaw is violated when you set a  value with 0  and non-zero   as the  information is lost. So don' t do that! )Otherwise, this is a perfectly cromulent . 0Traverse both the real and imaginary parts of a  number. N traverseComplex :: Applicative f => (a -> f b) -> Complex a -> f (Complex b) &portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred(Traverse the typed value contained in a 7 where the type required by your function matches that  of the contents of the . ()^.by dynamic<<()>>'portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred IntSet isn't Foldable, but this X) can be used to access the members of an . &sumOf members $ setOf folded [1,2,3,4]10This * 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 Z and  reindexing it via . (over setmapped (+1) (fromList [1,2,3,4])fromList [2,3,4,5] Construct an  from a %, X, ,  or 6. 5setOf (folded._2) [("hello",1),("world",2),("!!!",3)]fromList [1,2,3]    :: % s ) -> s ->    :: X s ) -> s ->    ::  6 s ) -> s ->    ::   s ) -> s ->    ::   s ) -> s ->  (portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred A partial  reading and writing to the  of a  non-empty list. #Attempting to read or write to the  of an empty list will result in an #. [1,2,3]^._head1 A partial  reading and writing to the  of a  non-empty list #Attempting to read or write to the  of an empty list will result in an #. _tail .~ [3,4,5] $ [1,2] [1,3,4,5] A partial . reading and writing to the last element of a  non-empty list 6Attempting to read or write to the last element of an empty list will result in an #.  [1,2]^._last2 A partial 7 reading and replacing all but the a last element of a  non-empty list >Attempting to read or write to all but the last element of an empty list will result in an #. [1,2,3,4]^._init[1,2,3]:A traversal for reading and writing to the head of a list MThe position of the head in the original list (0) is available as the index. traverseHead +~ 1 $ [1,2,3][2,2,3]  :: % f => (a -> f a) -> [a] -> f [a]+A traversal for editing the tail of a list The position of each element in the original list is available as the index. traverseTail +~ 1 $ [1,2,3][1,3,4]  :: % f => (a -> f a) -> [a] -> f [a]'A traversal the last element in a list QThe position of the last element in the original list is available as the index. traverseLast +~ 1 $ [1,2,3][1,2,4]  :: % f => (a -> f a) -> [a] -> f [a]2A traversal of all but the last element of a list 8The position of each element is available as the index. traverseInit +~ 1 $ [1,2,3][2,3,3]  :: % f => (a -> f a) -> [a] -> f [a]) Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred Obtain a X by splitting another X, ;, % or :, according to the given splitting strategy.    :: g a -> X i s a -> X [i] s [a]  Obtain a X by splitting another X, ;, % or : on the given delimiter. Equivalent to   h  i.    ::  a => [a] -> X s a -> X s [a]  Obtain a X by splitting another X, ;, % or : on any of the given elements. Equivalent to   h  j.    ::  a => [a] -> X s a -> X s [a]  Obtain a X by splitting another X, ;, % or :- on elements satisfying the given predicate. Equivalent to   h  k.    :: (a -> ) -> X s a -> X s [a]  Obtain a X by splitting another X, ;, % or :0 into chunks terminated by the given delimiter. Equivalent to   h  i.    ::  a => [a] -> X s a -> X s [a]  Obtain a X by splitting another X, ;, % or :6 into chunks terminated by any of the given elements. Equivalent to   m  h  j.    ::  a => [a] -> X s a -> X s [a]  Obtain a X by splitting another X, ;, % or : into words9, with word boundaries indicated by the given predicate. Equivalent to   n  h  k.    :: (a -> ) -> X a -> X s [a]  Obtain a X by splitting another X, ;, % or : into lines9, with line boundaries indicated by the given predicate. Equivalent to   m  h  k.    :: (a -> ) -> X s a -> X s [a]  Obtain a X by splitting another X, ;, % or : into length-n pieces.    chunkingOf :: ) -> X s a -> X s [a]  Obtain a X by splitting another X, ;, % or :% into chunks of the given lengths, .    ::  n => [n] -> X s a -> X s [a]  Obtain a X by splitting another X, ;, % or :+ into chunks of the given lengths. Unlike  , the output X= will always be the same length as the first input argument.    ::  n => [n] -> X s a -> X s [a] 0Modify or retrieve the list of delimiters for a g. )Modify or retrieve the policy for what a g to do with delimiters. )Modify or retrieve the policy for what a g& should about consecutive delimiters. ,Modify or retrieve the policy for whether a g should drop an initial blank. ,Modify or retrieve the policy for whether a g should drop a final blank.  n* Rank2Types experimentalEdward Kmett <ekmett@gmail.com> Safe-Inferred ,Modify the target of a monoidally valued by ing another value. :m + Control.Lens"both <>~ "!!!" $ ("hello","world")("hello!!!","world!!!")   () :: $ a =>  s t a a -> a -> s -> t  () :: $ a => 6 s t a a -> a -> s -> t  () :: $ a =>  s t a a -> a -> s -> t  () :: $ a =>  s t a a -> a -> s -> t Modify the target(s) of a  , 6,  or  by  ing a value.   () :: ( s m, $ a) =>   s a -> a -> m ()  () :: ( s m, $ a) =>  6 s a -> a -> m ()  () :: ( s m, $ a) =>   s a -> a -> m ()  () :: ( s m, $ a) =>   s a -> a -> m () 2 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, () is more flexible. 2 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, () is more flexible. Isomorphism for  Isomorphism for  Isomorphism for  0:m + Control.Lens Data.Monoid.Lens Data.Foldableala _all foldMap [True,True]True0:m + Control.Lens Data.Monoid.Lens Data.Foldableala _all foldMap [True,False]FalseIsomorphism for  0:m + Control.Lens Data.Monoid.Lens Data.Foldableala _any foldMap [False,False]False0:m + Control.Lens Data.Monoid.Lens Data.Foldableala _any foldMap [True,False]TrueIsomorphism for  0:m + Control.Lens Data.Monoid.Lens Data.Foldableala _sum foldMap [1,2,3,4]10Isomorphism for  0:m + Control.Lens Data.Monoid.Lens Data.Foldableala _product foldMap [1,2,3,4]24Isomorphism for  Isomorphism for     +portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred A  that can access the nth element of a . ENote: This is only a legal lens if there is already such an element! A  is isomorphic to a   m = m , A  is isomorphic to a   m = m , Traverse the head of a  Traverse the tail of a  Traverse the last element of a  'Traverse all but the last element of a  Traverse the first n elements of a  Traverse all but the first n elements of a  'Travere all the elements numbered from i to j of a     ,portable provisionalEdward Kmett <ekmett@gmail.com>None (or  ) strict .    x = x ,    x = x ,   -Traverse the individual characters in strict . $anyOf text (=='o') $ "hello"^.packedTrue-portable provisionalEdward Kmett <ekmett@gmail.com>NonePack (or unpack) lazy .    x = x ,    x = x ,   (Traverse the individual characters in a . $ anyOf text (=='c') :: Text -> Bool .portable provisionalEdward Kmett <ekmett@gmail.com>NoneTraversals for strict or lazy   (or ) strict or lazy .    x = x ,    x = x ,   5Traverse the individual characters in strict or lazy . /MTPCs provisionalEdward Kmett <ekmett@gmail.com> Safe-InferredA  that focuses on the root of a . view root $ Node 42 []42A , of the direct descendants of the root of a  1 indexed by its position in the list of children h  "a 0 Rank2Types experimentalEdward Kmett <ekmett@gmail.com>NoneA   for working with a  of a w value. A   for working with a  of a w value. 1 non-portable provisionalEdward Kmett <ekmett@gmail.com>None "A lens reading and writing to the  of a  non-empty  #Attempting to read or write to the  of an empty  will result in an #. Vector.fromList [1,2,3]^._head1A  reading and writing to the  element of a  non-empty  #Attempting to read or write to the  element of an empty  will result in an #. Vector.fromList [1,2]^._last2"A lens reading and writing to the  of a  non-empty  #Attempting to read or write to the  of an empty  will result in an #. 8_tail .~ Vector.fromList [3,4,5] $ Vector.fromList [1,2]fromList [1,3,4,5]A % reading and replacing all but the a  element of a  non-empty  +Attempting to read or write to all but the  element of an empty  will result in an #.  Vector.fromList [1,2,3,4]^._initfromList [1,2,3] sliced i n provides a lens that edits the n elements starting at index i from a lens. KThis is only a valid lens if you do not change the length of the resulting . QAttempting to return a longer or shorter vector will result in violations of the  laws.  Similar to h, but returning a . Convert a list to a  (or back)  Convert a 9 to a version with all the elements in the reverse order  Convert a  to a version that doesn't retain any extra memory. $This is a more efficient version of , that works for any .  atIndex n is only a valid  into a  with  at least n + 1. This = will ignore any duplicates in the supplied list of indices. ?toListOf (atIndices [1,3,2,5,9,10]) $ Vector.fromList [2,4..40][4,8,6,12,20,22] i starting index n length    2 non-portable provisionalEdward Kmett <ekmett@gmail.com>None"A lens reading and writing to the   of a  non-empty   #Attempting to read or write to the   of an empty   will result in an #. Vector.fromList [1,2,3]^._head1A  reading and writing to the   element of a  non-empty   #Attempting to read or write to the   element of an empty   will result in an #. Vector.fromList [1,2]^._last2"A lens reading and writing to the   of a  non-empty   #Attempting to read or write to the   of an empty   will result in an #. 8_tail .~ Vector.fromList [3,4,5] $ Vector.fromList [1,2]fromList [1,3,4,5]A % reading and replacing all but the a   element of a  non-empty   +Attempting to read or write to all but the   element of an empty   will result in an #.  Vector.fromList [1,2,3,4]^._initfromList [1,2,3] sliced i n provides a lens that edits the n elements starting at index i from a lens. KThis is only a valid lens if you do not change the length of the resulting  . QAttempting to return a longer or shorter vector will result in violations of the  laws.  Similar to h, but returning a  . Convert a list to a   (or back)  Convert a   to a finite   (or back)  Convert a   to a finite   from right to left (or back)  Convert a  G back and forth to an initializer that when run produces a copy of the  .  Convert a   to a version that doesn't retain any extra memory.  Convert a  9 to a version with all the elements in the reverse order $This is a more efficient version of , that works for any  .  atIndex n is only a valid  into a   with  at least n + 1. This = will ignore any duplicates in the supplied list of indices. ?toListOf (atIndices [1,3,2,5,9,10]) $ Vector.fromList [2,4..40][4,8,6,12,20,22]i starting index n length 3&MPTCs, Rank2Types, LiberalTypeSynonyms provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred Access an element of an array. <Note: The indexed element is assumed to exist in the target .    arr  i "a arr ,   i  arr  [(i,e)] "a   i  e  arr :ix 2 .~ 9 $ (listArray (1,5) [4,5,6,7,8] :: Array Int Int)+array (1,5) [(1,4),(2,9),(3,6),(4,7),(5,8)] (This setter can be used to derive a new  from an old array by E applying a function to each of the indices to look it up in the old .  This is a  contravariant .    "a  .      "a  .    (  b) f arr  i "a arr  f i   ( (  b) f arr) "a b  An  of the elements of an  , using the 5 index into the array as the index of the traversal.  "a               4 Rank2Types experimentalEdward Kmett <ekmett@gmail.com> Safe-Inferred  (Modify the path by adding another path. :m + Control.Lens#both </>~ "!!!" $ ("hello","world")("hello/!!!","world/!!!")   ( ) ::  s a   ->  -> s -> a  ( ) :: 6 s a   ->  -> s -> a  ( ) ::  s a   ->  -> s -> a  ( ) ::  s a   ->  -> s -> a  Modify the target(s) of a  , 6,  or  by adding a path.   ( ) ::  s m =>   s  ->  -> m ()  ( ) ::  s m =>  6 s  ->  -> m ()  ( ) ::  s m =>   s  ->  -> m ()  ( ) ::  s m =>   s  ->  -> 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.!!!")   () ::  s a   ->  -> s -> a  () :: 6 s a   ->  -> s -> a  () ::  s a   ->  -> s -> a  () ::  s a   ->  -> s -> a Modify the target(s) of a  , 6,  or  by adding an extension.   () ::  s m =>   s  ->  -> m ()  () ::  s m =>  6 s  ->  -> m ()  () ::  s m =>   s  ->  -> m ()  () ::  s m =>   s  ->  -> 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"            5portable provisionalEdward Kmett <ekmett@gmail.com>NoneEvaluate the targets of a  or  into a data structure  according to the given .     =   =    =      ::   s a ->  a ->  s   ::   s a ->  a ->  s   :: (a ->  a) -> s ->  s) ->  a ->  s Evaluate the targets of a  or  according into a % data structure according to a given  in parallel.   =      ::   s a ->  a ->  s   ::   s a ->  a ->  s   :: ((a ->  a) -> s ->  s) ->  a ->  s  Transform a , X, %,  or  to 3 first evaluates its argument according to a given  before proceeding.      ::  t =>  a ->  [a]  Transform a , X, %,  or  to , evaluate its argument according to a given  in parallel with evaluating.      ::  t =>  a ->  [a] 6portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred$Evaluate the elements targeted by a , , 6,  % or X" according to the given strategy.  =  Z7         !"#$%&'()C*+,-Z./0123456789:;<=>?@AR;BCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`a b c d e f g h i  V j k l m n o p q r s t u v  U w x y z { | } ~            ~                                 8fklnmopqrstuvwxy{z}|g9eYDEWS@=>    :  !"#$%&'()X*+,-./0123456789:;<=>?@ABCDEFGHIJJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ !!!! ! ! ! ! !!""""####$$$$$%%`%%&'''(((((c((( )!)")#)$)%)&)')()))*)+),)-).)/)0*1*2*3*4*5*6*7*8*9*:*;*+<+=+>+c+++ +?+@+A,B,C-B-C.D.B.C/E/F0G0H11111I1J1K1L1M1N1O22222I2J2K2P2Q2R2M2L2N2O3S3T3U4V4W4X4Y4Z4[4\4]4^4_4`4a5b5c5d5e6fghgijklmnopoqgmrstuvwxyz{|}z{~TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTmmmosstsm      m                        ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 :st;^<m=x>?@ABsCDElFOlGQlHGIJKLMNOPQRSTUVWXYZ[\]^s_`abacadefgahaistjklomn^opqrsatauxvawstxayzx{|}~stxaooaa ^mmom[\a^smsts@@?@@       ! " # $|%&'()*+,-).+$/$0a1aba2a3a456@78a9):);<=>?@ABCD@EF@EG@EH@EI@EJ+K+LMNMNMMOMPMP.Q.R@ST@SUVWVXYZuYZ[YZwYZ9YZtY\uY][Y\wY\9Y^_Y\t`ab`ac`ad`ae`af`aghijkijlijmijnijoipqrlens-3.3Control.Lens.TraversalControl.Lens.IsomorphicControl.Lens.InternalControl.Lens.IndexedControl.Lens.IndexedGetterControl.Lens.CombinatorsControl.Lens.ActionControl.Lens.TypeControl.Lens.IndexedLensControl.Lens.IndexedTraversalControl.Lens.IndexedSetterControl.Lens.LoupeControl.Lens.TupleControl.Lens.SetterControl.Lens.GetterControl.Lens.IsoControl.Lens.Simple Data.Set.LensControl.Lens.ProjectionControl.Lens.ZoomData.HashSet.LensControl.Lens.FoldData.Data.LensLanguage.Haskell.TH.LensControl.Lens.IndexedFoldControl.Lens.RepresentableControl.Lens.PlatedControl.Lens.ZipperControl.Lens.WithIndexControl.Lens.THGHC.Generics.LensControl.Exception.LensData.Bits.LensData.ByteString.Strict.LensData.ByteString.Lazy.LensData.ByteString.LensData.Complex.LensData.Dynamic.LensData.IntSet.LensData.List.LensData.List.Split.LensData.Monoid.LensData.Sequence.LensData.Text.Strict.LensData.Text.Lazy.LensData.Text.LensData.Tree.LensData.Typeable.LensData.Vector.LensData.Vector.Generic.LensData.Array.LensSystem.FilePath.Lens Control.Parallel.Strategies.LensControl.Seq.LensSettableSetterGetter TraversalLensclone maximumOf minimumOfmapM_ traverseOf_Control.Monad.Trans.State.LazyStateindexedZoomzoomControl.Monad.ErrorErrorTControl.Monad.Trans.MaybeMaybeTControl.Monad.Trans.ListListTControl.Monad.WriterWriterTControl.Monad.RWSRWSTControl.Monad.StateStateTSimple backwardsControl.Lens.UnsafeIndexedTraversal IndexedLensFold IndexedFoldIso IndexedGetter Data.Functor<$><$ Control.Monadjoin imaginary Data.ComplexComplex traverseHeadControl.Lens.LensviewsetGettingData.Functor.Compose getComposeCompose%~+~-~*~//~^~^^~**~||~&&~%=+=-=*=//=**=^^=||=&&=%@~ traverseOfforOfmapMOfforMOf mapAccumROf mapAccumLOfmapOfover^..~.=anyOfData.Traversabletraverse Traversable foldMapOf Data.MonoidMonoidData.Text.InternalTextData.Functor.IdentityIdentity fmapDefault%Prelude.idfoldedControl.Monad.Reader.Classlocalunfoldr ibackwardsfrom Data.FoldablefoldMapfoldfoldrfoldltoListandoranyallproductsum traverse_Data.Either.Lens traverseLeftfor_forM_ sequence_ maximumByfoldr1foldl1Offoldl1foldr'foldl'foldrMfoldlM Data.List transposeControl.PlatedplateSimpleIndexedLensSimpleIndexedTraversalfoldrOffoldlOfallOfforOf_mapMOf_forMOf_ concatMapOffindOffoldrOf'foldlOf'foldrMOffoldlMOf IndexedSetterData.Distributive distribute Distributive Data.Just isNothing mapAccumR Control.LensData.ByteStringpackunpackData.ByteString.Char8Data.ByteString.LazyData.ByteString.Lazy.Char8base Isomorphism Isomorphic isomorphicisomapviaLevelMutator runMutator untainted untainted#tainted#Folding getFolding Effective effectiveAccessor runAccessorGettablecoerce EffectRWS getEffectRWSEffect getEffectBazaar runBazaarContextMaxNoMaxMinNoMin Sequenced getSequenced Traversed getTraversedIndexing runIndexingIndexingResult FocusingErr unfocusingErrErrgetErr FocusingMay unfocusingMayMaygetMay FocusingOn unfocusingOn FocusingPlusunfocusingPlus FocusingWithunfocusingWithFocusing unfocusinggetMingetMaxbazaarduplicateBazaarsell ineffectivenoEffect levelWidth leftLevel left1Level leftmostLevelrightmostLevel rightLevel right1Level focusLevel rezipLevelIndex withIndex IndexableIndexedindex<..>reindex<.>icomposeReifiedIndexedGetterReifyIndexedGetterreflectIndexedGetterIndexedGetting<$!><$!Acting MonadicFoldActionperformperforms^!actactsliftActSimpleReifiedLens ReifiedLens ReifyLens reflectLensSimpleOverloaded OverloadedLensLikeSimpleLensLike SimpleLenslens%%~%%=choosingchosen alongside cloneLens<%~<+~<-~<*~:=>:-> setmappedsetOfSimpleProjectionProject Projective projective Projectionstereoprojectby projectionmirrorMagnifymagnify ReifiedFold ReifyFold reflectFoldfoldingrepeated replicatedcycledunfoldediteratedfiltered takingWhile droppingWhilefoldOftoListOf^..andOforOf productOfsumOf sequenceAOf_ sequenceOf_asumOfmsumOfelemOf notElemOfconcatOflengthOfheadOf^?lastOfnullOf maximumByOf minimumByOffoldr1OfSimpleReifiedTraversalReifiedTraversalReifyTraversalreflectTraversalSimpleTraversal sequenceAOf sequenceOf transposeOfscanr1Ofscanl1Ofbothbeside traverseRighttakingdroppingcloneTraversal gtraversetinplatetemplateuniplatebiplate SubstType substType HasTypeVars typeVarsExHasNamenametypeVars substTypeVars conFieldsconNamedFieldsReifiedIndexedFoldReifyIndexedFoldreflectIndexedFold ifoldMapOfifoldrOfifoldlOfianyOfiallOf itraverseOf_iforOf_imapMOf_iforMOf_ iconcatMapOfifindOf ifoldrOf' ifoldlOf' ifoldrMOf ifoldlMOf itoListOf withIndicesOf indicesOf ifiltering itakingWhileidroppingWhile isplitting isplittingOnisplittingOneOfisplittingWhen iendingByiendingByOneOf iwordingBy iliningBy ichunkingOfisplittingPlacesisplittingPlacesBlanksPathwalk RepresentablerepRepfmapReppureRepapRepbindRep distributeReppaths tabulatedrmap rtraverse rtraverse_rforrmapMrmapM_rforMrfoldMaprfoldrrmappedrfolded rtraversedPlatedchildren childrenOnrewrite rewriteOf rewriteOn rewriteOnOfrewriteM rewriteMOf rewriteMOn rewriteMOnOfuniverse universeOf universeOn universeOnOf transform transformOn transformOf transformOnOf transformM transformMOn transformMOftransformMOnOfdescend descendOf descendOnOf descendOndescendA descendAOf descendAOnOf descendAOn descendA_ descendAOf_ descendAOnOf_ descendAOn_descendM descendMOf descendMOnOf descendMOn descendM_ descendMOf_ descendMOnOf_ descendMOn_contexts contextsOf contextsOn contextsOnOfholesholesOfholesOn holesOnOfparaOfpara composOpFoldpartspartsOf unsafePartsOf elementOfelementTapeZipperZipped:>Topfocuszipper coordinateupleftleft1rightright1rightsleftslefts1rights1widthgotogoto1leftmost rightmostdownwithin fromWithinrezipsaverestorerestore1unsafelyRestoreTraversableWithIndex itraverseFoldableWithIndexifoldMapifoldrifoldlifoldr'ifoldl'FunctorWithIndeximapimappedifoldedifoldingianyiall itraverse_ifor_imapM_iforM_ iconcatMapifindifoldrMifoldlMitoList withIndicesindices itraversediforimapMiforM imapAccumR imapAccumLiwhere LensRulesLensFlagGenerateSignatures ClassRequiredCreateInstance CreateClassSingletonRequiredHandleSingletons SingletonIsoSingletonAndFieldBuildTraversals PartialLenses SimpleLenses simpleLenses partialLensesbuildTraversalshandleSingletonssingletonAndField singletonIsosingletonRequired createClasscreateInstance classRequiredgenerateSignatureslensIso lensField lensClass lensFlags defaultRules lensRules classyRulesisoRules makeLenses makeClassymakeIso makeLensesFor makeClassyFormakeLensesWith GTraversalgenericgeneric1 exception|~&~&=|=<|~<&~<&=<|=bitAt traverseBits packedBytesbytes packedCharschars IsByteStringrealpolarizetraverseComplexdynamicmembers_head_tail_last_init traverseTail traverseLast traverseInit splitting splittingOnsplittingOneOf splittingWhenendingBy endingByOneOf wordingByliningBychunkingsplittingPlacessplittingPlacesBlanks delimiters delimiting condensingkeepInitialBlankskeepFinalBlanks<>~<>=<<>~<<>=_dual_endo_all_any_sum_product_firstordinalviewLviewR traverseTo traverseFrom traverseSlicepackedtextIsTextrootbranches_cast_gcastsliced toVectorOfvectorreversedforcedatIndex atIndicesasStream asStreamRclonedixixmapped traverseArray~=<~<=<.>~<.>=<<.>~<<.>=basename directory extensionfilenameevalOfparOfafter throughoutseqOfControl.CategoryCategory$fIsomorphicIsomorphism$fCategoryIsomorphism$fIsomorphic(->)transformers-0.3.0.0GHC.BaseFunctorControl.Applicative ApplicativeConstfmapghc-prim GHC.TypesInt Data.EitherEither Data.MaybeMaybecomonad-3.0.0.2Control.ComonadComonadmemptyextract$fSettableBackwards$fSettableIdentity$fComonadStoreIntLevel$fComonadLevel$fTraversableLevel$fFoldableLevel$fFunctorLevel$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$fComonadStoreaContext$fComonadContext$fFunctorContext $fMonoidMax $fMonoidMin$fMonoidSequenced$fMonoidTraversed$fGettableIndexing$fApplicativeIndexing$fFunctorIndexing$fFunctorIndexingResult$fApplicativeFocusingErr$fFunctorFocusingErr $fMonoidErr$fApplicativeFocusingMay$fFunctorFocusingMay $fMonoidMay$fApplicativeFocusingOn$fFunctorFocusingOn$fApplicativeFocusingPlus$fFunctorFocusingPlus$fApplicativeFocusingWith$fFunctorFocusingWith$fApplicativeFocusing$fFunctorFocusingconst# getConst#zipList# getZipList# wrapMonad# unwrapMonad#last#getLast#first# getFirst#product# getProduct#sum#getSum#any#getAny#all#getAll#dual#getDual#endo#appEndo#may#getMay#folding# getFolding#effect# getEffect# effectRWS# getEffectRWS# accessor# runAccessor#err#getErr# traversed# getTraversed# sequenced# getSequenced# focusing# unfocusing# focusingWith#unfocusingWith# focusingPlus#unfocusingPlus# focusingOn# unfocusingOn# focusingMay#unfocusingMay# focusingErr#unfocusingErr#mutator# runMutator# backwards# forwards#$fIndexediIndex$fIndexedi(->)Monadpure mtl-2.1.2Control.Monad.State.Classstate MonadStateGHC.NumNumGHC.Real FractionalIntegral GHC.FloatFloating GHC.Classes||Bool&&const$fContainskHashSet$fContainskSet$fContainsIntIntSet $fAtkHashMap$fAtkMap $fAtIntIntMapflip mapAccumLswap$fTraverseMaxkMap$fTraverseMaxIntIntMap$fTraverseMinkMap$fTraverseMinIntIntMap$fField9(,,,,,,,,)(,,,,,,,,)ii'$fField8(,,,,,,,,)(,,,,,,,,)hh'$fField8(,,,,,,,)(,,,,,,,)hh'$fField7(,,,,,,,,)(,,,,,,,,)gg'$fField7(,,,,,,,)(,,,,,,,)gg'$fField7(,,,,,,)(,,,,,,)gg'$fField6(,,,,,,,,)(,,,,,,,,)ff'$fField6(,,,,,,,)(,,,,,,,)ff'$fField6(,,,,,,)(,,,,,,)ff'$fField6(,,,,,)(,,,,,)ff'$fField5(,,,,,,,,)(,,,,,,,,)ee'$fField5(,,,,,,,)(,,,,,,,)ee'$fField5(,,,,,,)(,,,,,,)ee'$fField5(,,,,,)(,,,,,)ee'$fField5(,,,,)(,,,,)ee'$fField4(,,,,,,,,)(,,,,,,,,)dd'$fField4(,,,,,,,)(,,,,,,,)dd'$fField4(,,,,,,)(,,,,,,)dd'$fField4(,,,,,)(,,,,,)dd'$fField4(,,,,)(,,,,)dd'$fField4(,,,)(,,,)dd'$fField3(,,,,,,,,)(,,,,,,,,)cc'$fField3(,,,,,,,)(,,,,,,,)cc'$fField3(,,,,,,)(,,,,,,)cc'$fField3(,,,,,)(,,,,,)cc'$fField3(,,,,)(,,,,)cc'$fField3(,,,)(,,,)cc'$fField3(,,)(,,)cc'$fField2(,,,,,,,,)(,,,,,,,,)bb'$fField2(,,,,,,,)(,,,,,,,)bb'$fField2(,,,,,,)(,,,,,,)bb'$fField2(,,,,,)(,,,,,)bb'$fField2(,,,,)(,,,,)bb'$fField2(,,,)(,,,)bb'$fField2(,,)(,,)bb'$fField2(,)(,)bb'$fField1(,,,,,,,,)(,,,,,,,,)aa'$fField1(,,,,,,,)(,,,,,,,)aa'$fField1(,,,,,,)(,,,,,,)aa'$fField1(,,,,,)(,,,,,)aa'$fField1(,,,,)(,,,,)aa'$fField1(,,,)(,,,)aa'$fField1(,,)(,,)aa'$fField1(,)(,)aa'CharliftM$Just MonadReadercontainers-0.5.0.0 Data.Set.BaseSetOrd$fProjectiveProjects'b'$fProjective(->)adControl.Monad.Trans.RWS.Strict Control.Monad.Trans.State.StrictControl.Monad.Trans.Error$fMagnify(->)(->)Accessorba$fMagnifyIdentityTIdentityTkba$fMagnifyRWSTRWSTEffectRWSba$fMagnifyRWSTRWSTEffectRWSba0$fMagnifyReaderTReaderTEffectba$fZoomErrorTErrorTFocusingErrst$fZoomMaybeTMaybeTFocusingMayst$fZoomListTListTFocusingOnst"$fZoomWriterTWriterTFocusingPlusst#$fZoomWriterTWriterTFocusingPlusst0$fZoomRWSTRWSTFocusingWithst$fZoomRWSTRWSTFocusingWithst0$fZoomIdentityTIdentityTkst$fZoomReaderTReaderTkst$fZoomStateTStateTFocusingst$fZoomStateTStateTFocusingst0unordered-containers-0.2.2.1 Data.HashSetHashSethashable-1.1.2.5 Data.HashableHashableEqFoldableGHC.Listrepeat replicateiterateevenGHC.Enumsucc takeWhile dropWhileTrue sequenceA_asum Alternativemsum MonadPluselemnotElem concatMapconcatlengthhead listToMaybelastFalsenullmaximum fromMaybeGHC.ErrerrorminimumOrdering minimumByNothingskipfor sequenceAmapMforMsequence unwrapMonad WrapMonadscanr1scanl1 Data.DatagmapMDatainlinePerformIOGHC.IOunsafePerformIOFollowerOracle fromOracleAnswerMissFollowHitCacheHitMapDataBox dataBoxKey _dataBoxValstepdataBox sybChildren emptyHitMap insertHitMapfixEqcachereadCacheFollowerinsert2hitTest biplateData uniplateDatapartfollower$fFunctorOracle$fFunctorAnswertemplate-haskellLanguage.Haskell.TH.SyntaxnewNameName$fSubstTypePred $fSubstType[]$fSubstTypeType$fHasTypeVars[]$fHasTypeVarsPred$fHasTypeVarsType$fHasTypeVarsName$fHasTypeVarsTyVarBndr $fHasNameCon $fHasNameName$fHasNameTyVarBndrmap Data.Tuplefst split-0.2.1.1Data.List.Split.InternalsSplitter dropDelims onSublistoneOfwhenEltuncurrydropFinalBlank dropBlanksreturn<*>>>=$fRepresentable(->)$fRepresentableIdentityGHC.ShowShowGHC.ReadReadData.Typeable.InternalTypeablemplusnegate==insunconsWithDefaultouts unsafeOuts $fPlatedTree $fPlated[]CoilStringDouble>=peelTrackForkrecoilSnoc restoreTrack restoreTrack1unsafelyRestoreTrack $fZipper:>c $fZipperTopaData.IntMap.Base Data.Map.Basefind$fFunctorWithIndexIntSeq$fFunctorWithIndexInt[]$fTraversableWithIndexkHashMap$fFoldableWithIndexkHashMap$fFunctorWithIndexkHashMap$fTraversableWithIndexkMap$fFoldableWithIndexkMap$fFunctorWithIndexkMap$fTraversableWithIndexIntIntMap$fFoldableWithIndexIntIntMap$fFunctorWithIndexIntIntMap$fTraversableWithIndexIntVector$fFoldableWithIndexIntVector$fFunctorWithIndexIntVector$fTraversableWithIndexIntSeq$fFoldableWithIndexIntSeq$fTraversableWithIndexInt[]$fFoldableWithIndexInt[]freshMap makeIsoLenses getLensFields_lensIso _lensField _lensClass _lensFlags makeIsoTo makeIsoFrom makeIsoBody makeLensBodyplainappArgsappsappsTmakeFieldLensBodymakeFieldLenses unifyTypes GHC.GenericsGeneric tinplated maybeArg1Of$fGTraversal:.:$fGTraversalM1$fGTraversal:+:$fGTraversal:*:$fGTraversalU1$fGTraversalK1 GHC.Exception Exception SomeException Data.Bits.|.Bits.&.bitSize undefined integer-gmpGHC.Integer.TypeIntegerbytestring-0.10.0.0Data.ByteString.Internal ByteStringGHC.WordWord8Data.ByteString.Lazy.Internal$fIsByteStringByteString$fIsByteStringByteString0realPartpolar magnitudephase Data.DynamicDynamicData.IntSet.BaseIntSettailendkeepsmappendDualEndoAllAnySumProductFirstLast Data.SequenceSeqViewLviewlViewRviewrunviewlunviewr text-0.11.2.3 Data.TextData.Text.Lazy.InternalData.Text.Lazy $fIsTextText $fIsTextText0 Data.TreeTree subForest Data.Typeablecastgcastvector-0.10.0.1 Data.VectorVectorData.Vector.GenericData.Vector.Generic.BaseData.Vector.Fusion.StreamStream array-0.4.0.1Data.Array.BaseIArray!//ixmapboundsamapFilePathparallel-3.2.0.3Control.Parallel.StrategiesStrategyevalTraversableEvalparTraversablerdeepseq Control.Seq seqFoldable