f          ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F GH I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k lmnopqrstuvwxyz{|}~       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^ _ ` a b c d e f g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!{!|!}!~!!!!!!!!!!!!!!!!!!!""""""""##########$$$$$$$$$$$$$$$%%%%%%%%%%%&&&&&&''''''(((((())**++++++++++++++,,,,,,--- - - - - ------............. .!.".#.$.%.&.'.(.).*.+.,.-.../.0.1.2.3.4.5.6.7.8.9.:.;.<.=.>.?.@.A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.W.X.Y.Z.[.\.].^._.`.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.{.|.}.~..........................................................................///////////////00011111111111111111111111111111112222234444444445 5 5 5 6 7888888888888888899 9!9"9#9$:%:&:':(:):*;+;,;-;.;/;0;1<2<3<4<5<6<7=8=9=:>;><>=?>???@?A?B?C@D@EAFAGBHBIBJBKBLCMCNCOCPDQDRDSDTDUDVDWDXEYEZE[E\E]E^E_E`EaEbEcEdEeEfEgEhFiFjFkFlFmFnFoFpFqFrFsFtFuFvFwFxFyFzF{F|F}F~FFFGGGGGGGGGGGGHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHIIJJJJQK(C) 2014-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable Safe-InferredL Safe-Inferred   +(C) 2014-2015 Edward Kmett and Eric Mertens BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional non-portable Safe-InferredhReturn the the subset of given ordinals within a given bound and in order of the first occurrence seen.Bound:  0 <= x < lordinalNub 3 [-1,2,1,4,2,3][2,1]strict upper bound ordinals )unique, in-bound ordinals, in order seen  +(C) 2013-2015 Edward Kmett and Eric Mertens BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable Trustworthy <Compatibility shim for recent changes to template haskell's !%Apply arguments to a type constructor"Apply arguments to a function#-Construct a tuple type given a list of types.$4Construct a tuple value given a list of expressions.%3Construct a tuple pattern given a list of patterns.&&Apply arguments to a type constructor.'Return  contained in a .' !"#$%&'()*+,-./0123456789:;<=>?@ABCDEF' !"#$%&'()*+,-./0123456789:;<=>?@ABCDEF' !"#$%&'()*+,-./0123456789:;<=>?@ABCDEF' !"#$%&'()*+,-./0123456789:;<=>?@ABCDEF&(C) 2015 Edward Kmett and Eric Mertens BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable TrustworthyHMGGGGM(C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable Safe-Inferred (C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portableSafe3=K HIWrap a monadic effect with a phantom type argument. Used when magnifying NO.K3Wrap a monadic effect with a phantom type argument.NThis type family is used by P$ to describe the common effect type.OUsed by Q to R into ST.RMake a  out of  for error handling.UUsed by Q to R into ST.XMake a  out of  for error handling.[Used by Q to R into  or .^Used by Q to R into UV.aUsed by Q to R into NO.dUsed by Q to R into WX.gThis type family is used by Q$ to describe the common effect type.QHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefg      HIJKLMNOPQRSTUVWXYZ[\]^_`abcdefg gdefabc^_`[\]UVWXYZOPQRSTNKLMHIJ=HIJKLMNOPQRSTUVWXYZ[\]^_`abcdefg      (C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional non-portable Safe-Inferredh Anything h must be isomorphic to the   .YSo you can pass our Z, into combinators from other lens libraries.hijkhijkhijkhijk(C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional non-portable Safe-Inferred 2346=KlrThis class is provided mostly for backwards compatibility with lens 3.8, but it can also shorten type signatures.m2This is a profunctor used internally to implement Review#It plays a role similar to that of [ or Const do for Control.Lens.Getterlmlmlmlm(C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable Safe-Inferredn type n a s t = o a a s to$This type is used internally by the \9 code to provide efficient access to the two parts of a Prism.nopnopopnnop(C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable TrustworthyqWThis class provides a generalized notion of list reversal extended to other containers.sThis is used internally by the ]T code to provide efficient access to the two functions that make up an isomorphism.qrst !"#$%&'qrststqrqrst !"#$%&'(C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable Safe-Inferred !"246HM uThis is an illegal (7 used to replace the contents of a list of consecutive {d values representing each layer of a structure into the original shape that they were derived from.Attempting to FlowL something back into a shape other than the one it was taken from will fail.xThis is an illegal  used to construct a single {.{This data type represents a path-compressed copy of one level of a source data structure. We can safely use path-compression because we know the depth of the tree.+Path compression is performed by viewing a {l as a PATRICIA trie of the paths into the structure to leaves at a given depth, similar in many ways to a ^_i, but unlike a regular PATRICIA trie we do not need to store the mask bits merely the depth of the fork.5One invariant of this structure is that underneath a ~ node you will not find any | nodes, so | can only occur at the root.)Append a pair of { values to get a new { with path compression.As the {< type is user-visible, we do not expose this as an illegal *' instance, and just use it directly in x as needed.Generate the leaf of a given x4 based on whether or not we're at the correct depth.+Walk down one constructor in a {, veering left.,Walk down one constructor in a {, veering right.-This is an illegal (..This is an illegal .uvwxyz{|}~)+,-/0.1234 uvwxyz{|}~ {~}|xyzuvwuvwxyz{~}|)+,-/0.1234(C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable Safe-Inferred 2346=HKM ( composition of `a 5 with a  , used by b.( composition of `a 6 with a  , used by c.]A function with access to a index. This constructor may be useful when you need to store an  in a container to avoid ImpredicativeTypes. %index :: Indexed i a b -> i -> a -> bnThis class permits overloading of function application for things that also admit a notion of a key or index.Build a function from an  function. This is a  that is both 7 by f and 8 by g such that f is left adjoint to g^. From this you can derive a lot of structure due to the preservation of limits and colimits.- is strong enough to let us distribute every   over every Haskell +. This is effectively a generalization of 9.^This permits us to make a decision at an outermost point about whether or not we use an index.Ideally any use of this function should be done in such a way so that you compute the same answer, but this cannot be enforced at the type level. Transform a d into an e or a f into an g, etc.  :: d s t a b -> e 6 s t a b  :: \ s t a b -> e 6 s t a b  :: h s t a b -> i 6 s t a b  :: ] s t a b -> i 6 s t a b  :: f s a -> g 6 s a  :: j s a -> k 6 s a  ::  6 p => l ( f) s t a b -> m p f s t a b Transform a d into an e or a f into an g, etc.This combinator is like > except that it handles large traversals and folds gracefully.  :: d s t a b -> e 5 s t a b  :: \ s t a b -> e 5 s t a b  :: h s t a b -> i 5 s t a b  :: ] s t a b -> i 5 s t a b  :: f s a -> g 5 s a  :: j s a -> k 5 s a  ::  5 p => l ( f) s t a b -> m p f s t a bHFold a container with indices returning both the indices and the values.)The result is only valid to compose in a  TraversalD, if you don't edit the index as edits to the index have no effect.When composed with an  IndexedFold or IndexedTraversal this yields an () Fold of the indices.1:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWX(:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWX(C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable Safe-Inferred 23468=>HKM type  p g a s =  p g a a sThis is a generalized form of o that can be repeatedly cloned with less impact on its performance, and which permits the use of an arbitrary  .The extra phantom " is used to let us lie and claim j-compatibility under limited circumstances. This is used internally to permit a number of combinators to gracefully degrade when applied to a f or j. type  p a s =  p a a sThis is a generalized form of o that can be repeatedly cloned with less impact on its performance, and which permits the use of an arbitrary   type  a s =  a a s0The indexed store can be used to characterize a h and is used by n. a b t is isomorphic to newtype  a b t =  { runContext :: forall f.  f => (a -> f b) -> f t } , and to exists s. (s, h s t a b).A  is like a h3 that has already been applied to a some structure.'This is used internally to construct a o,  or  from a singleton value.This is an indexed analogue to Y# for when you are working with an .This is the generalization of Z to an indexed comonad store.This is the generalization of [ to an indexed comonad store.This is the generalization of \ to an indexed comonad store.This is the generalization of ] to an indexed comonad store.This is the generalization of ^ to an indexed comonad store.This is the generalization of _ to an indexed comonad store.2We can always forget the rest of the structure of w: and obtain a simpler indexed comonad store model called .6This is a Bob Atkey -style 2-argument indexed comonad.It exists as a superclass for ( and expresses the functoriality of an  in its third argument.mThe notion of indexed monads is covered in more depth in Bob Atkey's "Parameterized Notions of Computation"  'http://bentnib.org/paramnotions-jfp.pdf) and that construction is dualized here.?extract from an indexed comonadic value when the indices match.9duplicate an indexed comonadic value splitting the index.;extend a indexed comonadic computation splitting the index.6This is a Bob Atkey -style 2-argument indexed functor.It exists as a superclass for ( and expresses the functoriality of an  in its third argument.`We can convert any  K to a function, possibly losing information about an index in the process.2`abcdefghijklmnopqrstuv!`abcdefghijklmnopqrstuv(C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable Safe-Inferred 2468=>HKM NThis alias is helpful when it comes to reducing repetition in type signatures. type  p g a t =  p g a a t  is like ), except that it provides a questionable J instance To protect this instance it relies on the soundness of another  type, and usage conventions.@For example. This lets us write a suitably polymorphic and lazy p", but there must be a better way!NThis alias is helpful when it comes to reducing repetition in type signatures. type  p a t =  p a a t This is used to characterize a d.Ta.k.a. indexed Cartesian store comonad, indexed Kleene store comonad, or an indexed FunList. *http://twanvl.nl/blog/haskell/non-regular1A  is like a d1 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 , (where N might be infinite).Mnemonically, a / holds many stores and you can easily add more.This is a final encoding of .NThis alias is helpful when it comes to reducing repetition in type signatures. type  p g a t =  p g a a t  is like ), except that it provides a questionable J instance To protect this instance it relies on the soundness of another  type, and usage conventions.@For example. This lets us write a suitably polymorphic and lazy p", but there must be a better way!NThis alias is helpful when it comes to reducing repetition in type signatures. type  p a t =  p a a t This is used to characterize a d.Ta.k.a. indexed Cartesian store comonad, indexed Kleene store comonad, or an indexed FunList. *http://twanvl.nl/blog/haskell/non-regular1A  is like a d1 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 , (where N might be infinite).Mnemonically, a / holds many stores and you can easily add more.This is a final encoding of .&This class is used to run the various  variants used in this library.;wxyz{|}~1wxyz{|}~(C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable Safe-Inferred!"246=>HKMBThis is used to generate an indexed magma from an unindexed sourceLBy constructing it this way we avoid infinite reassociations where possible.In  p g a b t, g has a nominal+ role to avoid exposing an illegal _|_ via 3, while the remaining arguments are degraded to a nominal role by the invariants of BThis is used to generate an indexed magma from an unindexed sourceTBy constructing it this way we avoid infinite reassociations in sums where possible.;This is a a non-reassociating initially encoded version of .<This provides a way to peek at the internal structure of a d or eRun a J where all the individual leaves have been converted to the expected type Generate a  using from a prefix sum. Generate a ? with leaves only while the predicate holds from left to right.'(C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional non-portable Safe-Inferred*246The mempty equivalent for a  ( . (C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable Safe-Inferred3HM  Used for q. Used for r. Used for s. Used for t.Used internally by u and the like. The argument a" of the result should not be used!Used internally by v and the like. The argument a" of the result should not be used!A  for a  (.Obtain the minimum.Obtain the maximum. Extract the @ element. This will fairly eagerly determine that it can return ( the moment it sees any element at all. Extract the @ element. This will fairly eagerly determine that it can return ( the moment it sees any element at all.)(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional Rank2Types Safe-Inferred !"'2346=HM-vThis is a convenient alias for use when you need to consume either indexed or non-indexed lens-likes based on context. type  p f =  ( p f) vThis is a convenient alias for use when you need to consume either indexed or non-indexed lens-likes based on context.FConvenient alias for constructing simple indexed lenses and their ilk.?Convenient alias for constructing indexed lenses and their ilk. type  f =  ( f) Many 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  p q f s a =  ( p q f) s a  type  f s t a b =  (->) (->) f s t a b  type  p f s t a b =  p (->) f s t a b type  p f s t a b =  p p f s t a b type  p f s a =  ( p f) s a A valid  l should satisfy the laws: l  "a  l ( Procompose f g) =  Procompose (l f) (l g)  This gives rise to the laws for , ,  , &,  , , , , , and 5 as well along with their index-preserving variants. type  f s t a b =  (->) f s t a b A  &,    , ... can be used instead of a &, E, ... whenever the type variables don't change upon setting a value. <w ::  & (xy a) a z ::  ( Int) [a] a .Note: To use this alias in your own code with  f or , you may have to turn on LiberalTypeSynonyms.2This is commonly abbreviated as a "prime" marker, e.g. % =  &.A relevant Fold (aka ) has one or more targets.An  can be used as a , but when composed with an , , or $ yields an  respectively.Every  is a valid f and can be used for {.A U describes how to retrieve multiple values in a way that can be composed with other  constructions.A  s aC provides a structure with operations very similar to those of the |} typeclass, see ~ and the other  combinators.!By convention, if there exists a foo method that expects a |} (f a), then there should be a fooOf method that takes a  s a and a value of type s.A  is a legal  that just ignores the supplied . Unlike a d a  is read-only. Since a , cannot be used to write back there are no & laws that apply.An  can be used as a , but when composed with an , , or $ yields an ,  or  respectively.Every  is a valid g and can be used for { like a .A T describes how to retrieve a single value in a way that can be composed with other  constructions. Unlike a & a  is read-only. Since a , cannot be used to write back there are no &Z laws that can be applied to it. In fact, it is isomorphic to an arbitrary function from (s -> a). Moreover, a  can be used directly as a f, since it just ignores the (. Composable asTypeOf0. Useful for constraining excess polymorphism, foo . (id :: As Int) . bar.A  .A witness that (a ~ s, b ~ t).Note: Composition with an  is index-preserving. A   . A   l is a  & that can also be turned around with  to obtain a  in the opposite direction.There are two laws that a   should satisfy: First, if I  or  a value with a   and then r or use (), I will get it back: r l ( l b) "a Just b #Second, if you can extract a value a using a   l from a value s, then the value s is completely described by l and a:If r l s "a Just a then  l a "a sThese two laws imply that the   laws hold for every   and that we  at most 1 element:  l x <= 1 "It may help to think of this as a & that can be partial in one direction.Every   is a valid  .Every  is a valid  .For example, you might have a   Integer ! allows you to always go from a  to an Integer,, and provide you with tools to check if an Integer is a  and/or to edit one if it is. nat ::   Integer  nat =   toInteger $ \ i -> if i < 0 then Left i else Right ( fromInteger i) Now we can ask if an Integer is a .5^?natJust 5 (-5)^?natNothing We can update the ones that are:(-3,4) & both.nat *~ 2(-3,8)And we can then convert from a  to an Integer.5 ^. re nat -- :: Natural5Similarly we can use a   to  the Left half of an Either:Left "hello" & _Left %~ lengthLeft 5or to construct an Either: 5^.re _LeftLeft 5#such that if you query it with the  (, you will get your original input back.5^.re _Left ^? _LeftJust 5&Another interesting way to think of a  ! is as the categorical dual of a & -- a co-&8, so to speak. This is what permits the construction of .Note: Composition with a   is index-preserving. KIf you see this in a signature for a function, the function is expecting a  % (in practice, this usually means a  ). This is a limited form of a   that can only be used for re operations. Like with a #, there are no laws to state for a  .You can generate a   by using unto. You can also use any   or  directly as a  . type   =   2Isomorphism families can be composed with another & using (.) and id.Note: Composition with an # is index- and measure- preserving. type IndexedPreservingSetter' i =  IndexedPreservingSetter An  can be composed with a ,  or $+ and leaves the index intact, yielding an . type  i =  ( i) Every  is a valid .The ! laws are still required to hold.A  is just a  that doesn't change the types.IThese are particularly common when talking about monomorphic containers. e.g. sets Data.Text.map ::   Char type  =   The only  law that can apply to a  l is that  l y ( l x a) "a  l y a  You can't  a 2 in general, so the other two laws are irrelevant. However, two  laws apply to a :  l id "a id  l f .  l g "a  l (f . g) "These can be stated more directly: l  "a  l f . i . l g "a l (f . i . g) You can compose a  with a & or a   using (. ) from the Prelude" and the result is always only a  and nothing more.over traverse f [a,b,c,d][f a,f b,f c,f d]over _1 f (a,b)(f a,b)"over (traverse._1) f [(a,b),(c,d)][(f a,b),(f c,d)]over both f (a,b) (f a,f b)$over (traverse.both) f [(a,b),(c,d)][(f a,f b),(f c,f d)] type  =   An ", leaves any index it is composed with alone. type  i =  ( i) Every  is a valid d or g.The  constraint is used to allow an  to be used directly as a d.The d! laws are still required to hold.In addition, the index iW should satisfy the requirement that it stays unchanged even when modifying the value a, otherwise traversals like indices break the   laws. type  =     A   can be used directly as a Z or a  (but not as a &e) and provides the ability to both read and update multiple fields, subject to some relatively weak   laws.TThese have also been known as multilenses, but they have the signature and spirit of  ::  f =>   (f a) (f b) a b 7and the more evocative name suggests their application.Most of the time the   you will want to use is just , but you can also pass any & or  as a  , and composition of a   (or & or  ) with a   (or & or  ) using (.) forms a valid  .The laws for a   t follow from the laws for 4 as stated in "The Essence of the Iterator Pattern". t  "a  9 (t f) . t g "a  . t ( . 9 f . g) .One consequence of this requirement is that a  K needs to leave the same number of elements as a candidate for subsequent   that it started with. Another testament to the strength of these laws is that the caveat expressed in section 5.5 of the "Essence of the Iterator Pattern" about exotic  instances that d the same entry multiple times was actually already ruled out by the second law in that same paper!! type ! =  " "An ", leaves any index it is composed with alone.# type # i =  ($ i) $Every $ is a valid & and a valid e.% type % =  & &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 & laws: 1) You get back what you put in:  l ( l v s) "a v 52) Putting back what you got doesn't change anything:  l ( l s) s "a s -3) Setting twice is the same as setting once:  l v' ( l v s) "a  l v' s =These laws are strong enough that the 4 type parameters of a &s cannot vary fully independently. For more on how they interact, read the "Why is it a Lens Family?" section of  /http://comonad.com/reader/2012/mirrored-lenses/.1There are some emergent properties of these laws:1)  l s must be injective for every s This is a consequence of law #12)  lZ must be surjective, because of law #2, which indicates that it is possible to obtain any v from some s such that  s v = sX3) Given just the first two laws you can prove a weaker form of law #3 where the values v that you are setting match:  l v ( l v s) "a  l v s Every & can be used directly as a Z or  .You can also use a & for { as if it were a  or . Since every & is a valid  , the   laws are required of any & you create: l  "a  9 (l f) . l g "a  . l ( . 9 f . g) type & s t a b = forall f.  f =>  f s t a b 5      !"#$%&5      !"#$%&5     &% $#"!5      !"#$%&(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional Rank2Types Safe-Inferred2346HMC'RThis is a convenient alias when defining highly polymorphic code that takes both + and )d as appropriate. If a function takes this it is expecting one of those two things based on context.(RThis is a convenient alias when defining highly polymorphic code that takes both , and *d as appropriate. If a function takes this it is expecting one of those two things based on context.) type ) i =  (* i) * Running an $ instantiates it to a concrete type.When consuming a setter directly to perform a mapping, you can use this type, but most user code will not need to use this type.+0This is a useful alias for use when consuming a .0Most user code will never have to use this type. type + =  , , Running a $ instantiates it to a concrete type.When consuming a setter directly to perform a mapping, you can use this type, but most user code will not need to use this type.-This 0 can be used to map over all of the values in a . 9 "a 6 -  "a 6  () "a 7 - over mapped f [a,b,c] [f a,f b,f c]over mapped (+1) [1,2,3][2,3,4]set mapped x [a,b,c][x,x,x] [[a,b],[c]] & mapped.mapped +~ x[[a + x,b + x],[c + x]]=over (mapped._2) length [("hello","world"),("leaders","!!!")][("hello",5),("leaders",3)] - ::  f =>  (f a) (f b) a b If you want an  use 1 9..This setter. can be used to modify all of the values in a .+You sometimes have to use this rather than - -- due to temporary insanity  is not a superclass of .  "a 6 . over lifted f [a,b,c] [f a,f b,f c]set lifted b (Just a)Just bIf you want an  use 1 ./This 0 can be used to map over all of the inputs to a .  "a 6 / 8getPredicate (over contramapped (*2) (Predicate even)) 5True,getOp (over contramapped (*5) (Op show)) 100"500"YPrelude.map ($ 1) $ over (mapped . _Unwrapping' Op . contramapped) (*12) [(*2),(+1),(^3)] [24,13,1728]0This ( can be used to map over the input of a .The most common  to use this with is (->).(argument %~ f) g xg (f x)!(argument %~ show) length [1,2,3]7(argument %~ f) h x y h (f x) yPMap over the argument of the result of a function -- i.e., its second argument:(mapped.argument %~ f) h x y h x (f y) 0 ::  (b -> r) (a -> r) a b 1Build an index-preserving  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: 1  6 "a  6  1 "a  Another way to view 2K is that it takes a "semantic editor combinator" and transforms it into a . 1 :: ((a -> b) -> s -> t) ->  s t a b 2Build a ,  or  depending on your choice of . 2 :: ((a -> b) -> s -> t) ->  s t a b 3Restore , to a full .4 Build an  from any .5 Clone an .6Modify the target of a & or all the targets of a  or   with a function. 9 "a 6 -  "a 6  2  6 "a  6  2 "a  Given any valid  l, you can also rely on the law: 6 l f  6 l g = 6 l (f  g) e.g.Dover mapped f (over mapped g [a,b,c]) == over mapped (f . g) [a,b,c]TrueAnother way to view 6 is to say that it transforms a & into a "semantic editor combinator".over mapped f (Just a) Just (f a)over mapped (*10) [1,2,3] [10,20,30]over _1 f (a,b)(f a,b)over _1 show (10,20) ("10",20) 6 ::  s t a b -> (a -> b) -> s -> t 6 :: , s t a b -> (a -> b) -> s -> t 7Replace the target of a & or all of the targets of a  or   with a constant value. () "a 7 - set _2 "hello" (1,()) (1,"hello")set mapped () [1,2,3,4] [(),(),(),()]Note: Attempting to 7 a  or B will fail at compile time with an relatively nice error message. 7 ::  s t a b -> b -> s -> t 7 ::  s t a b -> b -> s -> t 7 :: & s t a b -> b -> s -> t 7 ::   s t a b -> b -> s -> t 8Replace the target of a & or all of the targets of a  or  2 with a constant value, without changing its type.%This is a type restricted version of 7), which retains the type of the original.set' mapped x [a,b,c,d] [x,x,x,x]set' _2 "hello" (1,"world") (1,"hello")set' mapped 0 [1,2,3,4] [0,0,0,0]Note: Attempting to adjust 8 a  or B will fail at compile time with an relatively nice error message. 8 ::  s a -> a -> s -> s 8 ::   s a -> a -> s -> s 8 :: % s a -> a -> s -> s 8 ::  s a -> a -> s -> s 9Modifies the target of a & or all of the targets of a  or   with a user supplied function.This is an infix version of 6. 9 f "a - 9 f  f "a  9 f (a,b,c) & _3 %~ f (a,b,f c)(a,b) & both %~ f (f a,f b)_2 %~ length $ (1,"hello")(1,5)traverse %~ f $ [a,b,c] [f a,f b,f c]traverse %~ even $ [1,2,3][False,True,False]9traverse.traverse %~ length $ [["hello","world"],["!!!"]] [[5,5],[3]] (9) :: # s t a b -> (a -> b) -> s -> t (9) :: & s t a b -> (a -> b) -> s -> t (9) :: &% s t a b -> (a -> b) -> s -> t (9) ::   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 7!, provided for consistency with (H). f  a "a - : f  a (a,b,c,d) & _4 .~ e (a,b,c,e)(42,"world") & _1 .~ "hello"("hello","world")(a,b) & both .~ c(c,c) (:) ::  s t a b -> b -> s -> t (:) ::  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 7 l ( t) Nothing & id ?~ aJust aMap.empty & at 3 ?~ xfromList [(3,x)] (;) ::  s t a ( b) -> b -> s -> t (;) ::  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.SThis is mostly present for consistency, but may be useful for chaining assignments.AIf you do not need a copy of the intermediate result, then using l : t directly is a good idea.(a,b) & _1 <.~ c (c,(c,b))-("good","morning","vietnam") & _3 <.~ "world"$("world",("good","morning","world"))K(42,Map.fromList [("goodnight","gracie")]) & _2.at "hello" <.~ Just "world"G(Just "world",(42,fromList [("goodnight","gracie"),("hello","world")])) (<) :: ! s t a b -> b -> s -> (b, t) (<) :: $ 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) (=) ::  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  .(a,b) & _1 +~ c (a + c,b)(a,b) & both +~ c (a + c,b + c)(1,2) & _2 +~ 1(1,3)"[(a,b),(c,d)] & traverse.both +~ e[(a + e,b + e),(c + e,d + e)] (>) ::  a =>  s a -> a -> s -> s (>) ::  a =>   s a -> a -> s -> s (>) ::  a => % s a -> a -> s -> s (>) ::  a =>  s a -> a -> s -> s ?/Multiply the target(s) of a numerically valued &, ,  or  .(a,b) & _1 *~ c (a * c,b)(a,b) & both *~ c (a * c,b * c)(1,2) & _2 *~ 4(1,8)Just 24 & mapped *~ 2Just 48 (?) ::  a =>  s a -> a -> s -> s (?) ::  a =>   s a -> a -> s -> s (?) ::  a => % s a -> a -> s -> s (?) ::  a =>  s a -> a -> s -> s @0Decrement the target(s) of a numerically valued &, ,  or  .(a,b) & _1 -~ c (a - c,b)(a,b) & both -~ c (a - c,b - c)_1 -~ 2 $ (1,2)(-1,2)"mapped.mapped -~ 1 $ [[4,5],[6,7]] [[3,4],[5,6]] (@) ::  a =>  s a -> a -> s -> s (@) ::  a =>   s a -> a -> s -> s (@) ::  a => % s a -> a -> s -> s (@) ::  a =>  s a -> a -> s -> s A-Divide the target(s) of a numerically valued &, ,  or  .(a,b) & _1 //~ c (a / c,b)(a,b) & both //~ c (a / c,b / c)("Hawaii",10) & _2 //~ 2("Hawaii",5.0) (A) ::  a =>  s a -> a -> s -> s (A) ::  a =>   s a -> a -> s -> s (A) ::  a => % s a -> a -> s -> s (A) ::  a =>  s a -> a -> s -> s B,Raise the target(s) of a numerically valued &,  or  " to a non-negative integral power.(1,3) & _2 ^~ 2(1,9) (B) :: ( a,  e) =>  s a -> e -> s -> s (B) :: ( a,  e) =>   s a -> e -> s -> s (B) :: ( a,  e) => % s a -> e -> s -> s (B) :: ( a,  e) =>  s a -> e -> s -> s C-Raise the target(s) of a fractionally valued &,  or   to an integral power.(1,2) & _2 ^^~ (-1)(1,0.5) (C) :: ( a,  e) =>  s a -> e -> s -> s (C) :: ( a,  e) =>   s a -> e -> s -> s (C) :: ( a,  e) => % s a -> e -> s -> s (C) :: ( a,  e) =>  s a -> e -> s -> s D/Raise the target(s) of a floating-point valued &,  or   to an arbitrary power.(a,b) & _1 **~ c(a**c,b)(a,b) & both **~ c (a**c,b**c)_2 **~ 10 $ (3,2) (3,1024.0) (D) ::  a =>  s a -> a -> s -> s (D) ::  a =>   s a -> a -> s -> s (D) ::  a => % s a -> a -> s -> s (D) ::  a =>  s a -> a -> s -> s E Logically  the target(s) of a -valued & or .both ||~ True $ (False,True) (True,True)both ||~ False $ (False,True) (False,True) (E) ::  s  ->  -> s -> s (E) ::   s  ->  -> s -> s (E) :: % s  ->  -> s -> s (E) ::  s  ->  -> s -> s F Logically  the target(s) of a -valued & or .both &&~ True $ (False, True) (False,True)both &&~ False $ (False, True) (False,False) (F) ::  s  ->  -> s -> s (F) ::   s  ->  -> s -> s (F) :: % s  ->  -> s -> s (F) ::  s  ->  -> s -> s GReplace the target of a & or all of the targets of a  or  A in our monadic state with a new value, irrespective of the old.This is an alias for (H).-execState (do assign _1 c; assign _2 d) (a,b)(c,d)execState (both .= c) (a,b)(c,c) G ::  s m =>   s a -> a -> m () G ::  s m => % s a -> a -> m () G ::  s m =>  s a -> a -> m () G ::  s m =>  s a -> a -> m () HReplace the target of a & or all of the targets of a  or  A in our monadic state with a new value, irrespective of the old.This is an infix version of G.%execState (do _1 .= c; _2 .= d) (a,b)(c,d)execState (both .= c) (a,b)(c,c) (H) ::  s m =>   s a -> a -> m () (H) ::  s m => % s a -> a -> m () (H) ::  s m =>  s a -> a -> m () (H) ::  s m =>  s a -> a -> m () 9It puts the state in the monad or it gets the hose again.IMap over the target of a & or all of the targets of a  or   in our monadic state.$execState (do _1 %= f;_2 %= g) (a,b) (f a,g b)execState (do both %= f) (a,b) (f a,f b) (I) ::  s m =>   s a -> (a -> a) -> m () (I) ::  s m => % s a -> (a -> a) -> m () (I) ::  s m =>  s a -> (a -> a) -> m () (I) ::  s m =>  s a -> (a -> a) -> m () (I) ::  s m => , s s a b -> (a -> b) -> m () JThis is an alias for (I).KReplace the target of a & or all of the targets of a  or   in our monadic state with & a new value, irrespective of the old.-execState (do at 1 ?= a; at 2 ?= b) Map.emptyfromList [(1,a),(2,b)]1execState (do _1 ?= b; _2 ?= c) (Just a, Nothing)(Just b,Just c) (K) ::  s m =>   s ( a) -> a -> m () (K) ::  s m => % s ( a) -> a -> m () (K) ::  s m =>  s ( a) -> a -> m () (K) ::  s m =>  s ( a) -> a -> m () LModify the target(s) of a %, ,  or   by adding a value.Example: fresh ::  6 m => m 6 fresh = do  L 1   %execState (do _1 += c; _2 += d) (a,b) (a + c,b + d)CexecState (do _1.at 1.non 0 += 10) (Map.fromList [(2,100)],"hello")#(fromList [(1,10),(2,100)],"hello") (L) :: ( s m,  a) =>  s a -> a -> m () (L) :: ( s m,  a) =>   s a -> a -> m () (L) :: ( s m,  a) => % s a -> a -> m () (L) :: ( s m,  a) =>  s a -> a -> m () MModify the target(s) of a %, ,  or   by subtracting a value.%execState (do _1 -= c; _2 -= d) (a,b) (a - c,b - d) (M) :: ( s m,  a) =>  s a -> a -> m () (M) :: ( s m,  a) =>   s a -> a -> m () (M) :: ( s m,  a) => % s a -> a -> m () (M) :: ( s m,  a) =>  s a -> a -> m () NModify the target(s) of a %, ,  or   by multiplying by value.%execState (do _1 *= c; _2 *= d) (a,b) (a * c,b * d) (N) :: ( s m,  a) =>  s a -> a -> m () (N) :: ( s m,  a) =>   s a -> a -> m () (N) :: ( s m,  a) => % s a -> a -> m () (N) :: ( s m,  a) =>  s a -> a -> m () OModify the target(s) of a %, ,  or   by dividing by a value.'execState (do _1 //= c; _2 //= d) (a,b) (a / c,b / d) (O) :: ( s m,  a) =>  s a -> a -> m () (O) :: ( s m,  a) =>   s a -> a -> m () (O) :: ( s m,  a) => % s a -> a -> m () (O) :: ( s m,  a) =>  s a -> a -> m () P,Raise the target(s) of a numerically valued &,  or  " to a non-negative integral power. (P) :: ( s m,  a,  e) =>  s a -> e -> m () (P) :: ( s m,  a,  e) =>   s a -> e -> m () (P) :: ( s m,  a,  e) => % s a -> e -> m () (P) :: ( s m,  a,  e) =>  s a -> e -> m () Q,Raise the target(s) of a numerically valued &,  or   to an integral power. (Q) :: ( s m,  a,  e) =>  s a -> e -> m () (Q) :: ( s m,  a,  e) =>   s a -> e -> m () (Q) :: ( s m,  a,  e) => % s a -> e -> m () (Q) :: ( s m,  a,  e) =>  s a -> e -> m () R,Raise the target(s) of a numerically valued &,  or   to an arbitrary power'execState (do _1 **= c; _2 **= d) (a,b) (a**c,b**d) (R) :: ( s m,  a) =>  s a -> a -> m () (R) :: ( s m,  a) =>   s a -> a -> m () (R) :: ( s m,  a) => % s a -> a -> m () (R) :: ( s m,  a) =>  s a -> a -> m () SModify the target(s) of a %, ,  or   by taking their logical  with a value.[execState (do _1 &&= True; _2 &&= False; _3 &&= True; _4 &&= False) (True,True,False,False)(True,False,False,False) (S) ::  s m =>  s  ->  -> m () (S) ::  s m =>   s  ->  -> m () (S) ::  s m => % s  ->  -> m () (S) ::  s m =>  s  ->  -> m () TModify the target(s) of a %, 'Iso,  or   by taking their logical  with a value.[execState (do _1 ||= True; _2 ||= False; _3 ||= True; _4 ||= False) (True,True,False,False)(True,True,True,False) (T) ::  s m =>  s  ->  -> m () (T) ::  s m =>   s  ->  -> m () (T) ::  s m => % s  ->  -> m () (T) ::  s m =>  s  ->  -> m () U6Run a monadic action, and set all of the targets of a &,  or   to its result. (U) ::  s m =>  s s a b -> m b -> m () (U) ::  s m => & s s a b -> m b -> m () (U) ::  s m =>   s s a b -> m b -> m () (U) ::  s m =>  s s a b -> m b -> m () RAs a reasonable mnemonic, this lets you store the result of a monadic action in a &" rather than in a local variable. do foo <- bar ... *will store the result in a variable, while do foo U bar ... will store the result in a &, , or  .VSet with pass-throughKThis is useful for chaining assignment without round-tripping through your  stack. do x <-  V) ninety_nine_bottles_of_beer_on_the_wall AIf you do not need a copy of the intermediate result, then using l H d$ will avoid unused binding warnings. (V) ::  s m =>  s s a b -> b -> m b (V) ::  s m =>  s s a b -> b -> m b (V) ::  s m => & s s a b -> b -> m b (V) ::  s m =>   s s a b -> b -> m b WSet  a value with pass-throughKThis is useful for chaining assignment without round-tripping through your  stack. do x <- - "foo" W) ninety_nine_bottles_of_beer_on_the_wall AIf you do not need a copy of the intermediate result, then using l K d$ will avoid unused binding warnings. (W) ::  s m =>  s s a ( b) -> b -> m b (W) ::  s m =>  s s a ( b) -> b -> m b (W) ::  s m => & s s a ( b) -> b -> m b (W) ::  s m =>   s s a ( b) -> b -> m b X,Modify the target of a monoidally valued by ing another value.(Sum a,b) & _1 <>~ Sum c(Sum {getSum = a + c},b)(Sum a,Sum b) & both <>~ Sum c+(Sum {getSum = a + c},Sum {getSum = b + c})"both <>~ "!!!" $ ("hello","world")("hello!!!","world!!!") (X) ::  a =>  s t a a -> a -> s -> t (X) ::  a =>  s t a a -> a -> s -> t (X) ::  a => & s t a a -> a -> s -> t (X) ::  a =>   s t a a -> a -> s -> t YModify the target(s) of a %, ,  or   by  ing a value.?execState (do _1 <>= Sum c; _2 <>= Product d) (Sum a,Product b)3(Sum {getSum = a + c},Product {getProduct = b * d}),execState (both <>= "!!!") ("hello","world")("hello!!!","world!!!") (Y) :: ( s m,  a) =>  s a -> a -> m () (Y) :: ( s m,  a) =>   s a -> a -> m () (Y) :: ( s m,  a) => % s a -> a -> m () (Y) :: ( s m,  a) =>  s a -> a -> m () Z Write to a fragment of a larger Writer format.[This is a generalization of ; that alows you to modify just a portion of the resulting .\This is a generalization of ; that alows you to modify just a portion of the resulting ! with access to the index of an .]This is a generalization of  that alows you to " just a portion of the resulting .^This is a generalization of  that alows you to " just a portion of the resulting ", with access to the index of an ._%Map with index. This is an alias for i./When you do not need access to the index, then 6' is more liberal in what it can accept. 6 l "a _ l   _ l "a 6 l   _ :: ) i s t a b -> (i -> a -> b) -> s -> t _ :: $+ i s t a b -> (i -> a -> b) -> s -> t _ :: & i s t a b -> (i -> a -> b) -> s -> t `Set with index. Equivalent to _ with the current value ignored./When you do not need access to the index, then 7' is more liberal in what it can accept. 7 l "a ` l   ` :: $ i s t a b -> (i -> b) -> s -> t ` :: $& i s t a b -> (i -> b) -> s -> t ` :: ! i s t a b -> (i -> b) -> s -> t a Build an  from an -like function.Your supplied function f is required to satisfy: f  "a  f g  f h "a f (g  h) Equational reasoning: a  _ "a  _  a "a  Another way to view au is that it takes a "semantic editor combinator" which has been modified to carry an index and transforms it into a .bAdjust every target of an , $ or  with access to the index. (b) "a _ /When you do not need access to the index then (9() is more liberal in what it can accept. l 9 f "a l b  f (b) :: * i s t a b -> (i -> a -> b) -> s -> t (b) :: $, i s t a b -> (i -> a -> b) -> s -> t (b) :: & i s t a b -> (i -> a -> b) -> s -> t cReplace every target of an , $ or  with access to the index. (c) "a ` /When you do not need access to the index then (:() is more liberal in what it can accept. l : b "a l c  b (c) :: % i s t a b -> (i -> b) -> s -> t (c) :: $' i s t a b -> (i -> b) -> s -> t (c) :: ! i s t a b -> (i -> b) -> s -> t d/Adjust every target in the current state of an , $ or  with access to the index./When you do not need access to the index then (I() is more liberal in what it can accept. l I f "a l d  f (d) ::  s m => ( i s s a b -> (i -> a -> b) -> m () (d) ::  s m => $* i s s a b -> (i -> a -> b) -> m () (d) ::  s m => $ i s t a b -> (i -> a -> b) -> m () eThis is an alias for (d).f0Replace every target in the current state of an , $ or  with access to the index./When you do not need access to the index then (H() is more liberal in what it can accept. l H b "a l f  b (f) ::  s m => # i s s a b -> (i -> b) -> m () (f) ::  s m => $% i s s a b -> (i -> b) -> m () (f) ::  s m =>  i s t a b -> (i -> b) -> m () gERun an arrow command and use the output to set all the targets of a &,  or   to the result.g can be used very similarly to (UN), except that the type of the object being modified can change; for example: QrunKleisli action ((), (), ()) where action = assignA _1 (Kleisli (const getVal1)) >>> assignA _2 (Kleisli (const getVal2)) >>> assignA _3 (Kleisli (const getVal3)) getVal1 :: Either String Int getVal1 = ... getVal2 :: Either String Bool getVal2 = ... getVal3 :: Either String Char getVal3 = ...  has the type   (6, , ) g ::  p => ! s t a b -> p s b -> p s t g ::  p => & s t a b -> p s b -> p s t g ::  p =>   s t a b -> p s b -> p s t g ::  p =>  s t a b -> p s b -> p s t hh is a deprecated alias for 6.i&Map with index. (Deprecated alias for _)./When you do not need access to the index, then h' is more liberal in what it can accept. h l "a i l   i :: ) i s t a b -> (i -> a -> b) -> s -> t i :: $+ i s t a b -> (i -> a -> b) -> s -> t i :: & i s t a b -> (i -> a -> b) -> s -> t C'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghiK h'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghiK,+*)('21345-./067:9>@?ABCDEXF<;=GJHILMNOPQRTYSVKWUZ[\]^8i_`eabcdfgh hC'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghi#9:;<=>?@ABCDEFHIKLMNOPQRSTUVWXYbcdf(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional Rank2Types Safe-Inferred !"2346HMZj type j =  (k i) k>When you see this as an argument to a function, it expects an $l type l =  m m=When you see this as an argument to a function, it expects a &.4This type can also be used when you need to store a &D in a container, since it is rank-1. You can turn them back into a & with |,, or use it directly with combinators like  and ().nBuild a & from a getter and a setter. n :: : f => (s -> a) -> (s -> b -> t) -> (a -> f b) -> s -> f t s ^. lens getter settergetter ss & lens getter setter .~ b setter s bs & lens getter setter %~ fsetter s (f (getter s)) n! :: (s -> a) -> (s -> a -> s) -> % s a oBuild an index-preserving & from a j and a Z.p Build an $ from a j and a Z.q0This can be used to chain lens operations using op= syntax rather than op~+ syntax for simple non-type-changing cases.(10,20) & _1 .~ 30 & _2 .~ 40(30,40) (10,20) &~ do _1 .= 30; _2 .= 40(30,40)0This does not support type-changing assignment, e.g.(10,20) & _1 .~ "hello" ("hello",20)r(r&) can be used in one of two scenarios:When applied to a & , it can edit the target of the &1 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.5[66,97,116,109,97,110] & each %%~ \a -> ("na", chr a)("nananananana","Batman")7For all that the definition of this combinator is just: (r) "a  _It may be beneficial to think about it as if it had these even more restricted types, however: (r) ::  f => ]* s t a b -> (a -> f b) -> s -> f t (r) ::  f => &) s t a b -> (a -> f b) -> s -> f t (r) :: ( f => d# s t a b -> (a -> f b) -> s -> f t When applied to a  v, it can edit the targets of the traversals, extracting a supplemental monoidal summary of its actions, by choosing  f = ((,) m) (r) :: ]0 s t a b -> (a -> (r, b)) -> s -> (r, t) (r) :: &/ s t a b -> (a -> (r, b)) -> s -> (r, t) (r) ::  m => d) s t a b -> (a -> (m, b)) -> s -> (m, t) sModify the target of a &@ in the current state returning some extra information of type r or modify all targets of a d= in the current state, extracting extra information of type r. and return a monoidal summary of the changes.(runState (_1 %%= \x -> (f x, g x)) (a,b) (f a,(g a,b)) (s) "a ( ) It may be useful to think of (sO), instead, as having either of the following more restricted type signatures: (s) ::  s m => ]( s s a b -> (a -> (r, b)) -> m r (s) ::  s m => &' s s a b -> (a -> (r, b)) -> m r (s) :: ( s m,  r) => d! s s a b -> (a -> (r, b)) -> m r t]Passes the result of the left side to the function on the right side (forward pipe operator). This is the flipped version of (1), which is more common in languages like F# as (|>) where it is needed for inference. Here it is supplied for notational convenience and given a precedence that allows it to be nested inside uses of ().a & ff a"hello" & length & succ68This combinator is commonly used when applying multiple & operations in sequence.=("hello","world") & _1.element 0 .~ 'j' & _1.element 4 .~ 'y'("jelly","world")This reads somewhat similar to:Nflip execState ("hello","world") $ do _1.element 0 .= 'j'; _1.element 4 .= 'y'("jelly","world")uInfix flipped 9. (u) =  9 vThis is convenient to 2 argument order of composite functions defined as: fab ?? a = fmap ($ a) fab For the  instance  f = ((->) r)= you can reason about this function as if the definition was (v) "a : (h ?? x) ah a xexecState ?? [] $ modify (1:)[1]%over _2 ?? ("hello","world") $ length ("hello",5)(over ?? length ?? ("hello","world") $ _2 ("hello",5)wLift a &F so it can run under a function (or other corepresentable profunctor). w :: & s t a b -> &% (e -> s) (e -> t) (e -> a) (e -> b) "(\x -> (x-1,x+1)) ^. inside _1 $ 549runState (modify (1:) >> modify (2:)) ^. (inside _2) $ [][2,1]x8Merge two lenses, getters, setters, folds or traversals. y "a x   x :: j s a -> j s' a -> j ( s s') a x :: f s a -> f s' a -> f ( s s') a x :: % s a -> % s' a -> % ( s s') a x ::  s a ->  s' a ->  ( s s') a x ::  s a ->  s' a ->  ( s s') a y This is a & that updates either side of an &, where both sides have the same type. y "a x   Left a^.chosenaRight a^.chosenaRight "hello"^.chosen"hello"Right a & chosen *~ b Right (a * b) y :: & ( a a) ( b b) a b y f ( a) =   f a y f ( a) =   f a zz makes a & from two other lenses or a S from two other getters by executing them on their respective halves of a product.*(Left a, Right b)^.alongside chosen chosen(a,b)4(Left a, Right b) & alongside chosen chosen .~ (c,d)(Left c,Right d) z :: & s t a b -> & s' t' a' b' -> & (s,s') (t,t') (a,a') (b,b') z ::  s t a b ->  s' t' a' b' ->  (s,s') (t,t') (a,a') (b,b') {This & lets you view the current pos# of any indexed store comonad and seekR to a new position. This reduces the API for working these instances to a single &.  w "a w  {  s w "a w t {  s  f w "a w t {  f { :: % ( a s) a { ::  p => % ( p a s) a { ::  p => % ( p g a s) a | Cloning a &G is one way to make sure you aren't given something weaker, such as a dP and can be used as a way to pass around lenses that have to be monomorphic in f.!Note: This only accepts a proper &.Zlet example l x = set (cloneLens l) (x^.cloneLens l + 1) x in example _2 ("hello",1,"you")("hello",2,"you")}Clone a & as an IndexedPreservingLens4 that just passes through whatever index is on any $, ,  or  it is composed with.~ Clone an $ as an $ with the same index.Modify the target of a & and return the result.2When you do not need the result of the addition, () is more flexible. () :: &* s t a b -> (a -> b) -> s -> (b, t) () :: ]+ s t a b -> (a -> b) -> s -> (b, t) () ::  b => d$ 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, () is more flexible. () ::  a => % s a -> a -> s -> (a, s) () ::  a =>  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, () is more flexible. () ::  a => % s a -> a -> s -> (a, s) () ::  a =>  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, () is more flexible. () ::  a => % s a -> a -> s -> (a, s) () ::  a =>  s a -> a -> s -> (a, s) +Divide the target of a fractionally valued & and return the result.2When you do not need the result of the division, () is more flexible. () ::  a => % s a -> a -> s -> (a, s) () ::  a =>  s a -> a -> s -> (a, s) )Raise the target of a numerically valued & to a non-negative  power and return the result.3When you do not need the result of the operation, () is more flexible. () :: ( a,  e) => % s a -> e -> s -> (a, s) () :: ( a,  e) =>  s a -> e -> s -> (a, s) *Raise the target of a fractionally valued & to an  power and return the result.3When you do not need the result of the operation, () is more flexible. () :: ( a,  e) => % s a -> e -> s -> (a, s) () :: ( a,  e) =>  s a -> e -> s -> (a, s) ,Raise the target of a floating-point valued &. to an arbitrary power and return the result.3When you do not need the result of the operation, () is more flexible. () ::  a => % s a -> a -> s -> (a, s) () ::  a =>  s a -> a -> s -> (a, s)  Logically  a Boolean valued & and return the result.3When you do not need the result of the operation, () is more flexible. () :: % s  ->  -> s -> (, s) () ::  s  ->  -> s -> (, s)  Logically  a Boolean valued & and return the result.3When you do not need the result of the operation, () is more flexible. () :: % s  ->  -> s -> (, s) () ::  s  ->  -> s -> (, s) Modify the target of a &, but return the old value.%When you do not need the old value, () is more flexible. () :: &* s t a b -> (a -> b) -> s -> (a, t) () :: ]+ s t a b -> (a -> b) -> s -> (a, t) () ::  a => d$ s t a b -> (a -> b) -> s -> (a, t) Replace the target of a &, but return the old value.%When you do not need the old value, () is more flexible. () :: &# s t a b -> b -> s -> (a, t) () :: ]$ s t a b -> b -> s -> (a, t) () ::  a => d s t a b -> b -> s -> (a, t) -Increment the target of a numerically valued & and return the old value.%When you do not need the old value, () is more flexible.(a,b) & _1 <<+~ c (a,(a + c,b))(a,b) & _2 <<+~ c (b,(a,b + c)) () ::  a => % s a -> a -> s -> (a, s) () ::  a =>   s a -> a -> s -> (a, s) -Decrement the target of a numerically valued & and return the old value.%When you do not need the old value, () is more flexible.(a,b) & _1 <<-~ c (a,(a - c,b))(a,b) & _2 <<-~ c (b,(a,b - c)) () ::  a => % s a -> a -> s -> (a, s) () ::  a =>   s a -> a -> s -> (a, s) ,Multiply the target of a numerically valued & and return the old value.%When you do not need the old value, () is more flexible.(a,b) & _1 <<*~ c (a,(a * c,b))(a,b) & _2 <<*~ c (b,(a,b * c)) () ::  a => % s a -> a -> s -> (a, s) () ::  a =>   s a -> a -> s -> (a, s) *Divide the target of a numerically valued & and return the old value.%When you do not need the old value, () is more flexible.(a,b) & _1 <<//~ c (a,(a / c,b))("Hawaii",10) & _2 <<//~ 2(10.0,("Hawaii",5.0)) () :: Fractional a => % s a -> a -> s -> (a, s) () :: Fractional a =>   s a -> a -> s -> (a, s) )Raise the target of a numerically valued &2 to a non-negative power and return the old value.%When you do not need the old value, () is more flexible. () :: ( a,  e) => % s a -> e -> s -> (a, s) () :: ( a,  e) =>   s a -> e -> s -> (a, s) *Raise the target of a fractionally valued &/ to an integral power and return the old value.%When you do not need the old value, () is more flexible. () :: ( a,  e) => % s a -> e -> s -> (a, s) () :: ( a,  e) =>   s a -> e -> S -> (a, s) ,Raise the target of a floating-point valued &0 to an arbitrary power and return the old value.%When you do not need the old value, () is more flexible.(a,b) & _1 <<**~ c (a,(a**c,b))(a,b) & _2 <<**~ c (b,(a,b**c)) () ::  a => % s a -> a -> s -> (a, s) () ::  a =>   s a -> a -> s -> (a, s)  Logically  the target of a -valued & and return the old value.%When you do not need the old value, () is more flexible.(False,6) & _1 <<||~ True(False,(True,6))("hello",True) & _2 <<||~ False(True,("hello",True)) () :: % s  ->  -> s -> (, s) () ::   s  ->  -> s -> (, s)  Logically  the target of a -valued & and return the old value.%When you do not need the old value, () is more flexible.(False,6) & _1 <<&&~ True(False,(False,6))("hello",True) & _2 <<&&~ False(True,("hello",False)) () :: %# s Bool -> Bool -> s -> (Bool, s) () ::  " s Bool -> Bool -> s -> (Bool, s) )Modify the target of a monoidally valued & by )ing a new value and return the old value.%When you do not need the old value, () is more flexible.(Sum a,b) & _1 <<<>~ Sum c+(Sum {getSum = a},(Sum {getSum = a + c},b))$_2 <<<>~ ", 007" $ ("James", "Bond")("Bond",("James","Bond, 007")) () ::  r => % s r -> r -> s -> (r, s) () ::  r =>   s r -> r -> s -> (r, s) Modify the target of a & into your Monad';s state by a user supplied function and return the result.When applied to a dM, it this will return a monoidal summary of all of the intermediate results.3When you do not need the result of the operation, () is more flexible. () ::  s m => % s a -> (a -> a) -> m a () ::  s m =>  s a -> (a -> a) -> m a () :: ( s m,  a) =>  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, () is more flexible. () :: ( s m,  a) => % s a -> a -> m a () :: ( s m,  a) =>  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, () is more flexible. () :: ( s m,  a) => % s a -> a -> m a () :: ( s m,  a) =>  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, () is more flexible. () :: ( s m,  a) => % s a -> a -> m a () :: ( s m,  a) =>  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, () is more flexible. () :: ( s m,  a) => % s a -> a -> m a () :: ( s m,  a) =>  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, () is more flexible. () :: ( s m,  a,  e) => % s a -> e -> m a () :: ( s m,  a,  e) =>  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) =>  s a -> e -> m a ,Raise the target of a floating-point valued & into your Monad'5s state to an arbitrary power and return the result.3When you do not need the result of the operation, () is more flexible. () :: ( s m,  a) => % s a -> a -> m a () :: ( s m,  a) =>  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 =>  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 =>  s  ->  -> m  Modify the target of a & into your Monad'4s state by a user supplied function and return the old value that was replaced.When applied to a dK, it this will return a monoidal summary of all of the old values present.3When you do not need the result of the operation, () is more flexible. () ::  s m => % s a -> (a -> a) -> m a () ::  s m =>  s a -> (a -> a) -> m a () :: ( s m,  a) =>  s a -> (a -> a) -> m a () ::  s m => " ((,)a) s s a b -> (a -> b) -> m aReplace the target of a & into your Monad'3s state with a user supplied value and return the old value that was replaced.When applied to a dK, it this will return a monoidal summary of all of the old values present.3When you do not need the result of the operation, () is more flexible. () ::  s m => % s a -> a -> m a () ::  s m =>  s a -> a -> m a () :: ( s m,  t) =>  s a -> a -> m a Modify the target of a & into your Monad'*s state by adding a value and return the old value that was replaced.3When you do not need the result of the operation, () is more flexible. () :: ( s m,  a) => % s a -> a -> m a () :: ( s m,  a) =>   s a -> a -> m a Modify the target of a & into your Monad'/s state by subtracting a value and return the old value that was replaced.3When you do not need the result of the operation, () is more flexible. () :: ( s m,  a) => % s a -> a -> m a () :: ( s m,  a) =>   s a -> a -> m a Modify the target of a & into your Monad'.s state by multipling a value and return the old value that was replaced.3When you do not need the result of the operation, () is more flexible. () :: ( s m,  a) => % s a -> a -> m a () :: ( s m,  a) =>   s a -> a -> m a Modify the target of a & into your /s state by dividing by a value and return the old value that was replaced.3When you do not need the result of the operation, () is more flexible. () :: ( s m,  a) => % s a -> a -> m a () :: ( s m,  a) =>   s a -> a -> m a Modify the target of a & into your Monad'>s state by raising it by a non-negative power and return the old value that was replaced.3When you do not need the result of the operation, () is more flexible. () :: ( s m,  a,  e) => % s a -> e -> m a () :: ( s m,  a,  e) =>   s a -> a -> m a Modify the target of a & into your Monad';s state by raising it by an integral power and return the old value that was replaced.3When you do not need the result of the operation, () is more flexible. () :: ( s m,  a,  e) => % s a -> e -> m a () :: ( s m,  a,  e) =>   s a -> e -> m a Modify the target of a & into your Monad'<s state by raising it by an arbitrary power and return the old value that was replaced.3When you do not need the result of the operation, () is more flexible. () :: ( s m,  a) => % s a -> a -> m a () :: ( s m,  a) =>   s a -> a -> m a Modify the target of a & into your Monad's state by taking its logical  with a value and return the old value that was replaced.3When you do not need the result of the operation, () is more flexible. () ::  s m => % s  ->  -> m  () ::  s m =>   s  ->  -> m  Modify the target of a & into your Monad's state by taking its logical  with a value and return the old value that was replaced.3When you do not need the result of the operation, () is more flexible. () ::  s m => % s  ->  -> m  () ::  s m =>   s  ->  -> m  Modify the target of a & into your Monad' s state by ing a value and return the old value that was replaced.3When you do not need the result of the operation, () is more flexible. () :: ( s m,  r) => % s r -> r -> m r () :: ( s m,  r) =>   s r -> r -> m r ,Run a monadic action, and set the target of & to its result. () ::  s m => ] 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 d= because there are potential loss of state issues otherwise.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. for Arrows.Unlike ,  can't accept a simple Z-, but requires a full lens, or close enough. 6overA :: Arrow ar => Lens s t a b -> ar a b -> ar s t Adjust the target of an $H returning the intermediate result, or adjust all of the targets of an e6 and return a monoidal summary along with the answer. l  f "a 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 (). () :: $1 i s t a b -> (i -> a -> b) -> s -> (b, t) () ::  b => e+ i s t a b -> (i -> a -> b) -> s -> (b, t) Adjust the target of an $> returning the old value, or adjust all of the targets of an eH and return a monoidal summary of the old values along with the answer. () :: $1 i s t a b -> (i -> a -> b) -> s -> (a, t) () ::  a => e+ i s t a b -> (i -> a -> b) -> s -> (a, t) Adjust the target of an $G returning a supplementary result, or adjust all of the targets of an eL and return a monoidal summary of the supplementary results and the answer. () "a   () ::  f => $0 i s t a b -> (i -> a -> f b) -> s -> f t () :: ( f => e* i s t a b -> (i -> a -> f b) -> s -> f t yIn particular, it is often useful to think of this function as having one of these even more restricted type signatures: () :: $6 i s t a b -> (i -> a -> (r, b)) -> s -> (r, t) () ::  r => e0 i s t a b -> (i -> a -> (r, b)) -> s -> (r, t) Adjust the target of an $G returning a supplementary result, or adjust all of the targets of an eW within the current state, and return a monoidal summary of the supplementary results. l  f "a  (l  f) () ::  s m => $3 i s s a b -> (i -> a -> (r, b)) -> s -> m r () :: ( s m,  r) => e- i s s a b -> (i -> a -> (r, b)) -> s -> m r Adjust the target of an $H returning the intermediate result, or adjust all of the targets of an eV within the current state, and return a monoidal summary of the intermediate results. () ::  s m => $) i s s a b -> (i -> a -> b) -> m b () :: ( s m,  b) => e# i s s a b -> (i -> a -> b) -> m b Adjust the target of an $> returning the old value, or adjust all of the targets of an eL within the current state, and return a monoidal summary of the old values. () ::  s m => $) i s s a b -> (i -> a -> b) -> m a () :: ( s m,  b) => e# i s s a b -> (i -> a -> b) -> m a A version of () that works on m.("hello","world")^#_2"world" A version of  that works on m.$storing _2 "world" ("hello","there")("hello","world")A version of () that works on m.!("hello","there") & _2 #~ "world"("hello","world")A version of () that works on m.!("hello","world") & _2 #%~ length ("hello",5)A version of (r) that works on m.6("hello","world") & _2 #%%~ \x -> (length x, x ++ "!")(5,("hello","world!"))A version of () that works on m.A version of () that works on m.A version of () that works on m."("hello","world") & _2 <#%~ length(5,("hello",5))A version of () that works on m.A version of (s) that works on m.A version of () that works on m."("hello","there") & _2 <#~ "world"("world",("hello","world"))A version of () that works on m.'There is a field for every type in the  . Very zen.[] & mapped.devoid +~ 1[]Nothing & mapped.devoid %~ absNothing  :: %  a We can always retrieve a () from any type."hello"^.united()"hello" & united .~ ()"hello"#Fuse a composition of lenses using  to provide 9 fusion.#In general, given a pair of lenses foo and bar fusing (foo.bar) = foo.bar  however, foo and bar are either going to 9 internally or they are trivial. exploits the 2 lemma to merge these separate uses into a single 9.:This is particularly effective when the choice of functor f) is unknown at compile time or when the & foo.barN in the above description is recursive or complex enough to prevent inlining.  :: & s t a b -> & s t a b Zjklmnopqrstuvwxyz{|}~a#$%&jklmnopqrstuvwxyz{|}~a&%$#mlkjnporstuvqxyzw|}~{Zjklmnopqrstuvwxyz{|}~Fqrstuv(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional Rank2Types Safe-Inferred123468<=HJKM,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)(1,2,3,4) & _2 *~ 3 (1,6,3,4)_2 print (1,2)2(1,())   :: (s -> ) -> (a, s) ->     :: (( 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)(1,2) & _1 .~ "hello" ("hello",2)_1 putStrLn ("hello","world")hello ((),"world")/This can also be used on larger tuples as well:(1,2,3,4,5) & _1 +~ 41 (42,2,3,4,5)  :: & (a,b) (a',b) a a'  :: & (a,b,c) (a',b,c) a a'  :: & (a,b,c,d) (a',b,c,d) a a' ...  :: &/ (a,b,c,d,e,f,g,h,i) (a',b,c,d,e,f,g,h,i) a a' Strict version of Strict version of Strict version of Strict version of Strict version of Strict version of Strict version of Strict version of Strict version of   k ~(a,b) = (\b' -> (a,b'))  k b   k ~(a,b) = (\a' -> (a',b))  k a {      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTp      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRST(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional Rank2Types Safe-Inferred246HMrThis is a convenient alias used when consuming (indexed) getters and (indexed) folds in a highly general fashion.Used to consume an g.UWhen you see this in a type signature it indicates that you can pass the function a &, , d, f, \, ]I, or one of the indexed variants, and it will just "do the right thing".Most - combinators are able to be used with both a  or a fd in limited situations, to do so, they need to be monomorphic in what we are going to extract with . To be compatible with &, d and ]. we also restricted choices of the irrelevant t and b parameters.If a function accepts a  r s a , then when r is a , then you can pass a f (or d'), otherwise you can only pass this a  or &.Build an (index-preserving) $ from an arbitrary Haskell function.  f   g "a  (g  f)  a   f "a f a a ^.to ff a("hello","world")^.to snd"world" 5^.to succ6(0, -5)^._2.to abs5  :: (s -> a) ->  s a   :: (s -> (i, a)) ->  i s a ,Build an constant-valued (index-preserving) ! from an arbitrary Haskell value.  a   b "a  b a   b "a b a   b "a a   ( b) $This can be useful as a second case failing a  e.g. foo failing  0  :: a ->  s a   :: i -> a ->  i s a View the value pointed to by a , ] or &5 or the result of folding over all the results of a f or d" that points at a monoidal value.    "a   view (to f) af aview _2 (1,"hello")"hello"view (to succ) 56&view (_2._1) ("hello",("world","!!!"))"world"As , is commonly used to access the target of a 2 or obtain a monoidal summary of the targets of a U, It may be useful to think of it as having one of these more restricted signatures:  ::  s a -> s -> a  ::  m => f s m -> s -> m  ::  s a -> s -> a  :: % s a -> s -> a  ::  m =>  s m -> s -> m 7In a more general setting, such as when working with a  transformer stack you can use:  :: U s m =>  s a -> m a  :: (U s m,  a) => f s a -> m a  :: U s m =>  s a -> m a  :: U s m => % s a -> m a  :: (U s m,  a) =>  s a -> m a -View a function of the value pointed to by a  or &G or the result of folding over the result of mapping the targets of a f or d.  l f "a  (l   f) views (to f) g ag (f a)views _2 length (1,"hello")5As , is commonly used to access the target of a 2 or obtain a monoidal summary of the targets of a U, It may be useful to think of it as having one of these more restricted signatures:  ::  s a -> (a -> r) -> s -> r  ::  m => f! s a -> (a -> m) -> s -> m  :: ! s a -> (a -> r) -> s -> r  :: % s a -> (a -> r) -> s -> r  ::  m =>  s a -> (a -> m) -> s -> m 7In a more general setting, such as when working with a  transformer stack you can use:  :: U s m =>  s a -> (a -> r) -> m r  :: (U s m,  r) => f s a -> (a -> r) -> m r  :: U s m =>  s a -> (a -> r) -> m r  :: U s m => % s a -> (a -> r) -> m r  :: (U s m,  r) =>  s a -> (a -> r) -> m r  :: U s m =>  r s a -> (a -> r) -> m r View the value pointed to by a  or &5 or the result of folding over all the results of a f or d" that points at a monoidal values.This is the same operation as  with the arguments flipped.YThe fixity and semantics are such that subsequent field accesses can be performed with (). (a,b)^._2b("hello","world")^._2"world"import Data.Complex$((0, 1 :+ 2), 3)^._1._2.to magnitude2.23606797749979 () :: s ->  s a -> a () ::  m => s -> f s m -> m () :: s ->  s a -> a () :: s -> % s a -> a () ::  m => s ->  s m -> m Use the target of a &, ], or . in the current state, or use a summary of a f or d" that points to a monoidal value.evalState (use _1) (a,b)a$evalState (use _1) ("hello","world")"hello"  ::  s m =>  s a -> m a  :: ( s m,  r) => f s r -> m r  ::  s m =>  s a -> m a  ::  s m => % s a -> m a  :: ( s m,  r) =>  s r -> m r Use the target of a &, ] or . in the current state, or use a summary of a f or d" that points to a monoidal value.,evalState (uses _1 length) ("hello","world")5  ::  s m =>  s a -> (a -> r) -> m r  :: ( s m,  r) => f s a -> (a -> r) -> m r  ::  s m => % s a -> (a -> r) -> m r  ::  s m =>  s a -> (a -> r) -> m r  :: ( s m,  r) =>  s a -> (a -> r) -> m r  ::  s m =>  r s t a b -> (a -> r) -> m r This is a generalized form of VD that only extracts the portion of the log that is focused on by a  . If given a  or a  U then a monoidal summary of the parts of the log that are visited will be returned.  ::  w m =>  w u -> m a -> m (a, u)  ::  w m => % w u -> m a -> m (a, u)  ::  w m =>   w u -> m a -> m (a, u)  :: ( w m,  u) =>  w u -> m a -> m (a, u)  :: ( w m,  u) =>  w u -> m a -> m (a, u)  :: ( w m,  u) =>   w u -> m a -> m (a, u) This is a generalized form of VD that only extracts the portion of the log that is focused on by a  . If given a  or a  U then a monoidal summary of the parts of the log that are visited will be returned.  ::  w m => # i w u -> m a -> m (a, (i, u))  ::  w m => #$ i w u -> m a -> m (a, (i, u))  :: ( w m,  u) => % i w u -> m a -> m (a, (i, u))  :: ( w m,  u) =>  i w u -> m a -> m (a, (i, u)) This is a generalized form of VD that only extracts the portion of the log that is focused on by a  . If given a  or a  U then a monoidal summary of the parts of the log that are visited will be returned.  ::  w m => ( w u -> (u -> v) -> m a -> m (a, v)  ::  w m => %) w u -> (u -> v) -> m a -> m (a, v)  ::  w m =>  * w u -> (u -> v) -> m a -> m (a, v)  :: ( w m,  v) => * w u -> (u -> v) -> m a -> m (a, v)  :: ( w m,  v) => $ w u -> (u -> v) -> m a -> m (a, v)  :: ( w m,  v) =>  ( w u -> (u -> v) -> m a -> m (a, v) This is a generalized form of VD that only extracts the portion of the log that is focused on by a  . If given a  or a  U then a monoidal summary of the parts of the log that are visited will be returned.  ::  w m => - w u -> (i -> u -> v) -> m a -> m (a, v)  ::  w m => #. w u -> (i -> u -> v) -> m a -> m (a, v)  :: ( w m,  v) => / w u -> (i -> u -> v) -> m a -> m (a, v)  :: ( w m,  v) => ) w u -> (i -> u -> v) -> m a -> m (a, v) View the index and value of an ( into the current environment as a pair.When applied to an  the result will most likely be a nonsensical monoidal summary of the indices tupled with a monoidal summary of the values and probably not whatever it is you wanted.-View a function of the index and value of an  into the current environment.When applied to an B the result will be a monoidal summary instead of a single answer.  "a  Use the index and value of an " into the current state as a pair.When applied to an  the result will most likely be a nonsensical monoidal summary of the indices tupled with a monoidal summary of the values and probably not whatever it is you wanted.,Use a function of the index and value of an  into the current state.When applied to an B the result will be a monoidal summary instead of a single answer.View the index and value of an  or $.This is the same operation as  with the arguments flipped.YThe fixity and semantics are such that subsequent field accesses can be performed with (). ( ) :: s ->  i s a -> (i, a) ( ) :: s -> # i s a -> (i, a) AThe result probably doesn't have much meaning when applied to an . Coerce a  -compatible  to a . This is useful when using a   that is not simple as a  or a .  (C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional non-portable Safe-InferredHMAn analogue of  for .  :: (b -> t) -> Review' t b  =  .  Turn a  around to get a    =  .   =  .  un (to length) # [1,2,3]3Turn a   or ] around to build a .If you have an ], B is a more powerful version of this function that will return an ] instead of a mere . 5 ^.re _LeftLeft 56 ^.re (_Left.unto succ)Left 7  "a     "a     "a     "a     ::   s t a b ->  b t  ::  s t a b ->  b t This can be used to turn an ] or   around and ? a value (or the current environment) through it the other way.  "a     .  "a  review _Left "mustard"Left "mustard"review (unto succ) 56Usually  is used in the (->)  with a   or ]h, in which case it may be useful to think of it as having one of these more restricted type signatures:  ::   s a -> a -> s  ::   s a -> a -> s However, when working with a 9 transformer stack, it is sometimes useful to be able to  the current environment, in which case it may be beneficial to think of it as having one of these slightly more liberal type signatures:  :: U a m =>   s a -> m s  :: U a m =>   s a -> m s An infix alias for .  f # x "a f x l # x "a x   l #This is commonly used when using a   as a smart constructor. _Left # 4Left 4But it can be used for any   base 16 # 123"7b" (#) ::   s a -> a -> s (#) ::   s a -> a -> s (#) ::   s a -> a -> s (#) ::  s a -> a -> s This can be used to turn an ] or   around and U a value (or the current environment) through it the other way, applying a function.  "a     ( f) g "a g  f reviews _Left isRight "mustard"Falsereviews (unto succ) (*2) 38%Usually this function is used in the (->)  with a   or ]h, in which case it may be useful to think of it as having one of these more restricted type signatures:  ::   s a -> (s -> r) -> a -> r  ::   s a -> (s -> r) -> a -> r However, when working with a 9 transformer stack, it is sometimes useful to be able to  the current environment, in which case it may be beneficial to think of it as having one of these slightly more liberal type signatures:  :: U a m =>   s a -> (s -> r) -> m r  :: U a m =>   s a -> (s -> r) -> m r This can be used to turn an ] or   around and ? a value (or the current environment) through it the other way.  "a       "a W evalState (reuse _Left) 5Left 5evalState (reuse (unto succ)) 56  ::  a m =>   s a -> m s  ::  a m =>   s a -> m s This can be used to turn an ] or   around and B the current state through it the other way, applying a function.  "a     ( f) g "a W (g  f) *evalState (reuses _Left isLeft) (5 :: Int)True  ::  a m =>   s a -> (s -> r) -> m r  ::  a m =>   s a -> (s -> r) -> m r  lm     ml(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional non-portable TrustworthyHM type APrism' =   KIf you see this in a signature for a function, the function is expecting a  .Convert / to the pair of functions that characterize it.Clone a  6 so that you can reuse the same monomorphically typed   for different purposes.See | and / for examples of why you might want to do this.Build a \. t a is used instead of  a to permit the types of s and t to differ. This is usually used to build a  *, when you have to use an operation like  which already returns a .Use a  " as a kind of first-class pattern.  ::   s t a b -> &$ (t -> r) (s -> r) (b -> r) (a -> r)%Given a pair of prisms, project sums. Viewing a   as a co-&,, this combinator can be seen to be dual to z.Use a  " to work over part of a structure.lift a   through a Z functor, giving a Prism that matches only if all the elements of the container match the  .:[Left 1, Right "foo", Left 4, Right "woot"]^..below _Right[]M[Right "hail hydra!", Right "foo", Right "blah", Right "woot"]^..below _Right%[["hail hydra!","foo","blah","woot"]]Check to see if this   doesn't match.isn't _Left (Right 12)Trueisn't _Left (Left 12)Falseisn't _Empty []False!Retrieve the value targeted by a  W or return the original value while allowing the type to change if it does not match.matching _Just (Just 12)Right 12@matching _Just (Nothing :: Maybe Int) :: Either (Maybe Bool) Int Left Nothing This   provides a   for tweaking the  half of an :over _Left (+1) (Left 2)Left 3over _Left (+1) (Right 2)Right 2Right 42 ^._Left :: String""Left "hello" ^._Left"hello">It also can be turned around to obtain the embedding into the  half of an : _Left # 5Left 5 5^.re _LeftLeft 5 This   provides a   for tweaking the  half of an :over _Right (+1) (Left 2)Left 2over _Right (+1) (Right 2)Right 3Right "hello" ^._Right"hello"!Left "hello" ^._Right :: [Double][]>It also can be turned around to obtain the embedding into the  half of an : _Right # 5Right 5 5^.re _RightRight 5 This   provides a  ) for tweaking the target of the value of  in a .over _Just (+1) (Just 2)Just 3Unlike  this is a  *, and so you can use it to inject as well: _Just # 5Just 5 5^.re _JustJust 5Interestingly, m ^?   "a m Just x ^? _JustJust xNothing ^? _JustNothing This   provides the   of a X in a .Nothing ^? _NothingJust ()Just () ^? _NothingNothing3But you can turn it around and use it to construct X as well: _Nothing # ()Nothing & is a logically uninhabited data type. This is a   that will always fail to match.This  0 compares for exact equality with a given value. only 4 # ()4 5 ^? only 4NothingThis   compares for approximate equality with a given value and a predicate for testing, an example where the value is the empty list and the predicate checks that a list is empty (same as ) with the ) list instance):nearly [] null # ()[][1,2,3,4] ^? nearly [] nullNothing  [] Y ::   [a] ()To comply with the  " laws the arguments you supply to  nearly a p are somewhat constrained. We assume p x holds iff x "a a-. Under that assumption then this is a valid  .This is useful when working with a type where you can test equality for only a subset of its values, and the prism selects such a value. 7This is an improper prism for text formatting based on Z and [.This  q is "improper" in the sense that it normalizes the text formatting, but round tripping is idempotent given sane  'Read'/'Show' instances. _Show # 2"2""EQ" ^? _Show :: Maybe OrderingJust EQ  "a  \  readMaybe                         (C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional Rank2Types Safe-Inferred 2468=KThis class allows us to use O part of the environment, changing the environment supplied by many different  transformers. Unlike 4 this can change the environment of a deeply nested  transformer. Also, unlike ", this can be used with any valid , but cannot be used with a   or .MRun a monadic action in a larger environment than it was defined in, using a .This acts like C, but can in many cases change the type of the environment as well.3This is commonly used to lift actions in a simpler ]  into a  with a larger environment type.)This can be used to edit pretty much any - transformer stack with an environment in it:(1,2) & magnify _2 (+1)33flip Reader.runReader (1,2) $ magnify _1 Reader.ask1Dflip Reader.runReader (1,2,[10..20]) $ magnify (_3._tail) Reader.ask[11,12,13,14,15,16,17,18,19,20]  ::  s a -> (a -> r) -> s -> r  ::  r =>  s a -> (a -> r) -> s -> r  ::  w =>  s t -> ^ t w st c -> ^ s w st c  :: ( w,  c) =>  s a -> ^ a w st c -> ^ s w st c ... This class allows us to use  in, changing the _ supplied by many different , transformers, potentially quite deep in a  transformer stack.!Run a monadic action in a larger _" than it was defined in, using a % or .3This is commonly used to lift actions in a simpler _  into a _  with a larger _ type.When applied to a n over multiple values, the actions for each target are executed sequentially and the results are aggregated.)This can be used to edit pretty much any  transformer stack with a _ in it!-flip State.evalState (a,b) $ zoom _1 $ use ida.flip State.execState (a,b) $ zoom _1 $ id .= c(c,b)<flip State.execState [(a,b),(c,d)] $ zoom traverse $ _2 %= f[(a,f b),(c,f d)]<flip State.runState [(a,b),(c,d)] $ zoom traverse $ _2 <%= f((f b <> f d <> mempty,[(a,f b),(c,f d)])/flip State.evalState (a,b) $ zoom both (use id)a <> b  ::  m => % s t -> ` t m a -> ` s m a  :: ( m,  c) =>  s t -> ` t m c -> ` s m c  :: ( m,  w) => % s t -> a r w t m c -> a r w s m c  :: ( m,  w,  c) =>  s t -> a r w t m c -> a r w s m c  :: ( m,  w, b e) => % s t -> c e (a r w t m) c -> c e (a r w s m) c  :: ( m,  w,  c, b e) =>  s t -> c e (a r w t m) c -> c e (a r w s m) c ... d  =  efgdhijklmnopqrstefgdhijklmnopqrst(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-InferredHMThis % can be used to change the type of a u( by mapping the elements to new values. Sadly, you can't create a valid   for a u., but you can manipulate it by reading using  and reindexing it via .(over setmapped (+1) (fromList [1,2,3,4])fromList [2,3,4,5]Construct a set from a , f, d, h or ].setOf folded ["hello","world"]fromList ["hello","world"]5setOf (folded._2) [("hello",1),("world",2),("!!!",3)]fromList [1,2,3]  ::  s a -> s -> u a  :: v a =>  s a -> s -> u a  ::   s a -> s -> u a  :: % s a -> s -> u a  :: v a =>  s a -> s -> u a (C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable TrustworthyHMThis % can be used to change the type of a w( 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  and reindexing it via .Construct a set from a , f, d, h or ].  :: x a =>  s a -> s -> w a  :: (y a, x a) =>  s a -> s -> w a  :: x a =>   s a -> s -> w a  :: x a => % s a -> s -> w a  :: (y a, x a) =>  s a -> s -> w a (C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional Rank2Types Safe-Inferred2346HMh Obtain a ( by lifting an operation that returns a z result.+This can be useful to lift operations from  Data.List and elsewhere into a .[1,2,3,4]^..folding tail[2,3,4] Obtain a  by lifting { like function.[1,2,3,4]^..foldring foldr [1,2,3,4]Obtain  FoldWithIndex by lifting | like function. Obtain a  from any z indexed by ordinal position.Just 3^..folded[3]Nothing^..folded[][(1,2),(3,4)]^..folded.both [1,2,3,4] Obtain a  from any z indexed by ordinal position.Form a  by repeating the input forever. } "a -  "timingOut $ 5^..taking 20 repeated)[5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5]  ::  a a  A  that replicates its input n times. ~ n "a - (  n) 5^..replicated 20)[5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5]!Transform a non-empty  into a , that loops over its elements over and over.0timingOut $ [1,2,3]^..taking 7 (cycled traverse)[1,2,3,1,2,3,1] ! ::  s a ->  s a "Build a % that unfolds its values from a seed.  "a -  " ?10^..unfolded (\b -> if b == 0 then Nothing else Just (b, b-1))[10,9,8,7,6,5,4,3,2,1]#x  # f returns an infinite  of repeated applications of f to x. - (# f) a "a  f a # :: (a -> a) ->  a a $ Obtain an - that can be composed with to filter another &, , ,  (or  ).Note: This is not a legal  L, unless you are very careful not to invalidate the predicate on the target.Note: This is also not a legal  O, unless you are very careful not to inject a value that matches the predicate.*As a counter example, consider that given evens = $  the second   law is violated:  evens    evens    evens (  ) ,So, in order for this to qualify as a legal  K you can only use it for actions that preserve the result of the predicate![1..10]^..folded.filtered even [2,4,6,8,10]-This will preserve an index if it is present.% Obtain a ! by taking elements from another , &, ,  or   while a predicate holds.  p "a - (% p ) 5timingOut $ toListOf (takingWhile (<=3) folded) [1..][1,2,3] % :: (a -> ) ->  s a ->  s a % :: (a -> ) ->  s a ->  s a % :: (a -> ) ->  s a ->  s a -- * See note below % :: (a -> ) -> % s a ->  s a -- * See note below % :: (a -> ) ->   s a ->  s a -- * See note below % :: (a -> ) ->   s a ->  s a -- * See note below % :: (a -> ) ->  i s a ->  i s a -- * See note below % :: (a -> ) -> # i s a ->  i s a -- * See note below % :: (a -> ) ->  i s a ->  i s a % :: (a -> ) ->  i s a ->  i s a Note: When applied to a  , %3 yields something that can be used as if it were a  , but which is not a  w per the laws, unless you are careful to ensure that you do not invalidate the predicate when writing back through it.& Obtain a # by dropping elements from another , &, ,  or   while a predicate holds.  p "a - (& p ) ,toListOf (droppingWhile (<=3) folded) [1..6][4,5,6]-toListOf (droppingWhile (<=3) folded) [1,6,1][6,1] & :: (a -> ) ->  s a ->  s a & :: (a -> ) ->  s a ->  s a & :: (a -> ) ->  s a -> ! s a -- see notes & :: (a -> ) -> % s a -> ! s a -- see notes & :: (a -> ) ->   s a -> ! s a -- see notes & :: (a -> ) ->   s a -> ! s a -- see notes  & :: (a -> ) ->  s a ->  s a -- see notes & :: (a -> ) -> ! s a ->  s a -- see notes & :: (a -> ) ->  s a ->  s a & :: (a -> ) ->  s a ->  s a  & :: (a -> ) ->  i s a ->  i s a -- see notes & :: (a -> ) -> # i s a ->  i s a -- see notes & :: (a -> ) ->  i s a ->  i s a & :: (a -> ) ->  i s a ->  i s a kNote: Many uses of this combinator will yield something that meets the types, but not the laws of a valid   or . The   and  laws are only satisfied if the new values you assign also pass the predicate! Otherwise subsequent traversals will visit fewer elements and   fusion is not sound.'A  over the individual  of a . ' ::    ' ::     ' ::  6   ' ::  6   %Note: This function type-checks as a   but it doesn't satisfy the laws. It's only valid to use it when you don't insert any whitespace characters while traversing, and if your original u contains only isolated space characters (and no other characters that count as space, such as non-breaking spaces).(A  over the individual  of a . ( ::    ( ::     ( ::  6   ( ::  6   %Note: This function type-checks as a   but it doesn't satisfy the laws. It's only valid to use it when you don't insert any newline characters while traversing, and if your original , contains only isolated newline characters.).Map each part of a structure viewed through a &, ,  or  % to a monoid and combine the results.:foldMapOf (folded . both . _Just) Sum [(Just 21, Just 21)]Sum {getSum = 42}  = )   ) "a  d l = ) l    ) ::  s a -> (a -> r) -> s -> r ) ::  r => ! s a -> (a -> r) -> s -> r ) :: % s a -> (a -> r) -> s -> r ) ::  ! s a -> (a -> r) -> s -> r ) ::  r =>  s a -> (a -> r) -> s -> r ) ::  r =>   s a -> (a -> r) -> s -> r ) ::  r s a -> (a -> r) -> s -> r *5Combine the elements of a structure viewed through a &, ,  or   using a monoid.>foldOf (folded.folded) [[Sum 1,Sum 4],[Sum 8, Sum 8],[Sum 21]]Sum {getSum = 42}  = *   * "a  * ::  s m -> s -> m * ::  m =>  s m -> s -> m * :: % s m -> s -> m * ::   s m -> s -> m * ::  m =>  s m -> s -> m * ::  m =>   s m -> s -> m +IRight-associative fold of parts of a structure that are viewed through a &, ,  or  . { "a +   + :: ) s a -> (a -> r -> r) -> r -> s -> r + :: + s a -> (a -> r -> r) -> r -> s -> r + :: %* s a -> (a -> r -> r) -> r -> s -> r + ::  + s a -> (a -> r -> r) -> r -> s -> r + :: % s a -> (a -> r -> r) -> r -> s -> r + ::  ) s a -> (a -> r -> r) -> r -> s -> r  e l "a + l   + ::  (( r) s a -> (a -> r -> r) -> r -> s -> r ,LLeft-associative fold of the parts of a structure that are viewed through a &, ,  or  .  "a ,  , :: ) s a -> (r -> a -> r) -> r -> s -> r , :: + s a -> (r -> a -> r) -> r -> s -> r , :: %* s a -> (r -> a -> r) -> r -> s -> r , ::  + s a -> (r -> a -> r) -> r -> s -> r , :: % s a -> (r -> a -> r) -> r -> s -> r , ::  ) s a -> (r -> a -> r) -> r -> s -> r -#Extract a list of the targets of a  . See also (.).  "a -  (.) "a  - .(A convenient infix (flipped) version of -.[[1,2],[3]]^..id [[[1,2],[3]]][[1,2],[3]]^..traverse [[1,2],[3]][[1,2],[3]]^..traverse.traverse[1,2,3] (1,2)^..both[1,2]  xs "a xs .  (.) "a  - (. ) :: s ->  s a -> [a] (. ) :: s ->  s a -> [a] (. ) :: s -> % s a -> [a] (. ) :: s ->   s a -> [a] (. ) :: s ->  s a -> [a] (. ) :: s ->   s a -> [a] /Returns  if every target of a  is .andOf both (True,False)FalseandOf both (True,True)True  "a /  / ::  s  -> s ->  / ::  s  -> s ->  / :: % s  -> s ->  / ::   s  -> s ->  / ::  s  -> s ->  / ::   s  -> s ->  0Returns  if any target of a  is .orOf both (True,False)TrueorOf both (False,False)False  "a 0  0 ::  s  -> s ->  0 ::  s  -> s ->  0 :: % s  -> s ->  0 ::   s  -> s ->  0 ::  s  -> s ->  0 ::   s  -> s ->  1Returns  if any target of a  satisfies a predicate.anyOf both (=='x') ('x','y')Trueimport Data.Data.LensBanyOf biplate (== "world") (((),2::Int),"hello",("world",11::Int))True  "a 1   g l "a 2 l   1 ::  s a -> (a ->  ) -> s ->  1 ::  s a -> (a ->  ) -> s ->  1 :: % s a -> (a ->  ) -> s ->  1 ::   s a -> (a ->  ) -> s ->  1 ::  s a -> (a ->  ) -> s ->  1 ::   s a -> (a ->  ) -> s ->  2Returns  if every target of a  satisfies a predicate.allOf both (>=3) (4,5)TrueallOf folded (>=2) [1..10]False  "a 2   h l = 2 l   2 ::  s a -> (a ->  ) -> s ->  2 ::  s a -> (a ->  ) -> s ->  2 :: % s a -> (a ->  ) -> s ->  2 ::   s a -> (a ->  ) -> s ->  2 ::  s a -> (a ->  ) -> s ->  2 ::   s a -> (a ->  ) -> s ->  3Returns  only if no targets of a  satisfy a predicate.2noneOf each (is _Nothing) (Just 3, Just 4, Just 5)True3noneOf (folded.folded) (<10) [[13,99,20],[3,71,42]]False i l = 3 l   3 ::  s a -> (a ->  ) -> s ->  3 ::  s a -> (a ->  ) -> s ->  3 :: % s a -> (a ->  ) -> s ->  3 ::   s a -> (a ->  ) -> s ->  3 ::  s a -> (a ->  ) -> s ->  3 ::   s a -> (a ->  ) -> s ->  4Calculate the  of every number targeted by a .productOf both (4,5)20productOf folded [1,2,3,4,5]120  "a 4  [This operation may be more strict than you would expect. If you want a lazier version use ala   ) 4 ::  a =>  s a -> s -> a 4 ::  a =>  s a -> s -> a 4 ::  a => % s a -> s -> a 4 ::  a =>   s a -> s -> a 4 ::  a =>  s a -> s -> a 4 ::  a =>   s a -> s -> a 5Calculate the  of every number targeted by a .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 5  [This operation may be more strict than you would expect. If you want a lazier version use ala   ) 5 _1 ::  a => (a, b) -> a 5 (  ) :: (z f,  a) => f (a, b) -> a 5 ::  a =>  s a -> s -> a 5 ::  a =>  s a -> s -> a 5 ::  a => % s a -> s -> a 5 ::  a =>   s a -> s -> a 5 ::  a =>  s a -> s -> a 5 ::  a =>   s a -> s -> a 6&Traverse over all of the targets of a  (or ), computing an ( (or )-based answer, but unlike # do not construct a new structure. 6 generalizes  to work over any .When passed a , 6 can work over any , but when passed a , 6 requires an (.+traverseOf_ both putStrLn ("hello","world")helloworld  "a 6   6 _2 :: # f => (c -> f r) -> (d, c) -> f () 6  :: ( f => (a -> f b) ->  a c -> f ()  j l "a 6 l   !The rather specific signature of 65 allows it to be used as if the signature was any of: 6 ::  f => $ s a -> (a -> f r) -> s -> f () 6 :: ( f => & s a -> (a -> f r) -> s -> f () 6 ::  f => %% s a -> (a -> f r) -> s -> f () 6 ::  f =>  & s a -> (a -> f r) -> s -> f () 6 :: ( f =>  s a -> (a -> f r) -> s -> f () 6 :: ( f =>  $ s a -> (a -> f r) -> s -> f () 7&Traverse over all of the targets of a  (or ), computing an ( (or )-based answer, but unlike # do not construct a new structure. 7 generalizes  to work over any .When passed a , 7 can work over any , but when passed a , 7 requires an (.  "a 7  &forOf_ both ("hello","world") putStrLnhelloworld!The rather specific signature of 75 allows it to be used as if the signature was any of: k l s "a 7 l s   7 ::  f => $ s a -> s -> (a -> f r) -> f () 7 :: ( f => & s a -> s -> (a -> f r) -> f () 7 ::  f => %% s a -> s -> (a -> f r) -> f () 7 ::  f =>  & s a -> s -> (a -> f r) -> f () 7 :: ( f =>  s a -> s -> (a -> f r) -> f () 7 :: ( f =>  $ s a -> s -> (a -> f r) -> f () 8&Evaluate each action in observed by a 9 on a structure from left to right, ignoring the results.  "a 8  5sequenceAOf_ both (putStrLn "hello",putStrLn "world")helloworld 8 ::  f =>  s (f a) -> s -> f () 8 :: ( f =>  s (f a) -> s -> f () 8 ::  f => % s (f a) -> s -> f () 8 ::  f =>   s (f a) -> s -> f () 8 :: ( f =>  s (f a) -> s -> f () 8 :: ( f =>   s (f a) -> s -> f () 9Map each target of a g on a structure to a monadic action, evaluate these actions from left to right, and ignore the results.'mapMOf_ both putStrLn ("hello","world")helloworld  "a 9  9 ::  m => $ s a -> (a -> m r) -> s -> m () 9 ::  m => & s a -> (a -> m r) -> s -> m () 9 ::  m => %% s a -> (a -> m r) -> s -> m () 9 ::  m =>  & s a -> (a -> m r) -> s -> m () 9 ::  m =>  s a -> (a -> m r) -> s -> m () 9 ::  m =>  $ s a -> (a -> m r) -> s -> m () :: is 9# with two of its arguments flipped.'forMOf_ both ("hello","world") putStrLnhelloworld  "a :  : ::  m => $ s a -> s -> (a -> m r) -> m () : ::  m => & s a -> s -> (a -> m r) -> m () : ::  m => %% s a -> s -> (a -> m r) -> m () : ::  m =>  & s a -> s -> (a -> m r) -> m () : ::  m =>  s a -> s -> (a -> m r) -> m () : ::  m =>  $ s a -> s -> (a -> m r) -> m () ;-Evaluate each monadic action referenced by a = on the structure from left to right, and ignore the results.4sequenceOf_ both (putStrLn "hello",putStrLn "world")helloworld  "a ;  ; ::  m =>  s (m a) -> s -> m () ; ::  m =>  s (m a) -> s -> m () ; ::  m => % s (m a) -> s -> m () ; ::  m =>   s (m a) -> s -> m () ; ::  m =>  s (m a) -> s -> m () ; ::  m =>   s (m a) -> s -> m () <1The sum of a collection of actions, generalizing A.asumOf both ("hello","world") "helloworld",asumOf each (Nothing, Just "hello", Nothing) Just "hello"  "a <  < ::  f =>  s (f a) -> s -> f a < ::  f =>  s (f a) -> s -> f a < ::  f => % s (f a) -> s -> f a < ::  f =>   s (f a) -> s -> f a < ::  f =>  s (f a) -> s -> f a < ::  f =>   s (f a) -> s -> f a =1The sum of a collection of actions, generalizing A.msumOf both ("hello","world") "helloworld",msumOf each (Nothing, Just "hello", Nothing) Just "hello"  "a =  = ::  m =>  s (m a) -> s -> m a = ::  m =>  s (m a) -> s -> m a = ::  m => % s (m a) -> s -> m a = ::  m =>   s (m a) -> s -> m a = ::  m =>  s (m a) -> s -> m a = ::  m =>   s (m a) -> s -> m a >/Does the element occur anywhere within a given  of the structure?%elemOf both "hello" ("hello","world")True  "a >  > :: y a =>  s a -> a -> s ->  > :: y a =>  s a -> a -> s ->  > :: y a => % s a -> a -> s ->  > :: y a =>   s a -> a -> s ->  > :: y a =>  s a -> a -> s ->  > :: y a =>   s a -> a -> s ->  ?3Does the element not occur anywhere within a given  of the structure? notElemOf each 'd' ('a','b','c')True notElemOf each 'a' ('a','b','c')False  "a ?  ? :: y a =>  s a -> a -> s ->  ? :: y a =>  s a -> a -> s ->  ? :: y a =>   s a -> a -> s ->  ? :: y a => % s a -> a -> s ->  ? :: y a =>  s a -> a -> s ->  ? :: y a =>   s a -> a -> s ->  @)Map a function over all the targets of a 4 of a container and concatenate the resulting lists.)concatMapOf both (\x -> [x, x + 1]) (1,3) [1,2,3,4]  "a @  @ :: # s a -> (a -> [r]) -> s -> [r] @ :: % s a -> (a -> [r]) -> s -> [r] @ :: %$ s a -> (a -> [r]) -> s -> [r] @ ::  % s a -> (a -> [r]) -> s -> [r] @ ::  s a -> (a -> [r]) -> s -> [r] A+Concatenate all of the lists targeted by a  into a longer list.concatOf both ("pan","ama")"panama"  "a A  A "a  A ::  s [r] -> s -> [r] A ::  s [r] -> s -> [r] A ::   s [r] -> s -> [r] A :: % s [r] -> s -> [r] A ::  s [r] -> s -> [r] B0Calculate the number of targets there are for a  in a given container.Note:C This can be rather inefficient for large containers and just like ., this will not terminate for infinite folds.  "a B  lengthOf _1 ("hello",())1lengthOf traverse [1..10]100lengthOf (traverse.traverse) [[1,2],[3,4],[5,6]]6 B (  ) :: (z f, z g) => f (g a) -> 6 B ::  s a -> s -> 6 B ::  s a -> s -> 6 B :: % s a -> s -> 6 B ::   s a -> s -> 6 B ::  s a -> s -> 6 CPerform a safe  of a  or   or retrieve  the result from a  or &. When using a   as a partial &, or a  as a partial = this can be a convenient way to extract the optional value.BNote: if you get stack overflows due to this, you may want to use EI instead, which can deal more gracefully with heavily left-biased trees.Left 4 ^?_LeftJust 4Right 4 ^?_LeftNothing"world" ^? ix 3Just 'l'"world" ^? ix 20Nothing (C) "a  [ (C ) :: s ->  s a ->  a (C ) :: s ->  s a ->  a (C ) :: s -> % s a ->  a (C ) :: s ->   s a ->  a (C ) :: s ->  s a ->  a DPerform an *UNSAFE*  of a  or   assuming that it is there.Left 4 ^?! _Left4"world" ^?! ix 3'l' (D ) :: s ->  s a -> a (D ) :: s ->  s a -> a (D ) :: s -> % s a -> a (D ) :: s ->   s a -> a (D ) :: s ->  s a -> a E Retrieve the  entry of a  or   or retrieve  the result from a  or &.>The answer is computed in a manner that leaks space less than ala   )- and gives you back access to the outermost @ constructor more quickly, but may have worse constant factors.firstOf traverse [1..10]Just 1firstOf both (1,2)Just 1firstOf ignored ()Nothing E ::  s a -> s ->  a E ::  s a -> s ->  a E :: % s a -> s ->  a E ::   s a -> s ->  a E ::  s a -> s ->  a F Retrieve the  entry of a  or   or retrieve  the result from a  or &.>The answer is computed in a manner that leaks space less than ala   )- and gives you back access to the outermost @ constructor more quickly, but may have worse constant factors.lastOf traverse [1..10]Just 10lastOf both (1,2)Just 2lastOf ignored ()Nothing F ::  s a -> s ->  a F ::  s a -> s ->  a F :: % s a -> s ->  a F ::   s a -> s ->  a F ::  s a -> s ->  a GReturns  if this  or  ' has no targets in the given container.Note: G on a valid , & or  should always return . Y "a G  /This may be rather inefficient compared to the Y check of many containers.nullOf _1 (1,2)FalsenullOf ignored ()TruenullOf traverse []TruenullOf (element 20) [1..10]True G (  _1  ) :: (z f, z g) => f (g a, b) ->  G ::  s a -> s ->  G ::  s a -> s ->  G ::   s a -> s ->  G :: % s a -> s ->  G ::  s a -> s ->  HReturns  if this  or  ( has any targets in the given container.5A more "conversational" alias for this combinator is W.Note: H on a valid , & or  should always return . Y "a H  /This may be rather inefficient compared to the   Y check of many containers.notNullOf _1 (1,2)TruenotNullOf traverse [1..10]TruenotNullOf folded []FalsenotNullOf (element 20) [1..10]False H (  _1  ) :: (z f, z g) => f (g a, b) ->  H ::  s a -> s ->  H ::  s a -> s ->  H ::   s a -> s ->  H :: % s a -> s ->  H ::  s a -> s ->  I2Obtain the maximum element (if any) targeted by a  or   safely.Note: I on a valid , & or  will always return  a value.maximumOf traverse [1..10]Just 10maximumOf traverse []Nothing0maximumOf (folded.filtered even) [1,4,3,6,7,9,2]Just 6  "a  ( "empty")  I  bIn the interest of efficiency, This operation has semantics more strict than strictly necessary.   () l ), has lazier semantics but could leak memory. I :: v a =>  s a -> s ->  a I :: v a =>  s a -> s ->  a I :: v a =>   s a -> s ->  a I :: v a => % s a -> s ->  a I :: v a =>  s a -> s ->  a J2Obtain the minimum element (if any) targeted by a  or   safely.Note: J on a valid , & or  will always return  a value.minimumOf traverse [1..10]Just 1minimumOf traverse []Nothing0minimumOf (folded.filtered even) [1,4,3,6,7,9,2]Just 2  "a  ( "empty")  J  bIn the interest of efficiency, This operation has semantics more strict than strictly necessary.   () l ), has lazier semantics but could leak memory. J :: v a =>  s a -> s ->  a J :: v a =>  s a -> s ->  a J :: v a =>   s a -> s ->  a J :: v a => % s a -> s ->  a J :: v a =>  s a -> s ->  a K2Obtain the maximum element (if any) targeted by a ,  , &, , or  according to a user supplied .EmaximumByOf traverse (compare `on` length) ["mustard","relish","ham"]Just "mustard"`In the interest of efficiency, This operation has semantics more strict than strictly necessary.  cmp "a  ( "empty")  K  cmp K ::  s a -> (a -> a ->  ) -> s ->  a K ::  s a -> (a -> a ->  ) -> s ->  a K ::   s a -> (a -> a ->  ) -> s ->  a K :: % s a -> (a -> a ->  ) -> s ->  a K ::  s a -> (a -> a ->  ) -> s ->  a L2Obtain the minimum element (if any) targeted by a ,  , &,  or  according to a user supplied .`In the interest of efficiency, This operation has semantics more strict than strictly necessary.EminimumByOf traverse (compare `on` length) ["mustard","relish","ham"] Just "ham"  cmp "a  ( "empty")  L  cmp L ::  s a -> (a -> a ->  ) -> s ->  a L ::  s a -> (a -> a ->  ) -> s ->  a L ::   s a -> (a -> a ->  ) -> s ->  a L :: % s a -> (a -> a ->  ) -> s ->  a L ::  s a -> (a -> a ->  ) -> s ->  a MThe M function takes a & (or , , , or  n), a predicate and a structure and returns the leftmost element of the structure matching the predicate, or X if there is no such element.findOf each even (1,3,4,6)Just 4findOf folded even [1,3,5,7]Nothing M ::  s a -> (a ->  ) -> s ->  a M ::  s a -> (a ->  ) -> s ->  a M ::   s a -> (a ->  ) -> s ->  a M :: % s a -> (a ->  ) -> s ->  a M ::  s a -> (a ->  ) -> s ->  a   "a M  o l "a M l   8A simpler version that didn't permit indexing, would be: M ::  ( ( a)) s a -> (a ->  ) -> s ->  a M l p = + l (a y -> if p a then  a else y) X NThe N function takes a & (or , , , or  ), a monadic predicate and a structure and returns in the monad the leftmost element of the structure matching the predicate, or X if there is no such element.PfindMOf each ( \x -> print ("Checking " ++ show x) >> return (even x)) (1,3,4,6) "Checking 1" "Checking 3" "Checking 4"Just 4PfindMOf each ( \x -> print ("Checking " ++ show x) >> return (even x)) (1,3,5,7) "Checking 1" "Checking 3" "Checking 5" "Checking 7"Nothing N :: ( m,  s a) -> (a -> m  ) -> s -> m ( a) N :: ( m,  s a) -> (a -> m  ) -> s -> m ( a) N :: ( m,   s a) -> (a -> m  ) -> s -> m ( a) N :: ( m, % s a) -> (a -> m  ) -> s -> m ( a) N :: ( m,  s a) -> (a -> m  ) -> s -> m ( a)  N A :: (Monad m, Foldable f) => (a -> m Bool) -> f a -> m (Maybe a) p l "a N l   8A simpler version that didn't permit indexing, would be: N :: Monad m =>  ( (m ( a))) s a -> (a -> m  ) -> s -> m ( a) N l p = +* l (a y -> p a >>= x -> if x then return ( a) else y) $ return X O A variant of +\ that has no base case and thus may only be applied to lenses and structures such that the &. views at least one element of the structure.foldr1Of each (+) (1,2,3,4)10 O l f "a  f  - l  "a O  O :: $ s a -> (a -> a -> a) -> s -> a O :: & s a -> (a -> a -> a) -> s -> a O ::  & s a -> (a -> a -> a) -> s -> a O :: %% s a -> (a -> a -> a) -> s -> a O ::  s a -> (a -> a -> a) -> s -> a P A variant of ,\ that has no base case and thus may only be applied to lenses and structures such that the &- views at least one element of the structure.foldl1Of each (+) (1,2,3,4)10 P l f "a  f  - l  "a P  P :: $ s a -> (a -> a -> a) -> s -> a P :: & s a -> (a -> a -> a) -> s -> a P ::  & s a -> (a -> a -> a) -> s -> a P :: %% s a -> (a -> a -> a) -> s -> a P ::  s a -> (a -> a -> a) -> s -> a Q5Strictly fold right over the elements of a structure.  "a Q  Q :: ) s a -> (a -> r -> r) -> r -> s -> r Q :: + s a -> (a -> r -> r) -> r -> s -> r Q ::  + s a -> (a -> r -> r) -> r -> s -> r Q :: %* s a -> (a -> r -> r) -> r -> s -> r Q :: % s a -> (a -> r -> r) -> r -> s -> r RMFold over the elements of a structure, associating to the left, but strictly.  "a R  R :: ) s a -> (r -> a -> r) -> r -> s -> r R :: + s a -> (r -> a -> r) -> r -> s -> r R ::  + s a -> (r -> a -> r) -> r -> s -> r R :: %* s a -> (r -> a -> r) -> r -> s -> r R :: % s a -> (r -> a -> r) -> r -> s -> r S A variant of Q that has no base case and thus may only be applied to folds and structures such that the fold views at least one element of the structure. O l f "a  f  - l S :: $ s a -> (a -> a -> a) -> s -> a S :: & s a -> (a -> a -> a) -> s -> a S ::  & s a -> (a -> a -> a) -> s -> a S :: %% s a -> (a -> a -> a) -> s -> a S ::  s a -> (a -> a -> a) -> s -> a T A variant of R that has no base case and thus may only be applied to folds and structures such that the fold views at least one element of the structure. T l f "a  f  - l T :: $ s a -> (a -> a -> a) -> s -> a T :: & s a -> (a -> a -> a) -> s -> a T ::  & s a -> (a -> a -> a) -> s -> a T :: %% s a -> (a -> a -> a) -> s -> a T ::  s a -> (a -> a -> a) -> s -> a UbMonadic fold over the elements of a structure, associating to the right, i.e. from right to left.  "a U  U ::  m => - s a -> (a -> r -> m r) -> r -> s -> m r U ::  m => / s a -> (a -> r -> m r) -> r -> s -> m r U ::  m =>  / s a -> (a -> r -> m r) -> r -> s -> m r U ::  m => %. s a -> (a -> r -> m r) -> r -> s -> m r U ::  m => ) s a -> (a -> r -> m r) -> r -> s -> m r VaMonadic fold over the elements of a structure, associating to the left, i.e. from left to right.  "a V  V ::  m => - s a -> (r -> a -> m r) -> r -> s -> m r V ::  m => / s a -> (r -> a -> m r) -> r -> s -> m r V ::  m =>  / s a -> (r -> a -> m r) -> r -> s -> m r V ::  m => %. s a -> (r -> a -> m r) -> r -> s -> m r V ::  m => ) s a -> (r -> a -> m r) -> r -> s -> m r WCheck to see if this  or   matches 1 or more entries.has (element 0) []Falsehas _Left (Left 12)Truehas _Right (Left 12)FalseThis will always return  for a & or .has _1 ("hello","world")True W ::  s a -> s ->  W ::  s a -> s ->  W ::   s a -> s ->  W :: % s a -> s ->  W ::  s a -> s ->  XCheck to see if this  or   has no matches.hasn't _Left (Right 12)Truehasn't _Left (Left 12)FalseYThis converts a  to a 5 that returns the first element, if it exists, as a . Y ::  s a ->  s ( a) Y ::  s a ->  s ( a) Y ::  s a ->  s ( a) Y :: % s a ->  s ( a) Y ::   s a ->  s ( a) Y ::   s a ->  s ( a) ZThis converts an  to an @ that returns the first index and element, if they exist, as a . Z ::  i s a ->  s ( (i, a)) Z ::  i s a ->  s ( (i, a)) Z ::  i s a ->  s ( (i, a)) Z :: # i s a ->  s ( (i, a)) ['Retrieve the first value targeted by a  or   (or  the result from a  or & ). See also (C).    "a [  This is usually applied in the ]  (->) s. [ =   Y  [ ::  s a -> s ->  a [ ::  s a -> s ->  a [ :: % s a -> s ->  a [ ::   s a -> s ->  a [ ::  s a -> s ->  a OHowever, it may be useful to think of its full generality when working with a  transformer stack: [ :: U s m =>  s a -> m ( a) [ :: U s m =>  s a -> m ( a) [ :: U s m => % s a -> m ( a) [ :: U s m =>   s a -> m ( a) [ :: U s m =>  s a -> m ( a) \1Retrieve the first index and value targeted by a  or   (or  the result from a  or & ). See also (w). \ =   Z This is usually applied in the ]  (->) s. \ ::  i s a -> s ->  (i, a) \ ::  i s a -> s ->  (i, a) \ :: # i s a -> s ->  (i, a) \ ::  i s a -> s ->  (i, a) OHowever, it may be useful to think of its full generality when working with a  transformer stack: \ :: U s m =>  s a -> m ( (i, a)) \ :: U s m =>  s a -> m ( (i, a)) \ :: U s m => # s a -> m ( (i, a)) \ :: U s m =>  s a -> m ( (i, a)) ]5Retrieve a function of the first value targeted by a  or   (or  the result from a  or &).This is usually applied in the ]  (->) s.^@Retrieve a function of the first index and value targeted by an  or  (or  the result from an  or $). See also (w). ^ =   Z This is usually applied in the ]  (->) s. ^ :: $ 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 OHowever, it may be useful to think of its full generality when working with a  transformer stack: ^ :: U s m => " i s a -> (i -> a -> r) -> m ( r) ^ :: U s m => $ i s a -> (i -> a -> r) -> m ( r) ^ :: U s m => ## i s a -> (i -> a -> r) -> m ( r) ^ :: U s m =>  i s a -> (i -> a -> r) -> m ( r) _'Retrieve the first value targeted by a  or   (or  the result from a  or &) into the current state. _ =   Y _ ::  s m =>  s a -> m ( a) _ ::  s m =>  s a -> m ( a) _ ::  s m => % s a -> m ( a) _ ::  s m =>   s a -> m ( a) _ ::  s m =>  s a -> m ( a) `2Retrieve the first index and value targeted by an  or  (or  the index and result from an  or $) into the current state. ` =   Z ` ::  s m =>  i s a -> m ( (i, a)) ` ::  s m =>  i s a -> m ( (i, a)) ` ::  s m => # i s a -> m ( (i, a)) ` ::  s m =>  i s a -> m ( (i, a)) a5Retrieve a function of the first value targeted by a  or   (or  the result from a  or &) into the current state. a =   Y a ::  s m =>  s a -> (a -> r) -> m ( r) a ::  s m =>  s a -> (a -> r) -> m ( r) a ::  s m => % s a -> (a -> r) -> m ( r) a ::  s m =>   s a -> (a -> r) -> m ( r) a ::  s m =>  s a -> (a -> r) -> m ( r) b@Retrieve a function of the first index and value targeted by an  or  (or a function of  the index and result from an  or $) into the current state. b =   Z b ::  s m => " i s a -> (i -> a -> r) -> m ( r) b ::  s m => $ i s a -> (i -> a -> r) -> m ( r) b ::  s m => ## i s a -> (i -> a -> r) -> m ( r) b ::  s m =>  i s a -> (i -> a -> r) -> m ( r) cThis allows you to # the elements of a pretty much any $ construction in the opposite order.This will preserve indexes on 4 types and will give you the elements of a (finite)  or   in the opposite order."This has no practical impact on a , , & or .NB: To write back through an , you want to use '. Similarly, to write back through an  , you want to use .dFold an  or / by mapping indices and values to an arbitrary  with access to the i.-When you don't need access to the index then )% is more flexible in what it accepts. ) l "a d l   d :: & i s a -> (i -> a -> m) -> s -> m d ::  m => ( i s a -> (i -> a -> m) -> s -> m d :: #' i s a -> (i -> a -> m) -> s -> m d ::  m => " i s a -> (i -> a -> m) -> s -> m eJRight-associative fold of parts of a structure that are viewed through an  or  with access to the i.-When you don't need access to the index then +% is more flexible in what it accepts. + l "a e l   e :: 0 i s a -> (i -> a -> r -> r) -> r -> s -> r e :: 2 i s a -> (i -> a -> r -> r) -> r -> s -> r e :: #1 i s a -> (i -> a -> r -> r) -> r -> s -> r e :: , i s a -> (i -> a -> r -> r) -> r -> s -> r fMLeft-associative fold of the parts of a structure that are viewed through an  or  with access to the i.-When you don't need access to the index then ,% is more flexible in what it accepts. , l "a f l   f :: 0 i s a -> (i -> r -> a -> r) -> r -> s -> r f :: 2 i s a -> (i -> r -> a -> r) -> r -> s -> r f :: #1 i s a -> (i -> r -> a -> r) -> r -> s -> r f :: , i s a -> (i -> r -> a -> r) -> r -> s -> r g4Return whether or not any element viewed through an  or * satisfy a predicate, with access to the i.-When you don't need access to the index then 1% is more flexible in what it accepts. 1 l "a g l   g ::  i s a -> (i -> a ->  ) -> s ->  g ::  i s a -> (i -> a ->  ) -> s ->  g :: # i s a -> (i -> a ->  ) -> s ->  g ::  i s a -> (i -> a ->  ) -> s ->  h5Return whether or not all elements viewed through an  or * satisfy a predicate, with access to the i.-When you don't need access to the index then 2% is more flexible in what it accepts. 2 l "a h l   h ::  i s a -> (i -> a ->  ) -> s ->  h ::  i s a -> (i -> a ->  ) -> s ->  h :: # i s a -> (i -> a ->  ) -> s ->  h ::  i s a -> (i -> a ->  ) -> s ->  i=Return whether or not none of the elements viewed through an  or * satisfy a predicate, with access to the i.-When you don't need access to the index then 3% is more flexible in what it accepts. 3 l "a i l   i ::  i s a -> (i -> a ->  ) -> s ->  i ::  i s a -> (i -> a ->  ) -> s ->  i :: # i s a -> (i -> a ->  ) -> s ->  i ::  i s a -> (i -> a ->  ) -> s ->  jTraverse the targets of an  or  with access to the i, discarding the results.-When you don't need access to the index then 6% is more flexible in what it accepts. 6 l "a  l   j ::  f => + i s a -> (i -> a -> f r) -> s -> f () j :: ( f => - i s a -> (i -> a -> f r) -> s -> f () j ::  f => #, i s a -> (i -> a -> f r) -> s -> f () j :: ( f => ' i s a -> (i -> a -> f r) -> s -> f () kTraverse the targets of an  or P with access to the index, discarding the results (with the arguments flipped). k "a   j -When you don't need access to the index then 7% is more flexible in what it accepts. 7 l a "a k l a   k ::  f => + i s a -> s -> (i -> a -> f r) -> f () k :: ( f => - i s a -> s -> (i -> a -> f r) -> f () k ::  f => #, i s a -> s -> (i -> a -> f r) -> f () k :: ( f => ' i s a -> s -> (i -> a -> f r) -> f () l*Run monadic actions for each target of an  or 3 with access to the index, discarding the results.-When you don't need access to the index then 9% is more flexible in what it accepts. 9 l "a  l   l ::  m => + i s a -> (i -> a -> m r) -> s -> m () l ::  m => - i s a -> (i -> a -> m r) -> s -> m () l ::  m => #, i s a -> (i -> a -> m r) -> s -> m () l ::  m => ' i s a -> (i -> a -> m r) -> s -> m () m*Run monadic actions for each target of an  or P with access to the index, discarding the results (with the arguments flipped). m "a   l -When you don't need access to the index then :% is more flexible in what it accepts. : l a "a  l a   m ::  m => + i s a -> s -> (i -> a -> m r) -> m () m ::  m => - i s a -> s -> (i -> a -> m r) -> m () m ::  m => #, i s a -> s -> (i -> a -> m r) -> m () m ::  m => ' i s a -> s -> (i -> a -> m r) -> m () n<Concatenate the results of a function of the elements of an  or  with access to the index.-When you don't need access to the index then @& is more flexible in what it accepts. @ l "a n l   n "a d n :: * i s a -> (i -> a -> [r]) -> s -> [r] n :: , i s a -> (i -> a -> [r]) -> s -> [r] n :: #+ i s a -> (i -> a -> [r]) -> s -> [r] n :: & i s a -> (i -> a -> [r]) -> s -> [r] oThe o function takes an  or , a predicate that is also supplied the index, a structure and returns the left-most element of the structure matching the predicate, or X if there is no such element.-When you don't need access to the index then M% is more flexible in what it accepts. M l "a o l   o ::  i s a -> (i -> a ->  ) -> s ->  a o ::  i s a -> (i -> a ->  ) -> s ->  a o :: # i s a -> (i -> a ->  ) -> s ->  a o ::  i s a -> (i -> a ->  ) -> s ->  a pThe p function takes an  or , a monadic predicate that is also supplied the index, a structure and returns in the monad the left-most element of the structure matching the predicate, or X if there is no such element.-When you don't need access to the index then N% is more flexible in what it accepts. N l "a p l   p ::  m =>  i s a -> (i -> a -> m  ) -> s -> m ( a) p ::  m =>  i s a -> (i -> a -> m  ) -> s -> m ( a) p ::  m => # i s a -> (i -> a -> m  ) -> s -> m ( a) p ::  m =>  i s a -> (i -> a -> m  ) -> s -> m ( a) qStrictly; fold right over the elements of a structure with an index.-When you don't need access to the index then Q% is more flexible in what it accepts. Q l "a q l   q :: 0 i s a -> (i -> a -> r -> r) -> r -> s -> r q :: 2 i s a -> (i -> a -> r -> r) -> r -> s -> r q :: #1 i s a -> (i -> a -> r -> r) -> r -> s -> r q :: , i s a -> (i -> a -> r -> r) -> r -> s -> r 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 R% is more flexible in what it accepts. R l "a r l   r :: 2 i s a -> (i -> r -> a -> r) -> r -> s -> r r :: 4 i s a -> (i -> r -> a -> r) -> r -> s -> r r :: #3 i s a -> (i -> r -> a -> r) -> r -> s -> r r :: . i s a -> (i -> r -> a -> r) -> r -> s -> r sBMonadic fold right over the elements of a structure with an index.-When you don't need access to the index then U% is more flexible in what it accepts. U l "a s l   s ::  m => 4 i s a -> (i -> a -> r -> m r) -> r -> s -> m r s ::  m => 6 i s a -> (i -> a -> r -> m r) -> r -> s -> m r s ::  m => #5 i s a -> (i -> a -> r -> m r) -> r -> s -> m r s ::  m => 0 i s a -> (i -> a -> r -> m r) -> r -> s -> m r tUMonadic fold over the elements of a structure with an index, associating to the left.-When you don't need access to the index then V% is more flexible in what it accepts. V l "a t l   t ::  m => 4 i s a -> (i -> r -> a -> m r) -> r -> s -> m r t ::  m => 6 i s a -> (i -> r -> a -> m r) -> r -> s -> m r t ::  m => #5 i s a -> (i -> r -> a -> m r) -> r -> s -> m r t ::  m => 0 i s a -> (i -> r -> a -> m r) -> r -> s -> m r u-Extract the key-value pairs from a structure.>When you don't need access to the indices in the result, then -% is more flexible in what it accepts. - l "a    u l u ::  i s a -> s -> [(i,a)] u ::  i s a -> s -> [(i,a)] u :: # i s a -> s -> [(i,a)] u ::  i s a -> s -> [(i,a)] vAn infix version of u.wPerform a safe  (with index) of an  or  or retrieve  the index and result from an  or $. When using a  as a partial $, or an  as a partial = this can be a convenient way to extract the optional value. (w ) :: s ->  i s a ->  (i, a) (w ) :: s ->  i s a ->  (i, a) (w ) :: s -> # i s a ->  (i, a) (w ) :: s ->  i s a ->  (i, a) xPerform an *UNSAFE*  (with index) of an  or  assuming that it is there. (x ) :: s ->  i s a -> (i, a) (x ) :: s ->  i s a -> (i, a) (x ) :: s -> # i s a -> (i, a) (x ) :: s ->  i s a -> (i, a) y4Retrieve the index of the first value targeted by a  or ! which is equal to a given value.  "a y  y :: y a =>  i s a -> a -> s ->  i y :: y a =>  i s a -> a -> s ->  i z1Retrieve the indices of the values targeted by a  or " which are equal to a given value.  "a z  z :: y a =>  i s a -> a -> s -> [i] z :: y a =>  i s a -> a -> s -> [i] {4Retrieve the index of the first value targeted by a  or  which satisfies a predicate.  "a {  { ::  i s a -> (a ->  ) -> s ->  i { ::  i s a -> (a ->  ) -> s ->  i |1Retrieve the indices of the values targeted by a  or  which satisfy a predicate.  "a |  | ::  i s a -> (a -> ) -> s -> [i] | ::  i s a -> (a -> ) -> s -> [i] } Filter an  or , obtaining an .4[0,0,0,5,5,5]^..traversed.ifiltered (\i a -> i <= a) [0,5,5,5] Compose with $ to filter another $,  IndexedIso, ,  (or /) with access to both the value and the index.Note: As with $ , this is not a legal L, unless you are very careful not to invalidate the predicate on the target!~ Obtain an " by taking elements from another , $,  or  while a predicate holds. ~ :: (i -> a -> ) ->  i s a ->  i s a ~ :: (i -> a -> ) ->  i s a ->  i s a ~ :: (i -> a -> ) -> # i s a ->  i s a ~ :: (i -> a -> ) ->  i s a ->  i s a  Obtain an # by dropping elements from another , $,  or  while a predicate holds.  :: (i -> a -> ) ->  i s a ->  i s a  :: (i -> a -> ) ->  i s a ->  i s a -- see notes  :: (i -> a -> ) -> # i s a ->  i s a -- see notes  :: (i -> a -> ) ->  i s a ->  i s a  Applying  to an $ or - will still allow you to use it as a pseudo-R, but if you change the value of the targets to ones where the predicate returns , then you will break the   laws and   fusion will no longer be sound.Fold a value using a specified  and  operations. This is like  where the z% instance can be manually specified.   "a    :: ) s a -> (a -> a -> a) -> a -> s -> a  :: + s a -> (a -> a -> a) -> a -> s -> a  :: %* s a -> (a -> a -> a) -> a -> s -> a  :: % s a -> (a -> a -> a) -> a -> s -> a  ::  + s a -> (a -> a -> a) -> a -> s -> a 'foldByOf both (++) [] ("hello","world") "helloworld"Fold a value using a specified  and  operations. This is like  where the z% instance can be manually specified.   "a    :: 5 s a -> (r -> r -> r) -> r -> (a -> r) -> s -> r  :: 7 s a -> (r -> r -> r) -> r -> (a -> r) -> s -> r  :: 1 s a -> (r -> r -> r) -> r -> (a -> r) -> s -> r  :: %6 s a -> (r -> r -> r) -> r -> (a -> r) -> s -> r  ::  7 s a -> (r -> r -> r) -> r -> (a -> r) -> s -> r /foldMapByOf both (+) 0 length ("hello","world")10l| !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~q !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~q.CDYZ[]\^_a`bWX"#$c !%&'()*+,-123/0456789:;<=@A>?BGHEFIJKLMNQROPSTUVvwxdefghijklmnopqrstuyz{|}~l| !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~.CDvwx(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional Rank2Types Trustworthy !"23468HMCAllows # 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  f =  ( f) :When you see this as an argument to a function, it expectsto be indexed if p is an instance of  i,to be unindexed if p is (->),a   if f is (,a  if f is only a  and  Contravariant,a & if p is only a ,a  if f is ,  Contravariant and (. type  =  ( i)  type  =  ( i) >When you see this as an argument to a function, it expects an .>When you see this as an argument to a function, it expects an . type  =   =When you see this as an argument to a function, it expects a . type  =   =When you see this as an argument to a function, it expects a  ..Map each element of a structure targeted by a & or  F, evaluate these actions from left to right, and collect the results.0This function is only provided for consistency,  is strictly more general.traverseOf each print (1,2,3)123 ((),(),())  "a   l "a  l     itraversed "a  itraverse This yields the obvious law:  "a    ::  f => ) 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  A version of ' with the arguments flipped, such that:forOf each (1,2,3) print123 ((),(),())0This function is only provided for consistency,  is strictly more general.  "a   "a  .    "a    l s "a  l s    ::  f => # s t a b -> s -> (a -> f b) -> f t  ::  f => &# s t a b -> s -> (a -> f b) -> f t  :: ( f =>  # s t a b -> s -> (a -> f b) -> f t SEvaluate each action in the structure from left to right, and collect the results.sequenceAOf both ([1,2],[3,4])[(1,3),(1,4),(2,3),(2,4)]  "a   "a    l "a  l  "a l   ::  f =>  s t (f b) b -> s -> f t  ::  f => & s t (f b) b -> s -> f t  :: ( f =>   s t (f b) b -> s -> f t .Map each element of a structure targeted by a &Z to a monadic action, evaluate these actions from left to right, and collect the results.$mapMOf both (\x -> [x, x + 1]) (1,3)[(1,3),(1,4),(2,3),(2,4)]  "a    l "a  l    ::  m => ) s t a b -> (a -> m b) -> s -> m t  ::  m => &( 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 .$forMOf both (1,3) $ \x -> [x, x + 1][(1,3),(1,4),(2,3),(2,4)]  "a    l "a  ( l)  l s "a  l s    ::  m => ) s t a b -> s -> (a -> m b) -> m t  ::  m => &( s t a b -> s -> (a -> m b) -> m t  ::  m =>  # s t a b -> s -> (a -> m b) -> m t -Sequence the (monadic) effects targeted by a &# in a container from left to right.#sequenceOf each ([1,2],[3,4],[5,6])A[(1,3,5),(1,3,6),(1,4,5),(1,4,6),(2,3,5),(2,3,6),(2,4,5),(2,4,6)]  "a    l "a  l   l "a   l   ::  m =>  s t (m b) b -> s -> m t  ::  m => & s t (m b) b -> s -> m t  ::  m =>   s t (m b) b -> s -> m t This generalizes  to an arbitrary  .Note: E handles ragged inputs more intelligently, but for non-ragged inputs:&transposeOf traverse [[1,2,3],[4,5,6]][[1,4],[2,5],[3,6]]  "a    Since every & is a  9, we can use this as a form of monadic strength as well:   :: (b, [a]) -> [(b, a)] This generalizes  to an arbitrary  .  "a    accumulates _ from right to left.  :: A 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)  ::  ( (_A acc)) s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t) This generalizes  to an arbitrary  .  "a    accumulates _ from left to right.  :: A 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)  ::  (_@ acc) s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)  l f acc0 s =  ( (l (a ->  (acc ->  (f acc a))) s) acc0) This permits the use of  over an arbitrary   or &.  "a    :: * 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  over an arbitrary   or &.  "a    :: * 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   allows you to  the individual stores in a .This  allows you to  the individual stores in a  with access to their indices. turns a   into a &( that resembles an early version of the   (or  ) type.Note:W You should really try to maintain the invariant of the number of children in the list.!(a,b,c) & partsOf each .~ [x,y,z](x,y,z)oAny extras will be lost. If you do not supply enough, then the remainder will come from the original structure.#(a,b,c) & partsOf each .~ [w,x,y,z](w,x,y)(a,b,c) & partsOf each .~ [x,y](x,y,c)+('b', 'a', 'd', 'c') & partsOf each %~ sort('a','b','c','d')So technically, this is only a &7 if you do not change the number of results it returns.When applied to a  the result is merely a .  ::   s a -> % s [a]  :: % s a -> % s [a]  ::  s a -> % s [a]  ::  s a ->  s [a]  ::  s a ->  s [a] An indexed version of 7 that receives the entire list of indices as its index.A type-restricted version of  that can only be used with a  .A type-restricted version of  that can only be used with an . turns a   into a   (or   ) family. If you do not need the types of s and t2 to be different, it is recommended that you use .+It is generally safer to traverse with the G rather than use this 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!When applied to a  the result is merely a  (and becomes safe).  ::  s t a b -> & s t [a] [b]  :: & s t a b -> & s t [a] [b]  ::   s t a b -> & s t [a] [b]  ::  s a ->  s [a]  ::  s a ->  s [a] An indexed version of 7 that receives the entire list of indices as its index.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  to see the values, F at what the structure would be like with an edited result, or simply  the original structure. "propChildren l x = childrenOf l x    ( l x) propId l x =  ( x) [ w | w <-  l x]  ::   s a -> s -> [ (->) a s]  :: % s a -> s -> [ (->) a s]  ::  s a -> s -> [ (->) a s]  :: # i s a -> s -> [ ( i) a s]  ::  i s a -> s -> [ ( i) a s] This converts a  7 that you "know" will target one or more elements to a &0. It can also be used to transform a non-empty  into a .The resulting & or ! will be partial if the supplied   returns no results.[1,2,3] ^. singular _head1[] ^. singular _head(*** Exception: singular: empty traversalLeft 4 ^. singular _Left4[1..10] ^. singular (ix 7)8[] & singular traverse .~ 0[]  ::   s t a a -> & s t a a  ::  s a ->  s a  ::  i s t a a -> $ i s t a a  ::  i s a ->  i s a This converts a  3 that you "know" will target only one element to a &&. It can also be used to transform a  into a .The resulting & or  will be partial if the  + targets nothing or more than one element.![] & unsafeSingular traverse .~ 0.*** Exception: unsafeSingular: empty traversal  ::   s t a b -> & s t a b  ::  s a ->  s a  ::  i s t a b -> $ i s t a b  ::  i s a ->  i s a Traverse both parts of a  container with matching types.!Usually that type will be a pair.(1,2) & both *~ 10(10,20)"over both length ("hello","world")(5,5)("hello","world")^.both "helloworld"  ::   (a, a) (b, b) a b  ::   ( a a) ( b b) a b Apply a different   or  to each side of a  container.  ::   s t a b ->   s' t' a b ->   (r s s') (r t t') a b  ::  i s t a b ->  i s' t' a b ->  i (r s s') (r t t') a b  ::  s t a b ->  s' t' a b ->  (r s s') (r t t') a b   ::   s t a b ->   s' t' a b ->   (s,s') (t,t') a b  :: & s t a b -> &" s' t' a b ->   (s,s') (t,t') a b  ::  s a -> " s' a ->  (s,s') a  ::  s a ->  s' a ->  (s,s') a   ::  i s t a b ->  i s' t' a b ->  i (s,s') (t,t') a b  :: $ i s t a b -> $ i s' t' a b ->  i (s,s') (t,t') a b  ::  i s a ->  i s' a ->  i (s,s') a  ::  i s a ->  i s' a ->  i (s,s') a   ::  s t a b ->  s' t' a b ->  (s,s') (t,t') a b  :: " s t a b -> " s' t' a b ->  (s,s') (t,t') a b  ::  s a ->  s' a ->  (s,s') a  ::  s a ->  s' a ->  (s,s') a .("hello",["world","!!!"])^..beside id traverse["hello","world","!!!"]Visit the first n targets of a  , ,  or &.=[("hello","world"),("!!!","!!!")]^.. taking 2 (traverse.both)["hello","world"]'timingOut $ [1..] ^.. taking 3 traverse[1,2,3]+over (taking 5 traverse) succ "hello world" "ifmmp world"  :: 6 ->  s a ->  s a  :: 6 -> % s a ->  s a  :: 6 ->   s a ->  s a  :: 6 ->   s a ->  s a  :: 6 ->  s a ->  s a  :: 6 ->  s a ->  s a  :: 6 ->  i s a ->  i s a  :: 6 -> # i s a ->  i s a  :: 6 ->  i s a ->  i s a  :: 6 ->  i s a ->  i s a Visit all but the first n targets of a  , ,  or &.$("hello","world") ^? dropping 1 both Just "world".Dropping works on infinite traversals as well:[1..] ^? dropping 1 foldedJust 2  :: 6 ->  s a ->  s a  :: 6 -> % s a ->  s a  :: 6 ->   s a ->  s a  :: 6 ->   s a ->  s a  :: 6 ->  s a ->  s a  :: 6 ->  s a ->  s a  :: 6 ->  i s a ->  i s a  :: 6 -> # i s a ->  i s a  :: 6 ->  i s a ->  i s a  :: 6 ->  i s a ->  i s a A  2 is completely characterized by its behavior on a . Cloning a  G is one way to make sure you aren't given something weaker, such as a T and can be 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 use  and  than to [. The former can execute at full speed, while the latter needs to round trip through the .Plet foo l a = (view (getting (cloneTraversal l)) a, set (cloneTraversal l) 10 a)foo both ("hello","world")("helloworld",(10,10))  ::  ( (->) a b) s t a b ->   s t a b Clone a   yielding an 9 that passes through whatever index it is composed with. Clone an  yielding an  with the same index.A 2 is completely characterized by its behavior on a .Clone a  yielding an 9 that passes through whatever index it is composed with. Clone an  yielding an  with the same index.Traversal with an index.NB:F When you don't need access to the index then you can just apply your  directly as a function!  "a   l =  l   =   ::  f => $0 i s t a b -> (i -> a -> f b) -> s -> f t  :: ( f => + i s t a b -> (i -> a -> f b) -> s -> f t  :: Apply f => * 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     ::  f => $0 i s t a b -> s -> (i -> a -> f b) -> f t  :: ( f => + i s t a b -> s -> (i -> a -> f b) -> f t  :: Apply f => * i s t a b -> s -> (i -> a -> f b) -> f t .Map each element of a structure targeted by a &u to a monadic action, evaluate these actions from left to right, and collect the results, with access its position.(When you don't need access to the index ' is more liberal in what it can accept.  l "a  l    ::  m => $0 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  :: Bind m => * i s t a b -> (i -> a -> m b) -> s -> m t .Map each element of a structure targeted by a & to a monadic action, 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    :: $G i s t a b -> (i -> acc -> a -> (acc, b)) -> acc -> s -> (acc, t)  :: B i s t a b -> (i -> acc -> a -> (acc, b)) -> acc -> s -> (acc, t)  Generalizes  to an arbitrary  with access to the index.& accumulates state from left to right.  l "a  l    :: $G i s t a b -> (i -> acc -> a -> (acc, b)) -> acc -> s -> (acc, t)  :: B i s t a b -> (i -> acc -> a -> (acc, b)) -> acc -> s -> (acc, t)  Traverse any  container. This is an % that is indexed by ordinal position. Traverse any  container. This is an % that is indexed by ordinal position. Traverse any  container. This is an % that is indexed by ordinal position.This is the trivial empty  .  ::  i s s a b   "a   6 & ignored %~ absurd6 Traverse the nth  a  , & or  if it exists.2[[1],[3,4]] & elementOf (traverse.traverse) 1 .~ 5 [[1],[5,4]]*[[1],[3,4]] ^? elementOf (folded.folded) 1Just 3*timingOut $ ['a'..] ^?! elementOf folded 5'f'8timingOut $ take 10 $ elementOf traverse 3 .~ 16 $ [0..][0,1,2,16,4,5,6,7,8,9]  ::  s a -> 6 ->  6 s a  ::  s a -> 6 ->  6 s a  Traverse the nth element of a  container.  "a   *Traverse (or fold) selected elements of a   (or 2) where their ordinal positions match a predicate.  ::  s a -> (6 -> ) ->  6 s a  ::  s a -> (6 -> ) ->  6 s a Traverse elements of a ; container where their ordinal positions match a predicate.  "a    Try to map a function over this  , failing if the   has no targets..failover (element 3) (*2) [1,2] :: Maybe [Int]Nothing7failover _Left (*2) (Right 4) :: Maybe (Either Int Int)Nothing8failover _Right (*2) (Right 4) :: Maybe (Either Int Int)Just (Right 8) ? :: Alternative m => Traversal s t a b -> (a -> b) -> s -> m t 5Try to map a function which uses the index over this , failing if the  has no targets. M :: Alternative m => IndexedTraversal i s t a b -> (i -> a -> b) -> s -> m t Try the first   (or ), falling back on the second   (or ) if it returns no entries.This is only a valid   if the second   is disjoint from the result of the first or returns exactly the same results. These conditions are trivially met when given a &, , ,  6 or "affine" Traversal -- one that has 0 or 1 target.Mutatis mutandis for ."[0,1,2,3] ^? failing (ix 1) (ix 2)Just 1#[0,1,2,3] ^? failing (ix 42) (ix 2)Just 2  ::   s t a b ->   s t a b ->   s t a b  ::   s t a b ->   s t a b ->   s t a b  ::  s a ->  s a ->  s a fThese cases are also supported, trivially, but are boring, because the left hand side always succeeds.  :: & s t a b ->   s t a b ->   s t a b  ::  s t a b ->   s t a b ->   s t a b  ::  s t a b ->   s t a b ->   s t a b  ::  s a ->  s a ->  s a If both of the inputs are indexed, the result is also indexed, so you can apply this to a pair of indexed traversals or indexed folds, obtaining an indexed traversal or indexed fold.  ::  i s t a b ->  i s t a b ->  i s t a b  ::  i s a ->  i s a ->  i s a fThese cases are also supported, trivially, but are boring, because the left hand side always succeeds.  :: $ i s t a b ->  i s t a b ->  i s t a b  ::  i s a ->  i s a ->  i s a uTry the second traversal. If it returns no entries, try again with all entries from the first traversal, recursively.  ::  s s ->  s a ->  s a  ::  s s ->  s a ->  s a  ::   s t s t ->   s t a b ->   s t a b  ::  s s ->  i s a ->  i s a  ::   s t s t ->  i s t a b ->  i s t a b Fuse a   by reassociating all of the \<*\>/ operations to the left and fusing all of the 9B calls into one. This is particularly useful when constructing a  $ using operations from GHC.Generics.Given a pair of  s foo and bar,  (foo.bar) = foo.bar  However, foo and bar are each going to use the ( they are given. exploits the ' lemma to merge their separate uses of 9 into a single 9M. and it further exploits an interesting property of the right Kan lift (or *) to left associate all of the uses of '( *3)' to make it possible to fuse together more fmaps.:This is particularly effective when the choice of functor f) is unknown at compile time or when the   foo.barN in the above description is recursive or complex enough to prevent inlining.< is a version of this combinator suitable for fusing lenses.  ::   s t a b ->   s t a b 'Traverse a container using a specified (. This is like  where the " instance can be specified by any    "a  'Sequence a container using a specified (. This is like  where the " instance can be specified by any    "a  S] ] Q(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional Rank2Types Trustworthy !"123468HM)A  with an additional index.2An instance must satisfy a (modified) form of the  laws:  (  ) "a   9 ( f)   g "a    (\i ->   9 (f i)  g i) Traverse an indexed container.  "a   The  of a  container.;A container that supports folding with an additional index.2Fold a container by mapping value to an arbitrary  with access to the index i.-When you don't need access to the index then % is more flexible in what it accepts.  "a    The  of a  container.   is a fold over the keys of a .@Data.Map.fromList [(2, "hello"), (1, "world")]^..ifolded.asIndex[1,2]HRight-associative fold of an indexed container with access to the index i.-When you don't need access to the index then {% is more flexible in what it accepts. { "a    GLeft-associative fold of an indexed container with access to the index i.-When you don't need access to the index then % is more flexible in what it accepts.  "a    StrictlyF fold right over the elements of a structure with access to the index i.-When you don't need access to the index then % is more flexible in what it accepts.  "a    RFold over the elements of a structure with an index, associating to the left, but strictly.-When you don't need access to the index then R% is more flexible in what it accepts. R l "a r l   A  with an additional index..Instances must satisfy a modified form of the  laws:  f   g "a  (\i -> f i  g i)  (\_ a -> a) "a  Map with access to the index.The  for a .,If you don't need access to the index, then -% is more flexible in what it accepts. Compose an & function with a non-indexed function.Mnemonically, the <, points to the indexing we want to preserve.let nestedMap = (fmap Map.fromList . Map.fromList) [(1, [(10, "one,ten"), (20, "one,twenty")]), (2, [(30, "two,thirty"), (40,"two,forty")])].nestedMap^..(itraversed<.itraversed).withIndexA[(1,"one,ten"),(1,"one,twenty"),(2,"two,thirty"),(2,"two,forty")]'Compose a non-indexed function with an  function.Mnemonically, the >, points to the indexing we want to preserve.This is the same as ().f  g (and f  g) gives you the index of g unless g is index-preserving, like a  ,  or 0, in which case it'll pass through the index of f.let nestedMap = (fmap Map.fromList . Map.fromList) [(1, [(10, "one,ten"), (20, "one,twenty")]), (2, [(30, "two,thirty"), (40,"two,forty")])].nestedMap^..(itraversed.>itraversed).withIndexE[(10,"one,ten"),(20,"one,twenty"),(30,"two,thirty"),(40,"two,forty")]OUse a value itself as its own index. This is essentially an indexed version of .VNote: When used to modify the value, this can break the index requirements assumed by + and similar, so this is only properly an , but it can be used as more.  :: a a b Remap the index.Composition of  functions.Mnemonically, the < and >9 points to the fact that we want to preserve the indices.let nestedMap = (fmap Map.fromList . Map.fromList) [(1, [(10, "one,ten"), (20, "one,twenty")]), (2, [(30, "two,thirty"), (40,"two,forty")])]/nestedMap^..(itraversed<.>itraversed).withIndexU[((1,10),"one,ten"),((1,20),"one,twenty"),((2,30),"two,thirty"),((2,40),"two,forty")]Composition of ? functions with a user supplied function for combining indices.This allows you to filter an , ,  or $& based on a predicate on the indices.6["hello","the","world","!!!"]^..traversed.indices even["hello","world"]Mover (traversed.indices (>0)) Prelude.reverse $ ["He","was","stressed","o_O"]["He","saw","desserts","O_o"]This allows you to filter an , ,  or $ based on an index.0["hello","the","world","!!!"]^?traversed.index 2 Just "world"aReturn whether or not any element in a container satisfies a predicate, with access to the index i.-When you don't need access to the index then % is more flexible in what it accepts.  "a    `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    hReturn whether or not none of the 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     f "a    f FDetermines whether no elements of the structure satisfy the predicate.  f "a    f +Traverse elements with access to the index i, discarding the results.-When you don't need access to the index then % is more flexible in what it accepts.  l =    +Traverse elements with access to the index i6, discarding the results (with the arguments flipped).  "a   -When you don't need access to the index then % is more flexible in what it accepts.  a "a  a   *Run monadic actions for each target of an  or e3 with access to the index, discarding the results.-When you don't need access to the index then 9% is more flexible in what it accepts.  "a    *Run monadic actions for each target of an  or eP 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   gConcatenate 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  Searches a container with a predicate that is also supplied the index, returning the left-most element of the structure matching the predicate, or X if there is no such element.-When you don't need access to the index then % is more flexible in what it accepts.  "a    BMonadic 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    UMonadic fold over the elements of a structure with an index, associating to the left.-When you don't need access to the index then % is more flexible in what it accepts.  "a    -Extract the key-value pairs from a structure.>When you don't need access to the indices in the result, then % is more flexible in what it accepts.  "a     3Traverse with an index (and the arguments flipped). for a "a  a    "a   Map each element of a structure to a monadic action, 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    Map each element of a structure to a monadic action, evaluate these actions from left to right, and collect the results, with access its position (and the arguments flipped). forM a "a  a    "a    Generalizes  to add access to the index.& accumulates state from right to left.  "a     Generalizes  to add access to the index.& accumulates state from left to right.  "a    The position in the  is available as the index.3The position in the list is available as the index.n      !"#$%&'()77d      !"#$%&'()   (C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional Rank2Types Safe-Inferred3HMThis provides a breadth-first   of the individual  of any other  d via iterative deepening depth-first search. The levels are returned to you in a compressed format."This can permit us to extract the  directly:.["hello","world"]^..levels (traverse.traverse)[Zero,Zero,One () 'h',Two 0 (One () 'e') (One () 'w'),Two 0 (One () 'l') (One () 'o'),Two 0 (One () 'l') (One () 'r'),Two 0 (One () 'o') (One () 'l'),One () 'd']&But we can also traverse them in turn:7["hello","world"]^..levels (traverse.traverse).traverse "hewlolrold"=We can use this to traverse to a fixed depth in the tree of (*) used in the  :M["hello","world"] & taking 4 (levels (traverse.traverse)).traverse %~ toUpper["HEllo","World"]'Or we can use it to traverse the first n elements in found in that  3 regardless of the depth at which they were found.M["hello","world"] & taking 4 (levels (traverse.traverse).traverse) %~ toUpper["HELlo","World"]The resulting   of the ' which is indexed by the depth of each {.7["dog","cat"]^@..levels (traverse.traverse) <. traverse1[(2,'d'),(3,'o'),(3,'c'),(4,'g'),(4,'a'),(5,'t')]Note:4 Internally this is implemented by using an illegal (<, as it extracts information in an order that violates the ( laws.This provides a breadth-first  ' of the individual levels of any other  d via iterative deepening depth-first search. The levels are returned to you in a compressed format.This is similar to (, but retains the index of the original <, so you can access it when traversing the levels later on.;["dog","cat"]^@..ilevels (traversed<.>traversed).itraversedI[((0,0),'d'),((0,1),'o'),((1,0),'c'),((0,2),'g'),((1,1),'a'),((1,2),'t')]The resulting  5 of the levels which is indexed by the depth of each {.=["dog","cat"]^@..ilevels (traversed<.>traversed)<.>itraverseda[((2,(0,0)),'d'),((3,(0,1)),'o'),((3,(1,0)),'c'),((4,(0,2)),'g'),((4,(1,1)),'a'),((5,(1,2)),'t')]Note:4 Internally this is implemented by using an illegal (<, as it extracts information in an order that violates the ( laws.+,-./{{+,-./(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional Rank2Types Safe-Inferred 246=HKM type  =   Reify a  + so it can be stored safely in a container. type  =    Reify an + so it can be stored safely in a container. type  i =  ( i)  Reify an + so it can be stored safely in a container. type  =   Reify a + so it can be stored safely in a container. Reify a + so it can be stored safely in a container.;This can also be useful for creatively combining folds as   s is isomorphic to  ReaderT s []! and provides similar instances.;("hello","world")^..runFold ((,) <$> Fold _2 <*> Fold both)%[("world","hello"),("world","world")]  Reify an + so it can be stored safely in a container.Reify a + so it can be stored safely in a container.BThis can also be useful when combining getters in novel ways, as 8 is isomorphic to '(->)' and provides similar instances.P("hello","world","!!!")^.runGetter ((,) <$> Getter _2 <*> Getter (_1.to length)) ("world",5) type  =    A form of  3 that can be stored monomorphically in a container. type  i =  ( i)  Reify an + so it can be stored safely in a container. type  i =  ( i)  Reify an $+ so it can be stored safely in a container. type  =   Reify a &+ so it can be stored safely in a container.h      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\],      !h !]\[ZYXWVUTSRQPONMLKJIHGF  EDCBA@   ?>=<;:9876543210/.-,+*)('&%$#"P      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\] 7(C) 2012-2015 Edward Kmett, (C) 2006-2012 Neil Mitchell BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental Rank2Types Trustworthy !"+3:;FHM ^KA generic applicative transformation that maps over the immediate subterms.^ is to  what 0 is to This really belongs in  Data.Data._Nave   using 12. This does not attempt to optimize the traversal.YThis is primarily useful when the children are immediately obvious, and for benchmarking.`&Find every occurrence of a given type aE recursively that doesn't require passing through something of type a using 1I, while avoiding traversal of areas that cannot contain a value of type a.This is a with a more liberal signature.aFind descendants of type a[ non-transitively, while avoiding computation of areas that cannot contain values of type a using 1.a$ is a useful default definition for !bb performs like `, except when s ~ a%, it returns itself and nothing else.c This automatically constructs a  from an function.(2,4) & upon fst *~ 5(10,4)<There are however, caveats on how this function can be used!First, the user supplied function must access only one field of the specified type. That is to say the target must be a single element that would be visited by  holesOnOf ` aBNote: this even permits a number of functions to be used directly.[1,2,3,4] & upon head .~ 0 [0,2,3,4][1,2,3,4] & upon last .~ 5 [1,2,3,5][1,2,3,4] ^? upon tail Just [2,3,4]"" ^? upon tailNothing6Accessing parents on the way down to children is okay:'[1,2,3,4] & upon (tail.tail) .~ [10,20] [1,2,10,20]iSecond, the structure must not contain strict or unboxed fields of the same type that will be visited by 1 c :: (1 s, 1 a) => (s -> a) ->  [Int] s adThe design of f5 doesn't allow it to search inside of values of type a for other values of type a. d$ provides this additional recursion.Like f, d- trusts the user supplied function more than cM using it directly as the accessor. This enables reading from the resulting &F to be considerably faster at the risk of generating an illegal lens.(upon' (tail.tail) .~ [10,20] $ [1,2,3,4] [1,2,10,20]e This automatically constructs a  from a field accessor.The index of the   can be used as an offset into  ( `) or into the list returned by  `.The design of e5 doesn't allow it to search inside of values of type a for other values of type a. cG provides this additional recursion, but at the expense of performance.2onceUpon (tail.tail) .~ [10,20] $ [1,2,3,4] -- BAD [1,10,20]/upon (tail.tail) .~ [10,20] $ [1,2,3,4] -- GOOD [1,2,10,20]When in doubt, use c instead.fThis more trusting version of c1 uses your function directly as the getter for a &.This means that reading from d is considerably faster than c./However, you pay for faster access in two ways: 'When passed an illegal field accessor, d will give you a &, that quietly violates the laws, unlike c, which will give you a legal  " that avoids modifying the target.kModifying with the lens is slightly slower, since it has to go back and calculate the index after the fact.4When given a legal field accessor, the index of the & can be used as an offset into  ( `) or into the list returned by  `.When in doubt, use d instead.2 inlineable 3/456789:;<=>?@ABCDEF^_G`abHcdefIJKLMN2OPQRSTUVWX ^_`abcdef `_abcdef^$45678;:9<=>?@ABCDEF^_G`abHcdefIJKLMN2OPQRSTUVWX!(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional Rank2Types Trustworthy 12346HJKM)hA hN type is one where we know how to extract its immediate self-similar children. Example 1: rimport Control.Applicative import Control.Lens import Control.Lens.Plated import Data.Data import Data.Data.Lens (a)  data Expr = Val 6, | Neg Expr | Add Expr Expr deriving (y,v,[,Z,1,Y)   instance h Expr where i f (Neg e) = Neg  f e i f (Add a b) = Add  f a * f b i _ a =  a or  instance h Expr where i = a  Example 2: rimport Control.Applicative import Control.Lens import Control.Lens.Plated import Data.Data import Data.Data.Lens (a)  <data Tree a = Bin (Tree a) (Tree a) | Tip a deriving (y,v,[,Z,1,Y)   instance h (Tree a) where i f (Bin l r) = Bin  f l * f r i _ t =  t or  instance 1 a => h (Tree a) where i = a ;Note the big distinction between these two implementations.The former will only treat children directly in this tree as descendents, 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 h with orphan instances!>If you want to find something unplated and non-recursive with b use the ...OnOf variant with T, though those usecases are much better served in most cases by using the existing & combinators! e.g. - b "a x b  )This same ability to explicitly pass the  8 in question is why there is no analogue to uniplate's Biplate.xMoreover, since we can allow custom traversals, we implement reasonable defaults for polymorphic data types, that only  into themselves, and not their polymorphic arguments.i - of the immediate children of this structure.5If you're using GHC 7.2 or newer and your type has a 1 instance, i will default to aA and you can choose to not override it with your own definition.jCompose through a platek<Try to apply a traversal to all transitive descendants of a h= container, but do not recurse through matching descendants. k :: h s =>  s a ->  s a k :: h s =>  s a ->  s a k :: h s =>   s s a b ->   s s a b k :: h s =>  s s a b ->  s s a b l'Extract the immediate descendants of a h container. l "a - i moRewrite by applying a rule everywhere you can. Ensures that the rule cannot be applied anywhere in the result: propRewrite r x =  (  r) (u (m r x)) Usually } is more appropriate, but mE can give better compositionality. Given two single transformations f and g, you can construct  a -> f a mplus g a2 which performs both rewrites until a fixed point.noRewrite by applying a rule everywhere you can. Ensures that the rule cannot be applied anywhere in the result: propRewriteOf l r x =  (  r) (v l (n l r x)) Usually  is more appropriate, but nE can give better compositionality. Given two single transformations f and g, you can construct  a -> f a mplus g a2 which performs both rewrites until a fixed point. n ::  a a -> (a ->  a) -> a -> a n :: % a a -> (a ->  a) -> a -> a n ::  a a -> (a ->  a) -> a -> a n ::  a a -> (a ->  a) -> a -> a o4Rewrite recursively over part of a larger structure. o :: h a =>  s a -> (a ->  a) -> s -> s o :: h a => % s a -> (a ->  a) -> s -> s o :: h a =>  s a -> (a ->  a) -> s -> s o :: h a => + s a -> (a ->  a) -> s -> s pFRewrite recursively over part of a larger structure using a specified . p ::  s a ->  a a -> (a ->  a) -> s -> s p :: % s a -> % a a -> (a ->  a) -> s -> s p ::  s a ->  a a -> (a ->  a) -> s -> s p ::  s a ->  a a -> (a ->  a) -> s -> s qwRewrite by applying a monadic rule everywhere you can. Ensures that the rule cannot be applied anywhere in the result.rRRewrite by applying a monadic rule everywhere you recursing with a user-specified  B. Ensures that the rule cannot be applied anywhere in the result.s`Rewrite by applying a monadic rule everywhere inside of a structure located by a user-specified  B. Ensures that the rule cannot be applied anywhere in the result.t`Rewrite by applying a monadic rule everywhere inside of a structure located by a user-specified  , using a user-specified  O for recursion. Ensures that the rule cannot be applied anywhere in the result.u0Retrieve all of the transitive descendants of a h container, including itself.vGiven a u that knows how to locate immediate children, retrieve all of the transitive descendants of a node, including itself. v ::  a a -> a -> [a] wGiven a  that knows how to find hN parts of a container retrieve them and all of their descendants, recursively.xGiven a  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 . - l "a x l  y*Fold over all transitive descendants of a h container, including itself.zGiven a q that knows how to locate immediate children, fold all of the transitive descendants of a node, including itself. z ::  a a ->  a a {Given a  that knows how to find hJ parts of a container fold them and all of their descendants, recursively. { :: h a =>  s a ->  s a |Given a  that knows how to locate immediate children, fold all of the transitive descendants of a node, including itself that lie in a region indicated by another . | ::  s a ->  a a ->  s a };Transform every element in the tree, in a bottom-up manner.7For example, replacing negative literals with literals:  negLits = }) $ \x -> case x of Neg (Lit i) -> Lit (Z i) _ -> x ~WTransform every element in the tree in a bottom-up manner over a region indicated by a . ~ :: h a =>  s a -> (a -> a) -> s -> s ~ :: h 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 HTransform 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, h a) =>  s a -> (a -> m a) -> s -> m s 8Transform every element in a tree using a user supplied  - in a bottom-up manner with a monadic effect.  ::  m =>  a a -> (a -> m a) -> a -> m a PTransform 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 _Return a list of all of the editable contexts for every location in the structure, recursively. propUniverse x = u x    ( x) propId x =  ( x) [ w | w <-  x]  "a  i 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 = v l x    ( l x) propId l x =  ( x) [ w | w <-  l x]  ::  a 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 i.  b "a  b i  :: h 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 F. This extracts a list of the immediate children as editable contexts.Given a context you can use  to see the values, F at what the structure would be like with an edited result, or simply  the original structure. propChildren x = l l x    ( l x) propId x =  ( x) [ w | w <-  l x]  =  i  An alias for 6, provided for consistency with the other combinators.  "a   ::   s a -> s -> [ (->) a a s]  :: % s a -> s -> [ (->) a a s]  ::  s a -> s -> [ (->) a a s]  :: # i s a -> s -> [ ( i) a a s]  ::  i s a -> s -> [ ( i) a a s] Extract one level of / from a container in a region specified by one  , using another.  b l "a  (b  l)  ::   s a ->   a a -> s -> [ (->) a a s]  :: % s a -> % a a -> s -> [ (->) a a s]  ::  s a ->  a a -> s -> [ (->) a a s]  :: % s a -> # i a a -> s -> [ ( i) a a s]  ::  s a ->  i a a -> s -> [ ( i) a a s] JPerform a fold-like computation on each value, technically a paramorphism.  :: " a a -> (a -> [r] -> r) -> a -> r JPerform a fold-like computation on each value, technically a paramorphism.  "a  i !Fold the immediate children of a h container.  z c f = + i (c  f) z  The original uniplate% combinator, implemented in terms of h as a &.  "a  i The resulting & is safer to use as it ignores 'over-application'G and deals gracefully with under-application, but it is only a proper & if you don't change the list ! Implement i operation for a type using its [ instance.?g\hijklmnopqrstuvwxyz{|}~]^_`abcdefghijklmnop*ghijklmnopqrstuvwxyz{|}~*hilmnopqrstuvwxyz{|}~jkg=g\hijklmnopqrstuvwxyz{|}~]^_`abcdefghijklmnopj "(C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable Trustworthy3FHM Traverse a strict qb in a relatively balanced fashion, as a balanced tree with biased runs of elements at the leaves.Traverse a strict q in a relatively balanced fashion, as a balanced tree with biased runs of elements at the leaves, pretending the bytes are chars.Unpack a lazy  BytestringAn # of the individual bytes in a lazy rUnpack a lazy r pretending the bytes are chars.An # of the individual bytes in a lazy r pretending the bytes are chars.sConversion between t and . Should compile to a no-op.uUnsafe conversion between  and t<. This is a no-op and silently truncates to 8 bits Chars > '\255'=. It is provided as convenience for ByteString construction.Unpack a strict Unpack a strict !, pretending the bytes are chars.v8A way of creating ByteStrings outside the IO monad. The Int; argument gives the final size of the ByteString. Unlike  createAndTrimV the ByteString is not reallocated if the final size is less than the estimated size.wCreate ByteString of size l and use action f to fill it's contents.xyz{|}~suvwxyz{|}~suvw#(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional Rank2Types Safe-Inferred !"=HKM A  .>When you see this as an argument to a function, it expects an .Provides witness that (s ~ a, b ~ t) holds.Extract a witness of type .Substituting types with . We can use " to do substitution into anything. is symmetric.8This is an adverb that can be used to modify many other &k combinators to make them require simple lenses, simple traversals, simple prisms or simple isos as input.CComposition with this isomorphism is occasionally useful when your &, d or u has a constraint on an unused argument to force that argument to agree with the type of a used argument and avoid ScopedTypeVariables or other ugliness.    (C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional Rank2TypesNone68HMPAd hoc conversion between "strict" and "lazy" versions of a structure, such as  or q.-This class provides for symmetric bifunctors.    "a  first f   =   second f second g   =   first g  f g   =    g f (1,2)^.swapped(2,1)A  .>When you see this as an argument to a function, it expects an .<Build a simple isomorphism from a pair of inverse functions.  ( f g) "a f  ( ( f g)) "a g  ( f g) h "a g  h  f  ( ( f g)) h "a f  h  g Invert an isomorphism.  ( l) "a l $Extract the two functions, one from s -> a and one from b -> t that characterize an . Convert from  back to any .This is useful when you need to store an isomorphism as a data type inside a container and later reconstitute it as an overloaded function.See  or 7 for more information on why you might want to do this. Based on $& from Conor McBride's work on Epigram.*This version is generalized to accept any  , not just a newtype.$au (_Wrapping Sum) foldMap [1,2,3,4]10OYou may want to think of this combinator as having the following, simpler type: 6au :: AnIso s t a b -> ((b -> t) -> e -> s) -> e -> a  Based on ala'& from Conor McBride's work on Epigram.*This version is generalized to accept any  , not just a newtype.'For a version you pass the name of the newtype constructor to, see $.Gauf (_Unwrapping Sum) (foldMapOf both) Prelude.length ("hello","world")10Mnemonically, the German auf plays a similar role to  la, and the combinator is ! with an extra function argument:  :: 8 s t a b -> ((r -> a) -> e -> b) -> (r -> s) -> e -> t but the signature is general.The opposite of working  a  is working  an isomorphism.  "a     ::  s t a b -> (t -> s) -> b -> a BThis isomorphism can be used to convert to or from an instance of . LT^.from enum097^.enum :: Char'a'Note: this is only an isomorphism from the numeric range actually used and it is a bit of a pleasant fiction, since there are questionable  instances for , and  that exist solely for  [1.0 .. 4.0]' sugar and the instances for those and ( don't cover all values in their range.This can be used to lift any  into an arbitrary .If v is an element of a type a, and a' is a sans the element v, then  v is an isomorphism from  a' to a.  "a    NKeep in mind this is only a real isomorphism if you treat the domain as being  (a sans v).9This is practically quite useful when you want to have a 3 where all the entries should have non-zero values.4Map.fromList [("hello",1)] & at "hello" . non 0 +~ 2fromList [("hello",3)]4Map.fromList [("hello",1)] & at "hello" . non 0 -~ 1 fromList []0Map.fromList [("hello",1)] ^. at "hello" . non 01%Map.fromList [] ^. at "hello" . non 00JThis combinator is also particularly useful when working with nested maps.e.g.$ When you want to create the nested  when it is missing:<Map.empty & at "hello" . non Map.empty . at "world" ?~ "!!!"/fromList [("hello",fromList [("world","!!!")])]6and when have deleting the last entry from the nested @ mean that we should delete its entry from the surrounding one:dfromList [("hello",fromList [("world","!!!")])] & at "hello" . non Map.empty . at "world" .~ Nothing fromList []8It can also be used in reverse to exclude a given value:non 0 # rem 10 4Just 2non 0 # rem 10 5Nothing p generalizes  (p # ()) to take any unit  /This function generates an isomorphism between  (a |  p a) and a.PMap.singleton "hello" Map.empty & at "hello" . non' _Empty . at "world" ?~ "!!!"/fromList [("hello",fromList [("world","!!!")])]bfromList [("hello",fromList [("world","!!!")])] & at "hello" . non' _Empty . at "world" .~ Nothing fromList [] a p generalizes  a# to take any value and a predicate.This function assumes that p a holds & and generates an isomorphism between  (a |  (p a)) and a.FMap.empty & at "hello" . anon Map.empty Map.null . at "world" ?~ "!!!"/fromList [("hello",fromList [("world","!!!")])]nfromList [("hello",fromList [("world","!!!")])] & at "hello" . anon Map.empty Map.null . at "world" .~ Nothing fromList []AThe canonical isomorphism for currying and uncurrying a function.  =    (fst^.curried) 3 43view curried fst 3 43AThe canonical isomorphism for uncurrying and currying a function.  =      =   ((+)^.uncurried) (1,2)3(The isomorphism for flipping a function.((,)^.flipped) 1 2(2,1)An E between the strict variant of a structure and its lazy counterpart.  =   See  4http://hackage.haskell.org/package/strict-base-types for an example use.An  between a list, q, ! fragment, etc. and its reversal."live" ^. reversed"evil""live" & reversed %~ ('d':)"lived"<Given a function that is its own inverse, this gives you an  using it in both directions.  "a   "live" ^. involuted reverse"evil"$"live" & involuted reverse %~ ('d':)"lived"*This isomorphism can be used to inspect a  M to see how it associates the structure and it can also be used to bake the   into a 2 so that you can traverse over it multiple times.+This isomorphism can be used to inspect an M to see how it associates the structure and it can also be used to bake the  into a V so that you can traverse over it multiple times with access to the original indices.Lift an  into a  functor. contramapping ::  f =>  s t a b -> * (f a) (f b) (f s) (f t) contramapping ::  f =>   s a ->   (f a) (f s)  Lift two s into both arguments of a  simultaneously.  dimapping ::  p =>  s t a b ->  s' t' a' b' -> 2 (p a s') (p b t') (p s a') (p t b') dimapping ::  p =>   s a ->   s' a' ->   (p a s') (p s a') Lift an - contravariantly into the left argument of a .  lmapping ::  p =>  s t a b -> - (p a x) (p b y) (p s x) (p t y) lmapping ::  p =>   s a ->   (p a x) (p s x) Lift an * covariantly into the right argument of a .  rmapping ::  p =>  s t a b -> - (p x s) (p y t) (p x a) (p y b) rmapping ::  p =>   s a ->   (p x s) (p x a)  Lift two s into both arguments of a  .  bimapping ::   p =>  s t a b ->  s' t' a' b' -> 2 (p s s') (p t t') (p a a') (p b b') bimapping ::   p =>   s a ->   s' a' ->   (p s s') (p a a') &)qr ) qr$$'(C) 2012-15 Edward Kmett, Michael Sloan BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimentalRank2, MPTCs, fundeps Trustworthy '246=HKMW provides isomorphisms to wrap and unwrap newtypes or data types with one constructor.An isomorphism between s and a.Work under a newtype wrapper.5Const "hello" & _Wrapped %~ Prelude.length & getConst5  "a    "a   Given the constructor for a 3 type, return a deconstructor that is its inverse. Assuming the $ instance is legal, these laws hold:  f  f "a  f   f "a  op Identity (Identity 4)4op Const (Const "hello")"hello" This is a convenient version of ! with an argument that's ignored.The user supplied function is ignored, merely its type is used. This is a convenient version of ! with an argument that's ignored.The user supplied function is ignored, merely its type is used. This is a convenient version of ! with an argument that's ignored.The user supplied function is ignored, merely its types are used. This is a convenient version of ! with an argument that's ignored.The user supplied function is ignored, merely its types are used.This combinator is based on ala& from Conor McBride's work on Epigram.As with 0, the user supplied function for the newtype is ignored.ala Sum foldMap [1,2,3,4]10ala All foldMap [True,True]Trueala All foldMap [True,False]Falseala Any foldMap [False,False]Falseala Any foldMap [True,False]Trueala Sum foldMap [1,2,3,4]10ala Product foldMap [1,2,3,4]24PYou may want to think of this combinator as having the following, simpler, type. bala :: Rewrapping s t => (Unwrapped s -> s) -> ((Unwrapped t -> t) -> e -> s) -> e -> Unwrapped s This combinator is based on ala'& from Conor McBride's work on Epigram.As with 0, the user supplied function for the newtype is ignored. palaf :: Rewrapping s t => (Unwrapped s -> s) -> ((r -> t) -> e -> s) -> (r -> Unwrapped t) -> e -> Unwrapped s 1alaf Sum foldMap Prelude.length ["hello","world"]10Use wrapping . unwrapping returns a sorted list.Use wrapping . unwrapping returns a sorted list.Use wrapping . unwrapping returns a sorted list.Use wrapping . unwrapping returns a sorted list.Use wrapping 2. Unwrapping returns some permutation of the list.Use wrapping 2. Unwrapping returns some permutation of the list.                           ! " # $ %                           ! " # $ %%(C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional non-portable Trustworthy3HM  sliced i n provides a & that edits the n elements starting at index i from a &.This is only a valid &3 if you do not change the length of the resulting  &.RAttempting to return a longer or shorter vector will result in violations of the & laws.DVector.fromList [1..10] ^. sliced 2 5 == Vector.fromList [3,4,5,6,7]True^(Vector.fromList [1..10] & sliced 2 5 . mapped .~ 0) == Vector.fromList [1,2,0,0,0,0,0,8,9,10]True Similar to -, but returning a  &.G(toVectorOf both (8,15) :: Vector.Vector Int) == Vector.fromList [8,15]TrueConvert a list to a  & (or back.)C([1,2,3] ^. vector :: Vector.Vector Int) == Vector.fromList [1,2,3]True'Vector.fromList [0,8,15] ^. from vector[0,8,15] Convert a  & to a finite  ' (or back.) Convert a  & to a finite  ' from right to left (or back.) Convert a  &H back and forth to an initializer that when run produces a copy of the  &. Convert a  &4 to a version that doesn't retain any extra memory.This  = will ignore any duplicates in the supplied list of indices.>toListOf (ordinals [1,3,2,5,9,10]) $ Vector.fromList [2,4..40][4,8,6,12,20,22]Like ix$ but polymorphic in the vector type..Indexed vector traversal for a generic vector.>Different vector implementations are isomorphic to each other. i starting indexn length   &(C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portableNone3 This isomorphism can be used to  ( (or  ) ) strict ."hello"^.packed -- :: Text"hello"  ( x "a x    ) x "a x     "a    "a   (  )  This isomorphism can be used to  ) (or  () lazy ."hello"^.unpacked -- :: String"hello"This L is provided for notational convenience rather than out of great need, since  "a    ( x "a x     ) x "a x    "a   )  ( This is an alias for / that makes it more obvious how to use it with '#' > _Text # "hello" -- :: Text"hello"Convert between strict  and  * .  + x "a x    , ( - x) "a x    -Traverse the individual characters in strict .anyOf text (=='o') "hello"True@When the type is unambiguous, you can also use the more general each.  "a  .   "a each $Note that when just using this as a , 1  can be more efficient.EncodeDecode a strict  to from strict q , via UTF-8. utf8 # "&""\226\152\131" . / . /'(C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portableNone234 This isomorphism can be used to  0 (or  1) lazy  2."hello"^.packed -- :: Text"hello"  0 x "a x    1 x "a x     "a    This isomorphism can be used to  1 (or  0) lazy  2."hello"^.unpacked -- :: String"hello"  0 x "a x     1 x "a x   This L is provided for notational convenience rather than out of great need, since  "a   This is an alias for * that makes it clearer how to use it with ('#').  =   _Text # "hello" -- :: Text"hello"Convert between lazy  2 and  * .  3 x "a x    - x "a x    (Traverse the individual characters in a  2.anyOf text (=='c') "chello"True  =  .  @When the type is unambiguous, you can also use the more general each.  "a each $Note that when just using this as a , 1  can be more efficient.EncodeDecode a lazy  2 to from lazy r , via UTF-8.yNote: This function does not decode lazily, as it must consume the entire input before deciding whether or not it fails.ByteString.unpack (utf8 # "&") [226,152,131] 4 5 4 5((C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portableNone234Traversals for strict or lazy  This isomorphism can be used to  0 (or  1) strict or lazy .  0 x "a x ^.   1 x "a x ^.    "a   Convert between strict or lazy  and a  *.  + x "a x ^.  5Traverse the individual characters in strict or lazy .  =  .   This isomorphism can be used to  1 (or  0) both strict or lazy .  1 x "a x ^.   0 x "a x ^.   This L is provided for notational convenience rather than out of great need, since  "a   This is an alias for * that makes it clearer how to use it with ('#').  =   _Text # "hello" :: Strict.Text"hello"  6 7 8 6 7 8)(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional non-portable Trustworthy1;isn't _Empty [1,2,3]True 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T*(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable Trustworthy!"123468=KExtract 2 element of a (potentially monomorphic) container.3Notably, when applied to a tuple, this generalizes ! to arbitrary homogeneous tuples.(1,2,3) & each *~ 10 (10,20,30)3It can also be used on monomorphic containers like  or q.-over each Char.toUpper ("hello"^.Text.packed)"HELLO"-("hello","world") & each.each %~ Char.toUpper("HELLO","WORLD") U  :: ( V i,  W  X a,  W  X b) =>   ( Y i a) ( Y i b) a b Z  ::  V i =>   ( Y i a) ( Y i b) a b [  ::   r r t t \  ::   q q t t ]  ::    2  2   ^  ::       _  :: ( ` a,  ` b) =>   ( a a) ( a b) a b b  :: ( c a,  c b) =>   ( d a) ( d b) a b e  :: ( f a,  f b) =>   ( g a) ( g b) a b h  ::   ( i a) ( i b) a b j  ::   ( k a) ( k b) a b l  ::   ( a) ( b) a b m  ::   ( a) ( b) a b n  ::   (  a) (  b) a b o  ::   (NonEmpty a) (NonEmpty b) a b p  ::   [a] [b] a b q  ::   ( r c a) ( r c b) a b s  ::   ( t c a) ( t c b) a b u  ::   ( t c a) ( t c b) a b v  :: ( w a,  w b) =>   ( x a) ( x b) a b y  ::  , (a,a,a,a,a,a,a,a,a) (b,b,b,b,b,b,b,b,b) a b z  ::  ( (a,a,a,a,a,a,a,a) (b,b,b,b,b,b,b,b) a b {  ::  $ (a,a,a,a,a,a,a) (b,b,b,b,b,b,b) a b |  ::   (a,a,a,a,a,a) (b,b,b,b,b,b) a b }  ::   (a,a,a,a,a) (b,b,b,b,b) a b ~  ::   (a,a,a,a) (b,b,b,b) a b   ::   (a,a,a) (b,b,b) a b  ::   (a,a) (b,b) a b U Z [ \ ] ^ _ b e h j l m n o p q s u v y z { | } ~   U Z [ \ ] ^ _ b e h j l m n o p q s u v y z { | } ~  +(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable Trustworthy 23468=KnThis class provides a way to attach or detach elements on the right side of a structure in a flexible manner.  ::   [a] [b] ([a], a) ([b], b)  ::   ( a) ( b) ( a, a) ( b, b)  ::   ( i a) ( i b) ( i a, a) ( i b, b)  ::    (, )  ::    (, )  ::   q (q, t) mThis class provides a way to attach or detach elements on the left side of a structure in a flexible manner.  ::   [a] [b] (a, [a]) (b, [b])  ::   ( a) ( b) (a,  a) (b,  b)  ::   ( i a) ( i b) (a,  i a) (b,  i b)  ::    (, )  ::    (, )  ::   q (t, q)  an element onto a container.This is an infix alias for .a <| [][a] a <| [b, c][a,b,c]a <| Seq.fromList [] fromList [a]a <| Seq.fromList [b, c]fromList [a,b,c] an element onto a container. cons a [][a] cons a [b, c][a,b,c]cons a (Seq.fromList []) fromList [a]cons a (Seq.fromList [b, c])fromList [a,b,c]oAttempt to extract the left-most element from a container, and a version of the container without that element. uncons []Nothinguncons [a, b, c]Just (a,[b,c])A   reading and writing to the  of a  non-empty container.[a,b,c]^? _headJust a[a,b,c] & _head .~ d[d,b,c][a,b,c] & _head %~ f [f a,b,c][] & _head %~ f[][1,2,3]^?!_head1 []^?_headNothing [1,2]^?_headJust 1[] & _head .~ 1[][0] & _head .~ 2[2][0,1] & _head .~ 2[2,1]This isn't limited to lists.For instance you can also  the head of a :#Seq.fromList [a,b,c,d] & _head %~ ffromList [f a,b,c,d]Seq.fromList [] ^? _headNothingSeq.fromList [a,b,c,d] ^? _headJust a  ::  [a] a  ::  ( a) a  ::  ( i a) a A   reading and writing to the   of a  non-empty container.[a,b] & _tail .~ [c,d,e] [a,c,d,e][] & _tail .~ [a,b][]![a,b,c,d,e] & _tail.traverse %~ f[a,f b,f c,f d,f e][1,2] & _tail .~ [3,4,5] [1,3,4,5][] & _tail .~ [1,2][][a,b,c]^?_tail Just [b,c] [1,2]^?!_tail[2]"hello"^._tail"ello" ""^._tail""7This isn't limited to lists. For instance you can also  the tail of a .2Seq.fromList [a,b] & _tail .~ Seq.fromList [c,d,e]fromList [a,c,d,e]Seq.fromList [a,b,c] ^? _tailJust (fromList [b,c])Seq.fromList [] ^? _tailNothing  ::  [a] [a]  ::  ( a) ( a)  ::  ( i a) ( i a) A  7 reading and replacing all but the a last element of a  non-empty container.[a,b,c,d]^?_init Just [a,b,c] []^?_initNothing[a,b] & _init .~ [c,d,e] [c,d,e,b][] & _init .~ [a,b][][a,b,c,d] & _init.traverse %~ f[f a,f b,f c,d][1,2,3]^?_init Just [1,2][1,2,3,4]^?!_init[1,2,3]"hello"^._init"hell" ""^._init""  ::  [a] [a]  ::  ( a) ( a)  ::  ( i a) ( i a) A  . reading and writing to the last element of a  non-empty container.[a,b,c]^?!_lastc []^?_lastNothing[a,b,c] & _last %~ f [a,b,f c] [1,2]^?_lastJust 2[] & _last .~ 1[][0] & _last .~ 2[2][0,1] & _last .~ 2[0,2]This  U is not limited to lists, however. We can also work with other containers, such as a  i. Vector.fromList "abcde" ^? _lastJust 'e'Vector.empty ^? _lastNothingC(Vector.fromList "abcde" & _last .~ 'Q') == Vector.fromList "abcdQ"True  ::  [a] a  ::  ( a) a  ::  ( i a) a ( an element onto the end of a container.This is an infix alias for .Seq.fromList [] |> a fromList [a]Seq.fromList [b, c] |> afromList [b,c,a]LazyT.pack "hello" |> '!'"hello!"( an element onto the end of a container.snoc (Seq.fromList []) a fromList [a]snoc (Seq.fromList [b, c]) afromList [b,c,a]snoc (LazyT.pack "hello") '!'"hello!"pAttempt to extract the right-most element from a container, and a version of the container without that element.unsnoc (LazyT.pack "hello!")Just ("hello",'!')unsnoc (LazyT.pack "")Nothingunsnoc (Seq.fromList [b,c,a])Just (fromList [b,c],a)unsnoc (Seq.fromList [])Nothing$ " ,(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portableNone246FMA Banker's deque based on Chris Okasaki's "Purely Functional Data Structures"O(1). Determine if a  is  . null emptyTruenull (singleton 1)FalseO(1). Generate a singleton  singleton 1 BD 1 [1] 0 []O(1). Calculate the size of a size (fromList [1,4,6])3O(n) amortized. Construct a  from a list of values.fromList [1,2]BD 1 [1] 1 [2]  Check that a 7 satisfies the balance invariants and rebalance if not.  -(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable Trustworthy!"12346=HJKM provides a &Q that can be used to read, write or delete the value associated with a key in a  t$-like container on an ad hoc basis.An instance of  should satisfy:   k "a  k   !Map.fromList [(1,"world")] ^.at 1 Just "world"at 1 ?~ "hello" $ Map.emptyfromList [(1,"hello")]Note:  t5-like containers form a reasonable instance, but not  Y*-like ones, where you cannot satisfy the & laws. This simple   lets you  the value at a given key in a  t0 or element at an ordinal position in a list or .  This simple   lets you  the value at a given key in a  t0 or element at an ordinal position in a list or .NB: Setting the value of this   will only set the value in  if it is already present.!If you want to be able to insert missing values, you want ."Seq.fromList [a,b,c,d] & ix 2 %~ ffromList [a,b,f c,d]"Seq.fromList [a,b,c,d] & ix 2 .~ efromList [a,b,e,d]Seq.fromList [a,b,c,d] ^? ix 2Just cSeq.fromList [] ^? ix 2Nothing LThis provides a common notion of a value at an index that is shared by both  and . This class provides a simple &` that lets you view (and modify) information about whether or not a container contains a given  . 'IntSet.fromList [1,2,3,4] ^. contains 3True'IntSet.fromList [1,2,3,4] ^. contains 5False/IntSet.fromList [1,2,3,4] & contains 3 .~ FalsefromList [1,2,4]An indexed version of  .)IntSet.fromList [1,2,3,4] ^@. icontains 3(3,True))IntSet.fromList [1,2,3,4] ^@. icontains 5 (5,False)NIntSet.fromList [1,2,3,4] & icontains 3 %@~ \i x -> if odd i then not x else xfromList [1,2,4]OIntSet.fromList [1,2,3,4] & icontains 3 %@~ \i x -> if even i then not x else xfromList [1,2,3,4]An indexed version of  .%Seq.fromList [a,b,c,d] & iix 2 %@~ f'fromList [a,b,f' 2 c,d]$Seq.fromList [a,b,c,d] & iix 2 .@~ hfromList [a,b,h 2,d] Seq.fromList [a,b,c,d] ^@? iix 2 Just (2,c)Seq.fromList [] ^@? iix 2NothingA definition of   for types with an F instance. This is the default if you don't specify a definition for  .,Delete the value associated with a key in a  t-like container  k =  k .~ Nothing An indexed version of .$Map.fromList [(1,"world")] ^@. iat 1(1,Just "world")Giat 1 %@~ (\i x -> if odd i then Just "hello" else Nothing) $ Map.emptyfromList [(1,"hello")]Giat 2 %@~ (\i x -> if odd i then Just "hello" else Nothing) $ Map.empty fromList []   :: 6 ->  (a,a,a,a,a,a,a,a,a) a   :: 6 ->  (a,a,a,a,a,a,a,a) a   :: 6 ->  (a,a,a,a,a,a,a) a   :: 6 ->  (a,a,a,a,a,a) a   :: 6 ->  (a,a,a,a,a) a   :: 6 ->  (a,a,a,a) a   :: 6 ->  (a,a,a) a   :: 6 ->  (a,a) a arr   i "a arr    i arr   [(i,e)] "a   i : e  arr arr   i "a arr    i arr   [(i,e)] "a   i : e  arr u                                    r                        .(C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimentalTemplateHaskell TrustworthyHM Provides substitution for typesPerform substitution for typesGProvides for the extraction of free type variables, and alpha renaming.When performing substitution into this traversal you're not allowed to substitute in a name that is bound internally or you'll violate the  . laws, when in doubt generate your names with  .Contains some amount of  s insideTraverse all the typesHas a Extract (or modify) the  of something Traverse free type variables'Substitute using a map of names in for free type variables Provides a  - of the types of each field of a constructor.  of the types of the named fields of a constructor. !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      ! " # $ % & ' ( ) * !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ǵ !"#$%*+,-./01&'()no23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmpqrstuvwxyz{|}~ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      ! " # $ % & ' ( ) */1(C) 2014-2015 Edward Kmett, (C) 2014 Eric Mertens BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable TrustworthyF'Name to give to generated field optics.+makeFields-style class name and method nameSimple top-level definiton name Allow LensTraversal (otherwise GetterFold)AType Name -> Field Names -> Target Field Name -> Definition NamesCompute the field optics for the type identified by the given type name. Lenses will be computed when possible, Traversals otherwise. +qCompute the field optics for a deconstructed Dec When possible build an Iso otherwise build one optic per field. ,Normalized the Con type into a uniform positional representation, eliminating the variance between records, infix constructors, and normal constructors. -Compute the positional location of the fields involved in each constructor for a given optic definition as well as the type of clauses to generate and the type to annotate the declaration with. ./Compute the s t a b types given the outer type s} and the categorized field types. Left for fixed and Right for visited. These types are "raw" and will be packaged into an  / shortly after creation. 0Build the signature and definition for a single field optic. In the case of a singleton constructor irrefutable matches are used to enable the resulting lenses to be used on a bottom value. 1Construct an optic clause that returns an unmodified value given a constructor name and the number of fields on that constructor. 2vConstruct an optic clause suitable for a Getter or Fold by visited the fields identified by their 0 indexed positions 3JBuild a clause that updates the field at the given indexes When irref is m the value with me matched with an irrefutable pattern. This is suitable for Lens and Traversal construction 4%Build a clause that constructs an Iso 5Unify the given list of types, if possible, and return the substitution used to unify the types for unifying the outer type when building a definition's type signature. 6=Attempt to unify two given types using a running substitution 7Perform a limited substitution on type variables. This is used when unifying rank-2 fields when trying to achieve a Getter or Fold. 8cApply a substitution to a type. This is used after unifying the types of the fields in unifyTypes. 9Template Haskell wants type variables declared in a forall, so we find all free type variables in a given type and declare them. :This function works like  9J except that it takes a list of variables to exclude from quantification.1 / ; < = > ? @ + ,(constructor name, field name, field type -!outer type !normalized constructors !target definition 8optic type, definition type, field count, target fields A B C D E . 0 FOuter s type GOuter s type HOuter s type I J K 1 2 3 4 5 6 7 8 9 : L!  / < ; = @ ? > + , - A B C D E . 0 F G H I J K 1 2 3 4 5 6 7 8 9 : L0+(C) 2014-2015 Edward Kmett and Eric Mertens BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable Trustworthy MNormalized constructor Generate a Prism for each constructor of a data type. Isos generated when possible. Reviews are created for constructors with existentially quantified constructors and GADTs.e.g. Cdata FooBarBaz a = Foo Int | Bar a | Baz Int Char makePrisms '' FooBarBaz  will create x_Foo :: Prism' (FooBarBaz a) Int _Bar :: Prism (FooBarBaz a) (FooBarBaz b) a b _Baz :: Prism' (FooBarBaz a) (Int, Char)  Generate a Prism for each constructor of a data type and combine them into a single class. No Isos are created. Reviews are created for constructors with existentially quantified constructors and GADTs.e.g. Idata FooBarBaz a = Foo Int | Bar a | Baz Int Char makeClassyPrisms '' FooBarBaz  will create class AsFooBarBaz s a | s -> a where _FooBarBaz :: Prism' s (FooBarBaz a) _Foo :: Prism' s Int _Bar :: Prism' s a _Baz :: Prism' s (Int,Char) _Foo = _FooBarBaz . _Foo _Bar = _FooBarBaz . _Bar _Baz = _FooBarBaz . _Baz instance AsFooBarBaz (FooBarBaz a) a  Generate an As class of prisms. Names are selected by prefixing the constructor name with an underscore. Constructors with multiple fields will construct Prisms to tuples of those fields. NIMain entry point into Prism generation for a given type constructor name.Generate prisms for the given  O PGenerate prisms for the given type, normalized constructors, and an optional name to be used for generating a prism class. This function dispatches between Iso generation, normal top-level prisms, and classy prisms. QCompute the full type-changing Prism type given an outer type, list of constructors, and target constructor name. Additionally return + if the resulting type is a "simple" prism. R1Construct either a Review or Prism as appropriate SConstruct an iso declaration TConstruct prism expressionprism  reviewer remitter UConstruct an Iso expressioniso  reviewer remitter VConstruct a Review expressionunto ((x,y,z) -> Con x y z) W(Construct the review portion of a prism. ((x,y,z) -> Con x y z) :: b -> t X`Construct the remit portion of a prism. Pattern match only target constructor, no type changingh(x -> case s of Con x y z -> Right (x,y,z) _ -> Left x ) :: s -> Either s a Y6Pattern match all constructors to enable type-changingt(x -> case s of Con x y z -> Right (x,y,z) Other_n w -> Left (Other_n w) ) :: s -> Either t a Z.Construct the remitter suitable for use in an Iso"((Con x y z) -> (x,y,z)) :: s -> a [DConstruct the classy prisms class for a given type and constructors.class ClassName r  varsin type | r ->  varsin Type where topMethodName :: Prism' r Type conMethodName_n :: Prism' r conTypes_n conMethodName_n = topMethodName . conMethodName_n \GConstruct the classy prisms instance for a given type and constructors.Ninstance Classname OuterType where topMethodName = id conMethodName_n = prism ] Normalize  ^) to its constructor name and field types. _dCompute a prism's name by prefixing an underscore for normal constructors and period for operators. `*Quantify all the free variables in a type.) M a b c d e f g h iType constructor name Type constructor name Ngenerate top-level definitions P j k l m n o Q p R S Tconstructors target constructor U V W X Y Z [ \ q r s ] _ ` t" M a b c d e f g i h N P j k l m n o Q p R S T U V W X Y Z [ \ q r s ] _ ` t1/(C) 2012-15 Edward Kmett, 2012-13 Michael Sloan BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable TrustworthyF( u;Monad for emitting top-level declarations as a side effect. v?A data, newtype, data instance or newtype instance declaration. wDatatype context. x=Type constructor name, or Nothing for a data family instance. yList of type parameters z7Create a concrete record type given a substitution to detaParameters. {;Constructors , derivings :: [Name] -- currently not neededMGenerate "simple" optics even when type-changing optics are possible. (e.g. % instead of &)KIndicate whether or not to supply the signatures for the generated lenses.Disabling this can be useful if you want to provide a more restricted type signature or if you want to supply hand-written haddocks."Generate "updateable" optics when . When ,  s will be generated instead of  s and  s will be generated instead of &qes. This mode is intended to be used for types with invariants which must be maintained by "smart" constructors.wGenerate optics using lazy pattern matches. This can allow fields of an undefined value to be initialized with lenses: 8data Foo = Foo {_x :: Int, _y :: Bool} deriving Show  ( &  .~ True) ''Foo  9> undefined & x .~ 8 & y .~ True Foo {_x = 8, _y = True} The downside of this flag is that it can lead to space-leaks and code-size/compile-time increases when generated for large records. By default this flag is turned off, and strict optics are generated.LWhen using lazy optics the strict optic can be recovered by composing with  |: strictOptic = ($!) . lazyOptic 'Create the class if the constructor is  and the  rule matches.%3 to access the convention for naming fields in our .}Defaults to stripping the _ off of the field name, lowercasing the name, and skipping the field if it doesn't start with an '_'. The field naming rule provides the names of all fields in the type as well as the current field. This extra generality enables field naming conventions that depend on the full set of names in a type.The field naming rule has access to the type name, the names of all the field of that type (including the field being named), and the name of the field being named.6TypeName -> FieldNames -> FieldName -> DefinitionNamesxRetrieve options such as the name of the class and method to put in it to build a class around monomorphic data types. Classyn lenses are generated when this naming convention is provided. TypeName -> Maybe (ClassName, MainMethodName)Rules for making fairly simple partial lenses, ignoring the special cases for isomorphisms and traversals, and not making any classes. Construct a f value for generating top-level definitions using the given map from field names to definition names.?Rules for making lenses and traversals that precompose another &. }?Rules for making lenses and traversals that precompose another &w using a custom function for naming the class, main class method, and a mapping from field names to definition names.DBuild lenses (and traversals) with a sensible default configuration.e.g.  data FooBar = Foo { _x, _y :: 6 } | Bar { _x :: 6 }  ''FooBar  will create x :: % FooBar 6L x f (Foo a b) = (\a' -> Foo a' b) <$> f a x f (Bar a) = Bar <$> f a y ::  FooBar 6C y f (Foo a b) = (\b' -> Foo a b') <$> f b y _ c@(Bar _) = pure c  =   ZMake lenses and traversals for a type, and create a class when the type has no arguments.e.g. !data Foo = Foo { _fooX, _fooY :: 6 }  ''Foo  will create class HasFoo t where foo :: % t Foo fooX :: % t 6N fooX = foo . go where go f (Foo x y) = (\x' -> Foo x' y) <$> f x fooY :: % t 6i fooY = foo . go where go f (Foo x y) = (\y' -> Foo x y') <$> f y instance HasFoo Foo where foo = id  =   nMake lenses and traversals for a type, and create a class when the type has no arguments. Works the same as  except that (a) it expects that record field names do not begin with an underscore, (b) all record fields are made into lenses, and (c) the resulting lens is prefixed with an underscore.?Derive lenses and traversals, specifying explicit pairings of (fieldName, lensName).rIf you map multiple names to the same label, and it is present in the same constructor then this will generate a  .e.g. ( [("_foo", "fooLens"), ("baz", "lbaz")] ''Foo & [("_barX", "bar"), ("_barY", "bar")] ''Bar `Derive lenses and traversals, using a named wrapper class, and specifying explicit pairings of (fieldName, traversalName).Example usage: 7 "HasFoo" "foo" [("_foo", "fooLens"), ("bar", "lbar")] ''Foo )Build lenses with a custom configuration.qMake lenses for all records in the given declaration quote. All record syntax in the input will be stripped off.e.g. 3declareLenses [d| data Foo = Foo { fooX, fooY :: 6 } deriving [ |]  will create data Foo = Foo 6 6 deriving [ fooX, fooY :: % Foo Int  Similar to  , but takes a declaration quote.For each record in the declaration quote, make lenses and traversals for it, and create a class when the type has no arguments. All record syntax in the input will be stripped off.e.g. 3declareClassy [d| data Foo = Foo { fooX, fooY :: 6 } deriving [ |]  will create data Foo = Foo 6 6 deriving [ class HasFoo t where foo :: %' t Foo instance HasFoo Foo where foo =  fooX, fooY :: HasFoo t => % t 6  Similar to  , but takes a declaration quote. Generate a Prism( for each constructor of each data type.e.g. ^declarePrisms [d| data Exp = Lit Int | Var String | Lambda{ bound::String, body::Exp } |]  will create Ndata Exp = Lit Int | Var String | Lambda { bound::String, body::Exp } _Lit :: Prism' Exp Int _Var :: Prism' Exp String _Lambda :: Prism' Exp (String, Exp) Build Wrapped instance for each newtype.  declareFields =  PDeclare lenses for each records in the given declarations, using the specified 7. Any record syntax in the input will be stripped off. ~ Transform NewtypeDs declarations to DataDs and  NewtypeInstDs to  DataInstDs. ZGiven a set of names, build a map from those names to a set of fresh names based on them.Build Wrapped instance for a given newtype#Field rules for fields in the form  _prefix_fieldname #Field rules for fields in the form % prefixFieldname or _prefixFieldname I If you want all fields to be lensed, then there is no reason to use an _? before the prefix. If any of the record fields leads with an _& then it is assume a field without an _ should not have a lens created.Note: The prefix must be the same as the typename (with the first letter lowercased). This is a change from lens versions before lens 4.5. If you want the old behaviour, use  Field rules fields in the form % prefixFieldname or _prefixFieldname I If you want all fields to be lensed, then there is no reason to use an _? before the prefix. If any of the record fields leads with an _& then it is assume a field without an _ should not have a lens created. Note that prefix may be any string of characters that are not uppercase letters. (In particular, it may be arbitrary string of lowercase letters and numbers) This is the behavior that  had in lens 4.4 and earlier.$Generate overloaded field accessors.e.g data Foo a = Foo { _fooX :: 6+, _fooY : a } newtype Bar = Bar { _barX ::  } makeFields ''Foo makeFields ''Bar  will create I_fooXLens :: Lens' (Foo a) Int _fooYLens :: Lens (Foo a) (Foo b) a b class HasX s a | s -> a where x :: Lens' s a instance HasX (Foo a) Int where x = _fooXLens class HasY s a | s -> a where y :: Lens' s a instance HasY (Foo a) a where y = _fooYLens _barXLens :: Iso' Bar Char instance HasX Bar Char where x = _barXLens For details, see .  makeFields =   LTraverse each data, newtype, data instance or newtype instance declaration.: u v w x y z { (Field Name, Definition Name)  }-Type Name -> Maybe (Class Name, Method Name)  (Field Name, Method Name) ~       %%4 u v w x y z {  } ~       2(C) 2013-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable Safe-Inferred&'+23468=>M 1This permits the construction of an "impossible" ) that matches only if some function does. There was an  & caused by abusing the internals of a  .Both  exceptions and Control.Exception provide a   type.pThis lets us write combinators to build handlers that are agnostic about the choice of which of these they use.This builds a  ! for just the targets of a given \ (or any  , really).   ... [  H (s ->    "Assertion Failed\n"   s) ,  H (s ->    "Error\n"   s) ] This works ith both the   type provided by Control.Exception:  ::    a -> (a ->   r) ->   r  ::    a -> (a ->   r) ->   r  ::    a -> (a ->   r) ->   r  ::    a -> (a ->   r) ->   r  ::    a -> (a ->   r) ->   r  and with the   type provided by Control.Monad.Catch:  ::    a -> (a -> m r) ->   m r  ::    a -> (a -> m r) ->   m r  ::    a -> (a -> m r) ->   m r  ::    a -> (a -> m r) ->   m r  ::    a -> (a -> m r) ->   m r  and with the 4 type provided by Control.Monad.Error.Lens:  ::  e a -> (a -> m r) -> 4 e m r  ::  e a -> (a -> m r) -> 4 e m r  ::  e a -> (a -> m r) -> 4 e m r  ::  e a -> (a -> m r) -> 4 e m r  ::  e a -> (a -> m r) -> 4 e m r This builds a  ! for just the targets of a given \ (or any T, really). that ignores its input and just recovers with the stated monadic action.   ... [  H (  "looped") ,  H (  "overflow") ] This works with the   type provided by Control.Exception:  ::    a ->   r ->   r  ::    a ->   r ->   r  ::    a ->   r ->   r  ::    a ->   r ->   r  ::    a ->   r ->   r  and with the   type provided by Control.Monad.Catch:  ::    a -> m r ->   m r  ::    a -> m r ->   m r  ::    a -> m r ->   m r  ::    a -> m r ->   m r  ::    a -> m r ->   m r  and with the 4 type provided by Control.Monad.Error.Lens:  ::  e a -> m r -> 4 e m r  ::  e a -> m r -> 4 e m r  ::  e a -> m r -> 4 e m r  ::  e a -> m r -> 4 e m r  ::  e a -> m r -> 4 e m r      (C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental Rank2Types Safe-InferredHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portableNone hlmqr{      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !ghijklmnopqrstuvwxyz{|}~     (C) 2013-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portableNone hlmqr{      !"#$%&'()*+,-./012345678GJZ[\]^_`acefghijklmnopwxyz{|}~      !"#$%&'()*+,-/0123456789:;<=>?@ABEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuyz{|}~      !ghiklmnopqrstuvwxyz{|}~     3(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportableNoneCheck to see if this   matches.is _Left (Right 12)False is hex "3f79"True ^_`abcdef(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portableNonev9:;<=>?@ABCDEFHIKLMNOPQRSTUVWXYbdqrstuv.CDvwxjv.CDvwxrstquvj9:;<=>?@ABCDEFHIKLMNOPQRSTUVWXYbd4(C) 2014-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalControl.Monad.ErrorNone246:M You need this when using .$Catch exceptions that match a given   (or any  , really).  ::   e m =>  % e a -> m r -> (a -> m r) -> m r  ::   e m => %& e a -> m r -> (a -> m r) -> m r  ::   e m => ! e a -> m r -> (a -> m r) -> m r  ::   e m =>  ' e a -> m r -> (a -> m r) -> m r  ::   e m => % e a -> m r -> (a -> m r) -> m r  ::   e m => ' e a -> m r -> (a -> m r) -> m r $Catch exceptions that match a given   (or any \), discarding the information about the match. This is particuarly useful when you have a   e () where the result of the   or = isn't particularly valuable, just the fact that it matches.  ::   e m =>   e a -> m r -> m r -> m r  ::   e m => % e a -> m r -> m r -> m r  ::   e m =>  e a -> m r -> m r -> m r  ::   e m =>   e a -> m r -> m r -> m r  ::   e m =>  e a -> m r -> m r -> m r  ::   e m =>  e a -> m r -> m r -> m r  A version of d with the arguments swapped around; useful in situations where the code for the handler is shorter.  ::   e m =>  % e a -> (a -> m r) -> m r -> m r  ::   e m => %& e a -> (a -> m r) -> m r -> m r  ::   e m => ! e a -> (a -> m r) -> m r -> m r  ::   e m =>  ' e a -> (a -> m r) -> m r -> m r  ::   e m => ' e a -> (a -> m r) -> m r -> m r  ::   e m => % e a -> (a -> m r) -> m r -> m r  A version of d with the arguments swapped around; useful in situations where the code for the handler is shorter.  ::   e m =>   e a -> m r -> m r -> m r  ::   e m => % e a -> m r -> m r -> m r  ::   e m =>  e a -> m r -> m r -> m r  ::   e m =>   e a -> m r -> m r -> m r  ::   e m =>  e a -> m r -> m r -> m r  ::   e m =>  e a -> m r -> m r -> m r  takes a   (or any 0) to select which exceptions are caught If the  Exception/ does not match the predicate, it is re-thrown.  ::   e m =>   e a -> m r -> m ( a r)  ::   e m => % e a -> m r -> m ( a r)  ::   e m =>  e a -> m r -> m ( a r)  ::   e m =>   e a -> m r -> m ( a r)  ::   e m =>  e a -> m r -> m ( a r)  ::   e m =>  e a -> m r -> m ( a r) BThis function exists to remedy a gap between the functionality of Control.Exception and Control.Monad.Error. Control.Exception supplies  and a notion of C, which we duplicate here in a form suitable for working with any   instance.VSometimes you want to catch two different sorts of error. You could do something like f =  _Foo handleFoo ( _Bar handleBar expr) However, there are a couple of problems with this approach. The first is that having two exception handlers is inefficient. However, the more serious issue is that the second exception handler will catch exceptions in the first, e.g. in the example above, if  handleFoo uses  2 then the second exception handler will catch it.Instead, we provide a function , which would be used thus: f =  expr [ # _Foo handleFoo , # _Bar handleBar ]  Throw an  Exception described by a  .  l "a  l   ::   e m =>   e t -> t -> a  ::   e m =>   e t -> t -> a 6Helper function to provide conditional catch behavior.   5(C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable TrustworthyEvaluate 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  7 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 &, , ,  or  7 to first evaluates its argument according to a given   before proceeding.      ::  t =>   a ->   [a]   Transform a &, , ,  or  0 to evaluate its argument according to a given   in parallel with evaluating.      ::  t =>   a ->   [a]             6(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportableNone $Evaluate the elements targeted by a &,  , ,  or ! according to the given strategy.   =       7(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional&MPTCs, Rank2Types, LiberalTypeSynonymsNoneHM This setter can be used to derive a new  W from an old IAarrayI by applying a function to each of the indices to look it up in the old  W. This is a  contravariant .   "a 6      "a 1    6 (  b) f arr   i "a arr   f i   (6 (  b) f arr) "a b     8(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimentalLiberalTypeSynonymsNone3HM Bitwise   the target(s) of a & or ._2 .|.~ 6 $ ("hello",3) ("hello",7) () ::   a =>  s t a a -> a -> s -> t () ::   a =>  s t a a -> a -> s -> t () ::   a => & s t a a -> a -> s -> t () :: ( 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 =>  s t a a -> a -> s -> t () ::   a => & s t a a -> a -> s -> t () :: ( a,   a) =>   s t a a -> a -> s -> t Modify the target(s) of a %,  or  by computing its bitwise   with another value.*execState (do _1 .&.= 15; _2 .&.= 3) (7,7)(7,3) () :: ( s m,   a) =>  s a -> a -> m () () :: ( s m,   a) =>   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.*execState (do _1 .|.= 15; _2 .|.= 3) (7,7)(15,7) () :: ( s m,   a) =>  s a -> a -> m () () :: ( s m,   a) =>   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  G), returning the result (or a monoidal summary of all of the results)._2 <.|.~ 6 $ ("hello",3)(7,("hello",7)) () ::   a => $ s t a a -> a -> s -> (a, t) () ::   a => &# s t a a -> a -> s -> (a, t) () :: (  a,  a) =>   s t a a -> a -> s -> (a, t) Bitwise   the target(s) of a & or  F, returning the result (or a monoidal summary of all of the results)._2 <.&.~ 7 $ ("hello",254)(6,("hello",6)) () ::   a => $ s t a a -> a -> s -> (a, t) () ::   a => &# s t a a -> a -> s -> (a, t) () :: (  a,  a) =>   s t a a -> a -> s -> (a, t) Modify the target(s) of a % (or ) by computing its bitwise  c with another value, returning the result (or a monoidal summary of all of the results traversed).runState (_1 <.&.= 15) (31,0) (15,(15,0)) () :: ( s m,   a) => % s a -> a -> m a () :: ( s m,   a,  a) =>  s a -> a -> m a Modify the target(s) of a %, (or  ) by computing its bitwise  c with another value, returning the result (or a monoidal summary of all of the results traversed).runState (_1 <.|.= 7) (28,0) (31,(31,0)) () :: ( s m,   a) => % s a -> a -> m a () :: ( s m,   a,  a) =>  s a -> a -> m a This &< 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 4False15 & bitAt 4 .~ True3116 & bitAt 4 .~ False0,Get the nth byte, counting from the low end. n is a legal & into b iff 0   n     (  (  :: b)) 8(0xff00 :: Word16)^.byteAt 00(0xff00 :: Word16)^.byteAt 1255 byteAt 1 .~ 0 $ 0xff00 :: Word160byteAt 0 .~ 0xff $ 0 :: Word16255)Traverse over all bits in a numeric type.+The bit position is available as the index.toListOf bits (5 :: Word8)/[True,False,True,False,False,False,False,False]If you supply this an !, the result will be an infinite  ;, which can be productively consumed, but not reassembled.BTraverse over all the bytes in an integral type, from the low end.,The byte position is available as the index.(toListOf bytewise (1312301580 :: Word32) [12,34,56,78]If you supply this an !, the result will be an infinite  ;, which can be productively consumed, but not reassembled.Why is'nt this function called bytes to match 5? Alas, there is already a function by that name in Data.ByteString.Lens. 9(C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portableNone3 (or ) a list of bytes into a q  "a    x "a x    x "a x    "[104,101,108,108,111]^.packedBytes"hello" (or ) a q into a list of bytes  "a    x "a x    x "a x    ""hello"^.packedChars.unpackedBytes[104,101,108,108,111] Traverse each t in a q.This   walks the q in a tree-like fashion enable zippers to seek to locations in logarithmic time and accelerating many monoidal queries, but up to associativity (and constant factors) it is equivalent to the much slower:   "a    *anyOf bytes (== 0x80) (Char8.pack "hello")False$Note that when just using this as a , 1  can be more efficient.! (or ) a list of characters into a qWhen writing back to the q it is assumed that every  lies between '\x00' and '\xff'. ! "a  "  x "a x  !  x "a x   ! c"hello"^.packedChars.each.re (base 16 . enum).to (\x -> if Prelude.length x == 1 then '0':x else x) "68656c6c6f"" (or ) a list of characters into a qWhen writing back to the q it is assumed that every  lies between '\x00' and '\xff'. " "a  !  x "a x  "  x "a x   " 0[104,101,108,108,111]^.packedBytes.unpackedChars"hello"##Traverse the individual bytes in a q as characters.When writing back to the q it is assumed that every  lies between '\x00' and '\xff'.This   walks the q in a tree-like fashion enable zippers to seek to locations in logarithmic time and accelerating many monoidal queries, but up to associativity (and constant factors) it is equivalent to the much slower: # = "   anyOf chars (== 'h') "hello"True !"# !"# !"# !"#:(C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portableNone3$ (or ) a list of bytes into a r. $ "a  %  x "a x  $  x "a x   $ 8[104,101,108,108,111]^.packedBytes == Char8.pack "hello"True% (or ) a r into a list of bytes % "a  $  x "a x  %  x "a x   % ""hello"^.packedChars.unpackedBytes[104,101,108,108,111]&#Traverse the individual bytes in a r.This   walks each strict r chunk in a tree-like fashion enable zippers to seek to locations more quickly and accelerate many monoidal queries, but up to associativity (and constant factors) it is equivalent to the much slower: & "a %   *anyOf bytes (== 0x80) (Char8.pack "hello")False$Note that when just using this as a , 1  can be more efficient.'  (or  ) a list of characters into a r.When writing back to the r it is assumed that every  lies between '\x00' and '\xff'. ' "a  (  x "a x  '  x "a x   ' c"hello"^.packedChars.each.re (base 16 . enum).to (\x -> if Prelude.length x == 1 then '0':x else x) "68656c6c6f"(  (or  ) a list of characters into a rWhen writing back to the r it is assumed that every  lies between '\x00' and '\xff'. ( "a  '  x "a x  (  x "a x   ( 0[104,101,108,108,111]^.packedBytes.unpackedChars"hello")#Traverse the individual bytes in a r as characters.When writing back to the r it is assumed that every  lies between '\x00' and '\xff'.This   walks each strict r chunk in a tree-like fashion enable zippers to seek to locations more quickly and accelerate many monoidal queries, but up to associativity (and constant factors) it is equivalent to: ) = (   anyOf chars (== 'h') "hello"True$%&'()$%&'()$%&'()$%&'();(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portableNone3*Traversals for ByteStrings.+ (or () a list of bytes into a strict or lazy q.  x "a x  +  x "a x   + + "a  / , (or -) a list of characters into a strict or lazy q.When writing back to the q it is assumed that every  lies between '\x00' and '\xff'.  x "a x  ,  x "a x   , , "a  0 -Traverse each t in a strict or lazy qThis   walks each strict q chunk in a tree-like fashion enable zippers to seek to locations more quickly and accelerate many monoidal queries, but up to associativity (and constant factors) it is equivalent to the much slower: - "a /   1 - ( 0x80) :: q ->  .2Traverse the individual bytes in a strict or lazy q as characters.When writing back to the q it is assumed that every  lies between '\x00' and '\xff'.This   walks each strict q chunk in a tree-like fashion enable zippers to seek to locations more quickly and accelerate many monoidal queries, but up to associativity (and constant factors) it is equivalent to the much slower: . "a 0   1 . ( 'c') :: q ->  / (or ) a q into a list of bytes / "a  +  x "a x  /  x "a x   / / ::     [t] / ::     [t] 0 (or /) a list of characters into a strict (or lazy) qWhen writing back to the q it is assumed that every  lies between '\x00' and '\xff'. 0 "a  ,  x "a x  0  x "a x   0 0 ::      0 ::      *+,-./0 *+,-./0*+,-./0*+,-./0 <(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portableNone31 Access the   of a  x number.(a :+ b)^._realPartaa :+ b & _realPart *~ 2 a * 2 :+ b 1 ::  f => (a -> f a) ->  x a -> f ( x a)2 Access the   of a  x number.(a :+ b)^._imagPartba :+ b & _imagPart *~ 2 a :+ b * 2 2 ::  f => (a -> f a) ->  x a -> f ( x a)3 This isn't quite a legal & . Notably the  l (7 l b a) = blaw is violated when you set a   value with 0   and non-zero   as the  ) information is lost, or with a negative   which flips the   and retains a positive  . So don't do that!)Otherwise, this is a perfectly cromulent &.4 Access the   of a  x number. (10.0 :+ 20.0) & _magnitude *~ 2 20.0 :+ 40.0 This isn't quite a legal & . Notably the  l (7 l b a) = b(law is violated when you set a negative  . This flips the   and retains a positive  . So don't do that!)Otherwise, this is a perfectly cromulent &. Setting the   of a zero  x number assumes the   is 0.5 Access the   of a  x number.4(mkPolar 10 (2-pi) & _phase +~ pi & view _phase) "H 2True This isn't quite a legal & . Notably the  l (7 l b a) = blaw is violated when you set a   outside the range (- ,  ]D. The phase is always in that range when queried. So don't do that!)Otherwise, this is a perfectly cromulent &.6 Access the   of a  x number.*(2.0 :+ 3.0) & _conjugate . _imagPart -~ 1 2.0 :+ 4.02(mkPolar 10.0 2.0 ^. _conjugate . _phase) "H (-2.0)True123456123456123456123456=(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportableNoneHM7 IntSet isn't Foldable, but this ) can be used to access the members of an  .&sumOf members $ setOf folded [1,2,3,4]108This * 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 SetZ, because the number of elements might change but you can manipulate it by reading using  and reindexing it via 8.(over setmapped (+1) (fromList [1,2,3,4])fromList [2,3,4,5]9 Construct an   from a , ,  , & or .setOf folded [1,2,3,4]fromList [1,2,3,4]5setOf (folded._2) [("hello",1),("world",2),("!!!",3)]fromList [1,2,3] 9 ::  s 6 -> s ->   9 ::  s 6 -> s ->   9 ::   s 6 -> s ->   9 :: % s 6 -> s ->   9 ::  s 6 -> s ->   789789789789>(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportableNone3HM:A  / stripping a prefix from a list when used as a  0, or prepending that prefix when run backwards:"preview" ^? prefixed "pre" Just "view""review" ^? prefixed "pre"Nothingprefixed "pre" # "amble" "preamble";A  / stripping a suffix from a list when used as a  /, or appending that suffix when run backwards:"review" ^? suffixed "view" Just "re""review" ^? suffixed "tire"Nothingsuffixed ".o" # "hello" "hello.o":;<:;<:;<:;<?(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portableNone3HM=A  is isomorphic to a     m "a m  =Seq.fromList [a,b,c] ^. viewLa :< fromList [b,c]Seq.empty ^. viewLEmptyLEmptyL ^. from viewL fromList []&review viewL $ a Seq.:< fromList [b,c]fromList [a,b,c]>A  is isomorphic to a     m "a m  >Seq.fromList [a,b,c] ^. viewRfromList [a,b] :> cSeq.empty ^. viewREmptyREmptyR ^. from viewR fromList []&review viewR $ fromList [a,b] Seq.:> cfromList [a,b,c]?Traverse the first n elements of a #fromList [a,b,c,d,e] ^.. slicedTo 2[a,b]&fromList [a,b,c,d,e] & slicedTo 2 %~ ffromList [f a,f b,c,d,e]'fromList [a,b,c,d,e] & slicedTo 10 .~ xfromList [x,x,x,x,x]@Traverse all but the first n elements of a %fromList [a,b,c,d,e] ^.. slicedFrom 2[c,d,e](fromList [a,b,c,d,e] & slicedFrom 2 %~ ffromList [a,b,f c,f d,f e])fromList [a,b,c,d,e] & slicedFrom 10 .~ xfromList [a,b,c,d,e]A(Traverse all the elements numbered from i to j of a &fromList [a,b,c,d,e] & sliced 1 3 %~ ffromList [a,f b,f c,d,e]B Construct a  from a , f, d, h or ].seqOf folded ["hello","world"]fromList ["hello","world"]5seqOf (folded._2) [("hello",1),("world",2),("!!!",3)]fromList [1,2,3] B ::  s a -> s ->  a B ::  s a -> s ->  a B ::   s a -> s ->  a B :: % s a -> s ->  a B ::  s a -> s ->  a =>?@AB=>?@AB=>A?@B=>?@AB@(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalMTPCsNone3CA & that focuses on the root of a  k.view root $ Node 42 []42DA &3 returning the direct descendants of the root of a  k  D "a  CDCDCDCDA(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental Rank2TypesNoneHMEA  for working with a   of a Y value.FA  for working with a   of a Y value.EFEFEFEFB(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional non-portable Trustworthy36HMG sliced i n provides a & that edits the n elements starting at index i from a &.This is only a valid &3 if you do not change the length of the resulting  i.RAttempting to return a longer or shorter vector will result in violations of the & laws.DVector.fromList [1..10] ^. sliced 2 5 == Vector.fromList [3,4,5,6,7]True^(Vector.fromList [1..10] & sliced 2 5 . mapped .~ 0) == Vector.fromList [1,2,0,0,0,0,0,8,9,10]TrueH Similar to -, but returning a  i.0toVectorOf both (8,15) == Vector.fromList [8,15]TrueIConvert a list to a  i (or back),[1,2,3] ^. vector == Vector.fromList [1,2,3]True[1,2,3] ^. vector . from vector[1,2,3]LVector.fromList [0,8,15] ^. from vector . vector == Vector.fromList [0,8,15]TrueJ Convert a  i4 to a version that doesn't retain any extra memory.KThis  = will ignore any duplicates in the supplied list of indices.>toListOf (ordinals [1,3,2,5,9,10]) $ Vector.fromList [2,4..40][4,8,6,12,20,22]Gi starting indexn lengthHIJKGHIJKHIJGKGHIJKC(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimentalGHCNone3HJKMLUsed to traverse [ data by uniplate.M:Convert from the data type to its representation (or back)'"hello"^.generic.from generic :: String"hello"N:Convert from the data type to its representation (or back)OA [  , that visits every occurrence of something Y anywhere in a container.BallOf tinplate (=="Hello") (1::Int,2::Double,(),"Hello",["Hello"])True:mapMOf_ tinplate putStrLn ("hello",[(2 :: Int, "world!")])helloworld! L MNO LMNOMNOL L MNO D(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimentalGHCNone3HJKMW:You can access fields of `data (f :*: g) p` by using it's  and  instancesPQRSTUVW LMNOPQRSTUVWPQRSTUVWPQRSTUVWE(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental Rank2TypesNone X'Modify the path by adding another path.#both </>~ "bin" $ ("hello","world")("hello/bin","world/bin") (X) ::  s a     ->   -> s -> a (X) ::  s a     ->   -> s -> a (X) :: & s a     ->   -> s -> a (X) ::   s a     ->   -> s -> a YModify the target(s) of a %,  ,  or  by adding a path.-execState (both </>= "bin") ("hello","world")("hello/bin","world/bin") (Y) ::  s m =>  s   ->   -> m () (Y) ::  s m =>   s   ->   -> m () (Y) ::  s m => % s   ->   -> m () (Y) ::  s m =>  s   ->   -> m () Z+Add a path onto the end of the target of a & and return the result3When you do not need the result of the operation, (X) is more flexible.[+Add a path onto the end of the target of a &0 into your monad's state and return the result.3When you do not need the result of the operation, (Y) is more flexible.^'Modify the path by adding an extension.#both <.>~ "txt" $ ("hello","world")("hello.txt","world.txt") (^) ::  s a     ->  -> s -> a (^) ::  s a     ->  -> s -> a (^) :: & s a     ->  -> s -> a (^) ::   s a     ->  -> s -> a _Modify the target(s) of a %,  ,  or  by adding an extension.-execState (both <.>= "txt") ("hello","world")("hello.txt","world.txt") (_) ::  s m =>  s   ->  -> m () (_) ::  s m =>   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"_1 <<.>~ "txt" $ ("hello","world")#("hello.txt",("hello.txt","world"))3When you do not need the result of the operation, (^) is more flexible.a1Add an extension onto the end of the target of a &0 into your monad's state and return the result.,evalState (_1 <<.>= "txt") ("hello","world") "hello.txt"3When you do not need the result of the operation, (_) is more flexible.b1Add an extension onto the end of the target of a & but return the old value#_1 <<<.>~ "txt" $ ("hello","world")("hello",("hello.txt","world"))%When you do not need the old value, (^) is more flexible.dA &( for reading and writing to the basenameNote: This is  a legal & unless the outer  | has both a directory and filename component and the generated basenames are not null and contain no directory separators.(basename .~ "filename" $ "path/name.png""path/filename.png"eA &) for reading and writing to the directoryNote: this is not a legal & unless the outer  L already has a directory component, and generated directories are not null.!"long/path/name.txt" ^. directory "long/path"fA &) for reading and writing to the extensionNote: This is not a legal &=, unless you are careful to ensure that generated extension  * components are either null or start with   " and do not contain any internal   s.%extension .~ ".png" $ "path/name.txt""path/name.png"gA &- for reading and writing to the full filenameNote: This is not a legal &<, unless you are careful to ensure that generated filename  = components are not null and do not contain any elements of   s.(filename .~ "name.txt" $ "path/name.png""path/name.txt"XYZ[\]^_`abcdefgXYZ[\]^_`abcdefgXZ\^`bY[]_acdefgXYZ[\]^_`abcdefg XYZ[\]^_`abcF(C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental Rank2TypesNone2346hWhere the error happened.i Error type specific information.j2The handle used by the action flagging this error.kk the error is related to.ll leading to this error, if any.mWhat type of error it ishijklmnopqrstuvwxyz{|}~hijklmnopqrstuvwxyz{|}~hijklmnopqrstuvwxyz{|}~hijklmnopqrstuvwxyz{|}~G(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportableNoneHMThis  * can be used to model the fact that every  type is a subset of .Embedding through the   only succeeds if the 2 would pass through unmodified when re-extracted.?A prism that shows and reads integers in base-2 through base-36LNote: This is an improper prism, since leading 0s are stripped when reading."100" ^? base 16Just 256 1767707668033969 ^. re (base 36) "helloworld" Like , but handles up to base-36 Like , but handles up to base-36 A safe variant of  +Select digits that fall into the given base A simpler variant of > that only prepends a dash and doesn't know about parentheses A simpler variant of \ that supports any base, only recognizes an initial dash and doesn't know about parentheses  =  2  =  8  =  10  =  16  n =  (+n) (subtract n)[1..3]^..traverse.adding 1000[1001,1002,1003]  n =  (subtract n) ((+n)  n =  ( n)   n = iso (*n) (/n)Note: This errors for n = 05 & multiplying 1000 +~ 35.003Dlet fahrenheit = multiplying (9/5).adding 32 in 230^.from fahrenheit110.0   n =  (/n) (*n)  n =  ( n)Note: This errors for n = 0  n =  (**n) (**recip n)Note: This errors for n = 0Hau (_Wrapping Sum . from (exponentiating 2)) (foldMapOf each) (3,4) == 5True  =  Z Z8au (_Wrapping Sum . negated) (foldMapOf each) (3,4) == 7True9au (_Wrapping Sum) (foldMapOf (each.negated)) (3,4) == -7True    H(C) 2012-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalControl.Exception Trustworthy246HM9This   is thrown by lens7 when the user somehow manages to rethrow an internal .%There is no information carried in a .  ::    ()  ::     () #This is thrown when the user calls .Retrieve the argument given to .  is isomorphic to a .0catching _ErrorCall (error "touch down!") return "touch down!"A record update was performed on a constructor without the appropriate field. This can only happen with a datatype with multiple constructors, where some fields are in one constructor but not another.CInformation about the source location where the record was updated.A record selector was applied to a constructor without the appropriate field. This can only happen with a datatype with multiple constructors, where some fields are in one constructor but not another.JInformation about the source location where the record selection occurred.'An uninitialised record field was used.HInformation about the source location where the record was constructed.  ::       ::      A pattern match failed.5Information about the source location of the pattern.  ::       ::      }A class method without a definition (neither a default definition, nor a definition in the appropriate instance) was called.,Extract a description of the missing method.  ::       ::      BThere are no runnable threads, so the program is deadlocked. The    # is raised in the main thread only.%There is no information carried in a    .  ::     ()  ::     () "The thread is waiting to retry an c transaction, but there are no other references to any TVars involved, so it can't ever continue.0There is no additional information carried in a    .  ::     ()  ::     () The thread is blocked on an ,, but there are no other references to the  so it can't ever continue.0There is no additional information carried in a    .  ::     ()  ::     () ?Thrown when the program attempts to call atomically, from the , package, inside another call to atomically.0There is no additional information carried in a    .  ::     ()  ::     () Thrown when the runtime system detects that the computation is guaranteed not to terminate. Note that there is no guarantee that the runtime system will notice whether any given computation is guaranteed to terminate or not.0There is no additional information carried in a    .  ::     ()  ::     () Asynchronous exceptions.There are several types of  .  ::       ::         was applied to .This  B contains provides information about what assertion failed in the .zhandling _AssertionFailed (\ xs -> "caught" <$ guard ("<interactive>" `isInfixOf` xs) ) $ assert False (return "uncaught")"caught"  ::       ::      )Exceptions generated by array operations.Extract information about an  .  ::        ::       Arithmetic exceptions.Exceptions that occur in the IO . An  z records a more specific error type, a descriptive string and maybe the handle that was used when the error was flagged.nDue to their richer structure relative to other exceptions, these have a more carefully overloaded signature.Unfortunately the name  ioException is taken by base for throwing IOExceptions.  ::        ::       %Many combinators for working with an   are available in System.IO.Error.Lens.Traverse the strongly typed   contained in  6 where the type of your function matches the desired  .  :: (( f,   a) => (a -> f a) ->   -> f   $Catch exceptions that match a given   (or any  , really).Ucatching _AssertionFailed (assert False (return "uncaught")) $ \ _ -> return "caught""caught"  ::   m =>    # a -> m r -> (a -> m r) -> m r  ::   m => %  $ a -> m r -> (a -> m r) -> m r  ::   m =>    a -> m r -> (a -> m r) -> m r  ::   m =>    % a -> m r -> (a -> m r) -> m r  ::   m =>   # a -> m r -> (a -> m r) -> m r  ::   m =>   % a -> m r -> (a -> m r) -> m r $Catch exceptions that match a given   (or any \), discarding the information about the match. This is particuarly useful when you have a   e () where the result of the   or = isn't particularly valuable, just the fact that it matches.Ocatching_ _AssertionFailed (assert False (return "uncaught")) $ return "caught""caught"  ::   m =>     a -> m r -> m r -> m r  ::   m => %   a -> m r -> m r -> m r  ::   m =>    a -> m r -> m r -> m r  ::   m =>     a -> m r -> m r -> m r  ::   m =>    a -> m r -> m r -> m r  ::   m =>    a -> m r -> m r -> m r  A version of d with the arguments swapped around; useful in situations where the code for the handler is shorter.Ihandling _NonTermination (\_ -> return "caught") $ throwIO NonTermination"caught"  ::   m =>    # a -> (a -> m r) -> m r -> m r  ::   m => %  $ a -> (a -> m r) -> m r -> m r  ::   m =>    a -> (a -> m r) -> m r -> m r  ::   m =>    % a -> (a -> m r) -> m r -> m r  ::   m =>   % a -> (a -> m r) -> m r -> m r  ::   m =>   # a -> (a -> m r) -> m r -> m r  A version of d with the arguments swapped around; useful in situations where the code for the handler is shorter.Dhandling_ _NonTermination (return "caught") $ throwIO NonTermination"caught"  ::   m =>     a -> m r -> m r -> m r  ::   m => %   a -> m r -> m r -> m r  ::   m =>    a -> m r -> m r -> m r  ::   m =>     a -> m r -> m r -> m r  ::   m =>    a -> m r -> m r -> m r  ::   m =>    a -> m r -> m r -> m r  A variant of  that takes a   (or any /) to select which exceptions are caught (c.f. ,  ). If the  / does not match the predicate, it is re-thrown.  ::   m =>     a -> m r -> m ( a r)  ::   m => %   a -> m r -> m ( a r)  ::   m =>    a -> m r -> m ( a r)  ::   m =>     a -> m r -> m ( a r)  ::   m =>    a -> m r -> m ( a r)  ::   m =>    a -> m r -> m ( a r)  A version of - that discards the specific exception thrown.  ::   m =>     a -> m r -> m (Maybe r)  ::   m => %   a -> m r -> m (Maybe r)  ::   m =>    a -> m r -> m (Maybe r)  ::   m =>     a -> m r -> m (Maybe r)  ::   m =>    a -> m r -> m (Maybe r)  ::   m =>    a -> m r -> m (Maybe r)  Throw an   described by a  [. Exceptions may be thrown from purely functional code, but may only be caught within the IO .  l "a  l    ::     t -> t -> r  ::     t -> t -> r  A variant of " that can only be used within the IO  (or any other   instance) to throw an   described by a  . Although 5 has a type that is a specialization of the type of ), the two functions are subtly different:  l e `seq` x "a  e  l e `seq` x "a x !The first example will cause the   e7 to be raised, whereas the second one won't. In fact,  will only cause an  * to be raised when it is used within the   instance. The * variant should be used in preference to  to raise an   within the S because it guarantees ordering with respect to other monadic operations, whereas  does not.  l "a  l   ::   m =>     t -> t -> m r  ::   m =>     t -> t -> m r  raises an   specified by a   in the target thread.  thread l "a  l (  thread)  ::   ->     t -> t -> m a  ::   ->     t -> t -> m a This $ can be used to purely map over the  ;s an arbitrary expression might throw; it is a variant of   in the same way that - is a variant of 9. )'mapException' "a 'over' 'mappedException'NThis view that every Haskell expression can be regarded as carrying a bag of  [s is detailed in A Semantics for Imprecise Exceptions  by Peyton Jones & al. at PLDI 99.<The following maps failed assertions to arithmetic overflow:handling _Overflow (\_ -> return "caught") $ assert False (return "uncaught") & mappedException %~ \ (AssertionFailed _) -> Overflow"caught"%This is a type restricted version of 0, which avoids the type ambiguity in the input   when using 7.8The following maps any exception to arithmetic overflow:lhandling _Overflow (\_ -> return "caught") $ assert False (return "uncaught") & mappedException' .~ Overflow"caught"Handle arithmetic .  "a     ::        ::       Handle arithmetic .  "a     ::        ::       $Handle arithmetic loss of precision.  "a     ::        ::       Handle division by zero.  "a     ::        ::       /Handle exceptional _Denormalized floating pure.  "a     ::        ::        Added in base. 4.6 in response to this libraries discussion: Mhttp://haskell.1045720.n5.nabble.com/Data-Ratio-and-exceptions-td5711246.html  "a     ::        ::       BAn attempt was made to index an array outside its declared bounds.  "a     ::       ::      UAn attempt was made to evaluate an element of an array that had not been initialized.  "a     ::       ::      8The current thread's stack exceeded its limit. Since an   has been raised, the thread's stack will certainly be below its limit again, but the programmer should take remedial action immediately.  ::     ()  ::     () wThe program's heap is reaching its limit, and the program should take action to reduce the amount of live data it has.Notes:+It is undefined which thread receives this  .GHC currently does not throw   exceptions.  ::     ()  ::     () This  & is raised by another thread calling  H, or by the system if it needs to terminate the thread for some reason.  ::     ()  ::     () This   is raised by default in the main thread of the program when the user requests to terminate the program via the usual mechanism(s) (e.g. Control-C in the console).  ::     ()  ::     () ]                 ==L                 I(C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portableNone36Any   can be thrown as an  This  8 allows you to traverse the typed value contained in a  O where the type required by your function matches that of the contents of the  , or construct a  D value out of whole cloth. It can also be used to catch or throw a   value as  .  :: Y a =>     a  :: Y a =>     a     J(C) 2013-15 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalControl.ExceptionNone246*Exit codes that a program can return with:!indicates successful termination;  ::     ()  ::     () indicates program failure with an exit code. The exact interpretation of the code is operating-system dependent. In particular, some values may be prohibited (e.g. 0 on a POSIX-compliant system).  ::     6  ::     6      !"#$%&'%&($$)*$)+$)+,-.,-/012012013%&45675685695:;5:<5:=5:>?@A?@B?@C?@D?@E?@F?@G?@GHIJHIK L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r st u u v w w x y z z { | | } ~ ~                     coo                           mlgfkj\ ]    Zedih !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~{PQR~vqst     rY !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abpcdefghijkzlmnopqrstuvwxyz{|}~\] Zgfkjdeih       !!!!! ! ! ! ! !!!!!!!!!!!!!!!!!!! !!!"!#!!$!%!&!'!(!)!*!+!,!-"."/"0"1"2"3"4"5#6#7#8#8#9#:#;#<#=#>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\$]$^$_$`$a$b$c$d$e$f$g$h$i$$%j%k%l%m%n%o%p%q%r%s%t&u&v&w&x&y&z'u'v'w'x'y'z({(u(x(y(v(w))*|*}+~+++++++++++++,,,,,,-------------............................................................................................................ . . . . ................... .!.".#.$.%.&.'.(.).*.+.,.-.../.0.1.2.3.4.5.6.7.8.9.:.;.<.=.>.?.@.A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R/S/T/U/V/V/W/X/Y/Z/[/\/]/^/_/`0a0b0c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1{1|1}1~11112222234444444445555678888888888888888999999::::::;;;;;;;<<w<<<<===>>>?????j?@@AABjBkBlBpBqCCCCDDDDDDDDEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFFFFFFFFFFFFGG$GGGGGGGGGGHHHHHHHHHHHHHHHH H H H H HHHHHHHHHHHHHHHHHHHHHHHHHHH H!H"H#H$H%H&H'HH(H)H*I+I,J-J.J/J0L1L2L3L4L5L6L7L8L9L:L;L<L= >?@A?BC?BD$$EF$GH0IJ0KL M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | }$~   $)$!55$~      !"#$%&'()*+,-./0123456$G7 8 9 : ; < = > ? @ A B C D E$)F$~G$~$H$~I$~J$~K$LM$NO$NP$QR!ST!U!SVWXY$ZW[\W[]W[^$~_$~`!a$bcWXd$~e$Ef$$Eghijklmnopqrstuvwxyz{|}~WW[WX$G$$$$000`a0X0O00T!S!S$|}$|$$$$N$!S$$$$$|$|$ $| $| ! $| $|$|$|$$|$$|$|$|$|$|u$|$|$|$)$|$$$$ $!$"$#$$$%!!S&$'$G($)$*!+$|,$|-$|.$/$|/$0$|0$|1$|2$|3$|4$G5$~$6789$:I$:J$;$<$=$>$?$)@$)A$0BC$$6D0`E0`d$F$GH!SI$,JKkLMNOPQRSTUVWXY00Z1$$u$=[\]^9_`abcdefghijklmnopqrstuvwxyz{|}~$)$$ $                                     $$L$!!!!!!!!!!!!!!!!!!!!!  "$""""""""""""""$!! $6 $6        $ $ Z$  $  $ $  $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ !$ "$ #$ $$ %$ &$ '$ ($ )$ *$ +$ ,$ -$ .$ /$ 0$ 1$ 2$ 3$ 4$ 5$ 6$ 7$ 8$ 9$ :$ ;$ <$ =$ >$ ?$ @$ A$ B$ C$ D$ E$ F$ G$ H$ I$ J$ K$ L$ M$ N$ O$ P$ Q$ R$ S$ T$ U$ V$ W$ X$ Y$ Z$ [$ \$ ]$ ^$ _$ `$ a$ b$ c$ d$ e$ f$ g$ h$ i$ j$ k$ l$ m$ n$ o$ p$ q$ r$ s$ t$ u$ v$ w$ x$ y$ z$ {$ |$ }$ ~$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $         & &   ' ' ( ( ( ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) * $    $  * * * * * *   * $   *   *  *   * * * * * *   * Z* * $Q $xy* * * * * * * * $ + + + + + + + + + + + + + + + + + + + + + + $) , , , , , , , , , , , , , !, ", #, $, %, &, ', (, ), *- +- ,- -- .- /- 0- 1- 2- 3  4 5- 6- 7- 8- 9- :- ;- <- =- >- ?- @- A- B- C- D- E- F- G- H- I- J- K- L- M- N- O- P- Q- R- S- T- U- V- W- X- Y- Z- [- \- ]- ^- _- `- a- b- c- d- e- f- g- h- i- j- k- l- m- n- o- p- q- r- s- t- u- v- w- x- y- z- {- |- }- ~- - - - - - - - - - - - - - - - - - - - - - ?B ?B . . . . . . . . . . . . . . . . / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 0 0 ?B 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ?B 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 $ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 $   $ $~ $$  !  $~ 2 2 2 2 2 2 2 2 W  W  44 4 4 4 4 4 ! " # $ " # % " # & " # ' " # ( " ) * + 4 ,$ - .$ - /$ - 0!S 1!S 2$ - 3$) 4$N 5; 6; 7$x 8$x 9$x :$x ;$x <$Q =$x >  ?\ @\ A\ B\ C D$$ EC FC GC HC IC JC KC LC M$ NG OG PG QG RG SG T$  U$ V W$ V X$ V Y$ Z [$ Z \$ Z ]$ V ^$ V _$ Z `$~ a$ Z b$ Z c$ Z d  e$   f$ g h$ g i$ V j$  k$ Z lH mH nH oH pH qH rH sH tH uH vH wH xH yH zH {H |H }H ~H H H H H H H H H H H H H H H H H $  I I $ Z J J lens-4.13Control.Lens.Internal.CoerceControl.Lens.TraversalControl.Lens.GetterControl.Lens.ReviewControl.Lens.SetterControl.Lens.PrismControl.Lens.IsoControl.Lens.FoldControl.Lens.Internal.FoldControl.Lens.Internal.ListControl.Lens.Internal.THControl.Lens.Internal.ZoomControl.Lens.Internal.SetterControl.Lens.Internal.ReviewControl.Lens.Internal.PrismControl.Lens.Internal.IsoControl.Lens.Internal.LevelControl.Lens.Internal.IndexedControl.Lens.Internal.ContextControl.Lens.Internal.BazaarControl.Lens.Internal.MagmaControl.Lens.Internal.GetterControl.Lens.TypeControl.Lens.LensControl.Lens.TupleControl.Lens.Zoom Data.Set.LensData.HashSet.LensControl.Lens.IndexedControl.Lens.LevelControl.Lens.ReifiedData.Data.LensControl.Lens.Plated Control.Lens.Internal.ByteStringControl.Lens.EqualityControl.Lens.WrappedData.Vector.Generic.LensData.Text.Strict.LensData.Text.Lazy.LensData.Text.LensControl.Lens.EmptyControl.Lens.EachControl.Lens.ConsControl.Lens.Internal.DequeControl.Lens.AtLanguage.Haskell.TH.LensControl.Lens.Internal.FieldTHControl.Lens.Internal.PrismTHControl.Lens.THControl.Lens.Internal.ExceptionControl.Lens.ExtrasControl.Monad.Error.Lens Control.Parallel.Strategies.LensControl.Seq.LensData.Array.LensData.Bits.LensData.ByteString.Strict.LensData.ByteString.Lazy.LensData.ByteString.LensData.Complex.LensData.IntSet.LensData.List.LensData.Sequence.LensData.Tree.LensData.Typeable.LensData.Vector.LensGenerics.Deriving.LensGHC.Generics.LensSystem.FilePath.LensSystem.IO.Error.Lens Numeric.LensControl.Exception.LensData.Dynamic.LensSystem.Exit.Lens Data.Map.Lens Paths_lensControl.Lens.Internal.InstancesControl.Monad.RWSRWSTMagnifyZoomzoomControl.Monad.ErrorErrorTControl.Monad.WriterWriterTControl.Monad.StateStateT backwardsSetterAccessorPrismIso Data.IntMapIntMapControl.Monad.Trans.State.LazyState indexed64indexed TraversalIndexedTraversalFold IndexedFoldLens IndexedLensGetter IndexedGetterLensLikeOvercloneBazaartakinglastOfpreview maximumOf minimumOfmapM_ traverseOf_ _imagPart Data.ComplexComplex traversedGetting Data.FoldableFoldable foldMapOf Data.MonoidMonoidrereview^?Data.TraversabletraverselengthOfNumeric.NaturalNaturalprismoutsideData.Text.InternalTextsetviewover TraversableData.Functor.Compose getComposeCompose fmapDefaultuse_2atimap Traversal'Setter'^..~%~+~Iso'-~*~//~^~^^~**~||~&&~<>~%=+=-=*=//=^=^^=**=||=&&=.=<>=%@~ withIndex<.~<.=anyOf Data.Functor<$> ifoldMapOffromcloneTraversal Data.Typeablecast_EmptyAsEmptyControl.Monad.Reader.ClasslocalfoldedPreludeunfoldr_1 traverseOf_LeftforOf Data.Listfoldl1' Control.MonadMonadControl.TraversableControl.Lens.Isomorphic itraverseOfimapMOfiforMOf elemIndex elemIndices findIndex findIndicesifor transposeuniplatebiplate contextsOfControl.Comonad.Store.ClasspospeekReifiedTraversal runTraversalControl.Lens.IndexedTraversalmap mapAccumR mapAccumLplate Data.Just isNothingextractIndexedB Bytestring cloneLensalaalafData.MapMapjoin Data.TextData.Text.LazySimpleControl.ExceptionHandler_AssertionFailed _ErrorCallPrism'Lens'_NonTermination_StackOverflowControl.Lens.Internal Control.LensControl.Lens.CombinatorsControl.Lens.OperatorscatchesData.ByteStringpackunpackData.ByteString.Char8Data.ByteString.LazyData.ByteString.Lazy.Char8 ByteStringSystem.FilePath extSeparatorpathSeparators Data.Char intToDigit digitToIntNumeric showSigned readSignederrorControl.Monad.STMSTMControl.Concurrent.MVarMVarFalsetrytryJust catchJustCatchIOthrowControl.Concurrent killThreadghc-primGHC.Primcoercebasecontravariant-1.3.3Data.Functor.Contravariant contramap ContravariantControl.ApplicativegetConstConst bifunctors-5Data.Bifunctorbimap Bifunctortransformers-0.4.3.0Data.Functor.IdentityIdentity runIdentity>$profunctors-5.1.1Data.Profunctorright'left'ChoiceData.Profunctor.Unsafermaplmapdimap Profunctorreflection-2.1Data.Reflection sequenceBy traverseBy foldMapByfoldBy reifiedMemptyreifiedMappend ReifiedMonoidsemigroupoids-5.0.0.4 Data.Semigroup.Traversable.Class traverse1 Traversable1 ordinalNub tySynInstD'appsTappsE1toTupleTtoTupleEtoTuplePconAppsTbndrNamefromSetlensPackageKey mkLensName_tc mkLensName_vtraversalTypeNametraversal'TypeName lensTypeName lens'TypeName isoTypeName iso'TypeNamegetterTypeName foldTypeName prismTypeNameprism'TypeNamereviewTypeNamewrappedTypeNameunwrappedTypeNamerewrappedTypeName_wrapped'ValName isoValName prismValName untoValNamephantomValNamephantom2composeValName idValName fmapValName pureValName apValName rightDataName leftDataNamecoerce' EffectRWS getEffectRWSEffect getEffect Magnified FocusingErr unfocusingErrErrgetErr FocusingMay unfocusingMayMaygetMay FocusingOn unfocusingOn FocusingPlusunfocusingPlus FocusingWithunfocusingWithFocusing unfocusingZoomedSettable untainted untaintedDot taintedDot ReviewableretaggedMarket'Market Reversing reversingExchangeFlowsrunFlows Deepening runDeepeningLevelZeroOneTwo deepening Indexing64 runIndexing64Indexing runIndexing runIndexed Indexable Conjoineddistrib conjoinedindexing indexing64asIndex PretextT'PretextT runPretextTPretext'Pretext runPretextContext'ContextSellablesellIndexedComonadStoreiposipeekipeeksiseekiseeks iexperimentcontextIndexedComonadiextract iduplicateiextendIndexedFunctorifmap BazaarT1'BazaarT1 runBazaarT1Bazaar1'Bazaar1 runBazaar1Bizarre1bazaar1BazaarT'BazaarT runBazaarTBazaar' runBazaarBizarrebazaar TakingWhileMaficMolten runMoltenMagma MagmaFmap MagmaPureMagmaAprunMagmarunMaficrunTakingWhileAlongsideRightgetAlongsideRight AlongsideLeftgetAlongsideLeftnoEffect RightmostRStepRLeafRPureLeftmostLStepLLeafLPureMaxNoMaxMinNoMin Sequenced getSequenced Traversed getTraversedFolding getFoldinggetMingetMax getLeftmost getRightmostOver'IndexedLensLike'IndexedLensLike LensLike'Optical'OpticalOptic'OpticIndexPreservingFold1 IndexedFold1Fold1IndexPreservingFoldIndexPreservingGetterAs Equality'EqualityAReviewReviewIndexPreservingSetter'IndexPreservingSetterIndexedSetter' IndexedSetterIndexPreservingTraversal1'IndexPreservingTraversal1IndexPreservingTraversal'IndexPreservingTraversalIndexedTraversal1'IndexedTraversal1IndexedTraversal' Traversal1' Traversal1IndexPreservingLens'IndexPreservingLens IndexedLens'Setting'SettingAnIndexedSetter'AnIndexedSetterASetter'ASettermappedlifted contramappedargumentsettingsets cloneSettercloneIndexPreservingSettercloneIndexedSetterset'?~??insidechoosingchosen alongsidelocuscloneIndexPreservingLenscloneIndexedLens<%~<+~<-~<*~~<%=<+=<-=<*==<<~<<>~<<>=overA<%@~<<%@~%%@~%%@=<%@=<<%@=^#storing#~#%~#%%~#=#%=<#%~<#%=#%%=<#~<#=devoidunitedfusingField9_9Field8_8Field7_7Field6_6Field5_5Field4_4Field3_3Field2Field1_1'_2'_3'_4'_5'_6'_7'_8'_9' AccessingIndexedGettingtoitolikeilikeviewsuses listening ilistening listenings ilisteningsiviewiviewsiuseiuses^@.gettinguntoun#reviewsreusereusesAPrism'APrism withPrism clonePrismprism'withoutasidebelowisn'tmatching_Right_Just_Nothing_Voidonlynearly_Showmagnify setmappedsetOffoldingifoldingfoldring ifoldringfolded64repeated replicatedcycledunfoldediteratedfiltered takingWhile droppingWhilewordedlinedfoldOffoldrOffoldlOftoListOf^..andOforOfallOfnoneOf productOfsumOfforOf_ sequenceAOf_mapMOf_forMOf_ sequenceOf_asumOfmsumOfelemOf notElemOf concatMapOfconcatOf^?!firstOfnullOf notNullOf maximumByOf minimumByOffindOffindMOffoldr1Offoldl1OffoldrOf'foldlOf' foldr1Of' foldl1Of'foldrMOffoldlMOfhashasn'tpreipreipreviewpreviews ipreviewspreuseipreusepreusesipreusesifoldrOfifoldlOfianyOfiallOfinoneOf itraverseOf_iforOf_imapMOf_iforMOf_ iconcatMapOfifindOfifindMOf ifoldrOf' ifoldlOf' ifoldrMOf ifoldlMOf itoListOf^@..^@?^@?! elemIndexOf elemIndicesOf findIndexOf findIndicesOf ifiltered itakingWhileidroppingWhilefoldByOf foldMapByOf TraverseMax traverseMax TraverseMin traverseMin Traversing1' Traversing' Traversing1 TraversingAnIndexedTraversal1'AnIndexedTraversal'AnIndexedTraversal1AnIndexedTraversal ATraversal1' ATraversal1 ATraversal' ATraversal sequenceAOfmapMOfforMOf sequenceOf transposeOf mapAccumROf mapAccumLOfscanr1Ofscanl1OflociilocipartsOfipartsOfpartsOf' ipartsOf' unsafePartsOfiunsafePartsOfunsafePartsOf'iunsafePartsOf'holesOfsingularunsafeSingularbothbesidedroppingcloneIndexPreservingTraversalcloneIndexedTraversalcloneTraversal1cloneIndexPreservingTraversal1cloneIndexedTraversal1iforOf imapAccumROf imapAccumLOf traversed1 traversed64ignored elementOfelement elementsOfelementsfailover ifailoverfailingdeepOf confusing traverseByOf sequenceByOfTraversableWithIndex itraverse itraversedFoldableWithIndexifoldMapifoldedifoldrifoldlifoldr'ifoldl'FunctorWithIndeximapped<..> selfIndex reindexed<.>icomposeindicesindexianyiallinonenone itraverse_ifor_imapM_iforM_ iconcatMapifindifoldrMifoldlMitoListimapMiforM imapAccumR imapAccumL ifoldMapBy ifoldMapByOf itraverseBy itraverseByOflevelsilevels ReifiedPrism' ReifiedPrismrunPrism ReifiedIso' ReifiedIsorunIsoReifiedIndexedSetter'ReifiedIndexedSetterrunIndexedSetterReifiedSetter' ReifiedSetter runSetterReifiedIndexedFoldrunIndexedFold ReifiedFoldrunFoldReifiedIndexedGetterrunIndexedGetter ReifiedGetter runGetterReifiedTraversal'ReifiedIndexedTraversal'ReifiedIndexedTraversalrunIndexedTraversalReifiedIndexedLens'ReifiedIndexedLensrunIndexedLens ReifiedLens' ReifiedLensrunLens$fStrongReifiedIndexedFold!$fRepresentableReifiedIndexedFold $fSieveReifiedIndexedFoldCompose$fProfunctorReifiedIndexedFold$fFunctorReifiedIndexedFold$fPlusReifiedIndexedFold$fAltReifiedIndexedFold$fMonoidReifiedIndexedFold$fSemigroupReifiedIndexedFold$fPlusReifiedFold$fAltReifiedFold$fMonoidReifiedFold$fSemigroupReifiedFold$fMonadReadersReifiedFold$fMonadPlusReifiedFold$fMonadReifiedFold$fBindReifiedFold$fAlternativeReifiedFold$fApplicativeReifiedFold$fApplyReifiedFold$fFunctorReifiedFold$fArrowApplyReifiedFold$fArrowChoiceReifiedFold$fArrowReifiedFold$fCategory*ReifiedFold$fChoiceReifiedFold$fStrongReifiedFold$fRepresentableReifiedFold$fSieveReifiedFold[]$fProfunctorReifiedFold$fApplyReifiedIndexedGetter$fFunctorReifiedIndexedGetter$fStrongReifiedIndexedGetter#$fRepresentableReifiedIndexedGetter$fSieveReifiedIndexedGetter(,) $fProfunctorReifiedIndexedGetter$fArrowLoopReifiedGetter$fArrowChoiceReifiedGetter$fArrowApplyReifiedGetter$fArrowReifiedGetter$fCategory*ReifiedGetter$fChoiceReifiedGetter$fStrongReifiedGetter$fConjoinedReifiedGetter$fCostrongReifiedGetter$fRepresentableReifiedGetter$fSieveReifiedGetterIdentity$fCorepresentableReifiedGetter$fCosieveReifiedGetterIdentity$fProfunctorReifiedGetter$fMonadReadersReifiedGetter$fMonadReifiedGetter$fBindReifiedGetter$fApplicativeReifiedGetter$fApplyReifiedGetter$fComonadApplyReifiedGetter$fComonadReifiedGetter$fExtendReifiedGetter$fFunctorReifiedGetter$fDistributiveReifiedGetter gtraversetinplatetemplateuponupon'onceUpon onceUpon'GPlatedPlated...deepchildrenrewrite rewriteOf rewriteOn rewriteOnOfrewriteM rewriteMOf rewriteMOn rewriteMOnOfuniverse universeOf universeOn universeOnOfcosmoscosmosOfcosmosOn cosmosOnOf transform transformOn transformOf transformOnOf transformM transformMOn transformMOftransformMOnOfcontexts contextsOn contextsOnOfholesholesOn holesOnOfparaOfpara composOpFoldpartsgplatetraversedStrictTreetraversedStrictTree8 unpackLazy traversedLazy unpackLazy8traversedLazy8 unpackStrict unpackStrict8 AnEquality' AnEquality IdenticalrunEqsubstEqmapEqfromEqsimplysimpleStrictstrictSwappedswappedAnIso'AnIsoisowithIsocloneIsoauaufunderenummappingnonnon'anoncurried uncurriedflippedlazyreversed involutedmagmaimagma contramapping dimappinglmappingrmapping bimapping Rewrapping RewrappedWrapped Unwrapped _Wrapped' _Unwrapped'_Wrapped _Unwrappedop _Wrapping' _Unwrapping' _Wrapping _Unwrappingsliced toVectorOfvectorasStream asStreamRclonedforcedordinalsvectorIxvectorTraverse convertedpackedunpacked_Textbuildertextutf8IsTextEacheachSnoc_SnocCons_Cons<|consuncons_head_tail_init_last|>snocunsnocDequeBDnull singletonsizefromListAtIxedixIxValueContainscontainsIndex icontainsiixixAtsansiat SubstType substType HasTypeVars typeVarsExHasTypestypesHasNamenametypeVars substTypeVars conFieldsconNamedFields locFileName locPackage locModulelocStartlocEnd funDepInputs funDepOutputs fieldExpNamefieldExpExpression fieldPatNamefieldPatPattern matchPattern matchBodymatchDeclarationsfixityPrecedencefixityDirection clausePattern clauseBody clauseDecs_ClassI _ClassOpI_TyConI_FamilyI _PrimTyConI _DataConI_VarI_TyVarI_FunD_ValD_DataD _NewtypeD_TySynD_ClassD _InstanceD_SigD _ForeignD_InfixD_PragmaD_FamilyD _DataInstD _NewtypeInstD _TySynInstD_ClosedTypeFamilyD _RoleAnnotD_NormalC_RecC_InfixC_ForallC _IsStrict _NotStrict _Unpacked_ImportF_ExportF_CCall_StdCall_Unsafe_Safe_Interruptible_InlineP _SpecialiseP_SpecialiseInstP_RuleP_AnnP _NoInline_Inline _Inlinable_ConLike_FunLike _AllPhases _FromPhase _BeforePhase_RuleVar _TypedRuleVar_ModuleAnnotation_TypeAnnotation_ValueAnnotation_FunDep_TypeFam_DataFamtySynEqnPatternstySynEqnResult_InfixL_InfixR_InfixN_VarE_ConE_LitE_AppE_InfixE_UInfixE_ParensE_LamE _LamCaseE_TupE _UnboxedTupE_CondE _MultiIfE_LetE_CaseE_DoE_CompE _ArithSeqE_ListE_SigE_RecConE_RecUpdE _GuardedB_NormalB_NormalG_PatG_BindS_LetS_NoBindS_ParS_FromR _FromThenR_FromToR _FromThenToR_CharL_StringL _IntegerL _RationalL _IntPrimL _WordPrimL _FloatPrimL _DoublePrimL _StringPrimL_LitP_VarP_TupP _UnboxedTupP_ConP_InfixP_UInfixP_ParensP_TildeP_BangP_AsP_WildP_RecP_ListP_SigP_ViewP_ForallT_AppT_SigT_VarT_ConT _PromotedT_TupleT_UnboxedTupleT_ArrowT_ListT_PromotedTupleT _PromotedNilT_PromotedConsT_StarT _ConstraintT_LitT_PlainTV _KindedTV _NumTyLit _StrTyLit_ClassP_EqualP _NominalR_RepresentationalR _PhantomR_InferRDefName MethodNameTopName LensRules _simpleLenses _generateSigs_generateClasses _allowIsos _allowUpdates _lazyPatterns _fieldToDef _classyLensesmakeFieldOpticsmakeFieldOpticsForDec makePrismsmakeClassyPrisms makeDecPrisms simpleLensesgenerateSignaturesgenerateUpdateableOpticsgenerateLazyPatterns createClass lensField lensClass lensRules lensRulesFor classyRules classyRules_ makeLenses makeClassy makeClassy_ makeLensesFor makeClassyFormakeLensesWith declareLensesdeclareLensesFor declareClassydeclareClassyFor declarePrismsdeclareWrapped declareFieldsdeclareLensesWith makeWrappedunderscoreFieldscamelCaseFieldsabbreviatedFields makeFieldsdefaultFieldRulesHandlingException Handleablehandlerhandler_iscatching catching_handling handling_tryingthrowingevalOfparOfafter throughoutseqOfixmapped.|.~.&.~.&.=.|.=<.|.~<.&.~<.&.=<.|.=<<.&.~<<.|.~<<.&.=<<.|.=bitAtbyteAtbitsbytewise packedBytes unpackedBytesbytes packedChars unpackedCharschars IsByteString _realPart_polar _magnitude_phase _conjugatemembersprefixedsuffixed stripSuffixviewLviewRslicedTo slicedFromrootbranches_cast_gcast GTraversalgenericgeneric1_V1_U1_Par1_Rec1_K1_M1_L1_R1~=<~<=<<~<<=<.>~<.>=<<.>~<<.>=<<<.>~<<<.>=basename directory extensionfilenamelocation descriptionhandlefileNameerrno errorType_AlreadyExists _NoSuchThing _ResourceBusy_ResourceExhausted_EOF_IllegalOperation_PermissionDenied _UserError_UnsatisfiedConstraints _SystemError_ProtocolError _OtherError_InvalidArgument_InappropriateType_HardwareFault_UnsupportedOperation _TimeExpired_ResourceVanished _Interruptedintegralbinaryoctaldecimalhexadding subtracting multiplyingdividingexponentiatingnegatedAsHandlingException_HandlingException AsErrorCall AsRecUpdError _RecUpdError AsRecSelError _RecSelError AsRecConError _RecConErrorAsPatternMatchFail_PatternMatchFailAsNoMethodError_NoMethodError AsDeadlock _DeadlockAsBlockedIndefinitelyOnSTM_BlockedIndefinitelyOnSTMAsBlockedIndefinitelyOnMVar_BlockedIndefinitelyOnMVarAsNestedAtomically_NestedAtomicallyAsNonTerminationAsAsyncException_AsyncExceptionAsAssertionFailedAsArrayException_ArrayExceptionAsArithException_ArithException AsIOException _IOException exceptiontrying_ throwingM throwingTomappedExceptionmappedException' _Overflow _Underflow_LossOfPrecision _DivideByZero _Denormal_RatioZeroDenominator_IndexOutOfBounds_UndefinedElement _HeapOverflow _ThreadKilled_UserInterrupt AsDynamic_Dynamic AsExitCode _ExitCode _ExitSuccess _ExitFailurecatchIOversionbindirlibdirdatadir libexecdir sysconfdir getBinDir getLibDir getDataDir getLibexecDir getSysconfDirgetDataFileNameordinalNubHelpertemplate-haskellLanguage.Haskell.TH.Lib tySynInstDLanguage.Haskell.TH.SyntaxName TyVarBndr Data.EitherEither Data.MaybeMaybeControl.Monad.Trans.MaybeMaybeTControl.Monad.Trans.ListListT$fContravariantEffectRWS$fApplicativeEffectRWS$fApplyEffectRWS$fFunctorEffectRWS$fApplicativeEffect $fApplyEffect$fMonoidEffect$fSemigroupEffect$fContravariantEffect$fFunctorEffectTFCo:R:MagnifiedIdentityTTFCo:R:MagnifiedRWSTTFCo:R:MagnifiedRWST0TFCo:R:Magnified(->)TFCo:R:MagnifiedReaderT$fApplicativeFocusingErr$fApplyFocusingErr$fFunctorFocusingErr $fMonoidErr$fSemigroupErr$fApplicativeFocusingMay$fApplyFocusingMay$fFunctorFocusingMay $fMonoidMay$fSemigroupMay$fApplicativeFocusingOn$fApplyFocusingOn$fFunctorFocusingOn$fApplicativeFocusingPlus$fApplyFocusingPlus$fFunctorFocusingPlus$fApplicativeFocusingWith$fApplyFocusingWith$fFunctorFocusingWith$fApplicativeFocusing$fApplyFocusing$fFunctorFocusingTFCo:R:ZoomedExceptTTFCo:R:ZoomedErrorTTFCo:R:ZoomedMaybeTTFCo:R:ZoomedListTTFCo:R:ZoomedWriterTTFCo:R:ZoomedWriterT0TFCo:R:ZoomedRWSTTFCo:R:ZoomedRWST0TFCo:R:ZoomedIdentityTTFCo:R:ZoomedReaderTTFCo:R:ZoomedStateTTFCo:R:ZoomedStateT0GHC.BaseFunctor$fSettableBackwards$fSettableIdentity$fSettableCompose $fReviewablep$fChoiceMarket$fProfunctorMarket$fFunctorMarket$fReversingVector$fReversingVector0$fReversingVector1$fReversingSeq$fReversingVector2$fReversingText$fReversingText0$fReversingByteString$fReversingByteString0 $fReversing[]$fProfunctorExchange$fFunctorExchange Applicativelappendsemigroups-0.17.0.1Data.Semigroup Semigrouptrimltrimr$fApplicativeFlows$fMonoidDeepening $fApplyFlows$fFunctorFlows$fSemigroupDeepening$fTraversableLevel$fFoldableLevel$fFunctorLevelGHC.IntInt64 GHC.TypesIntData.Profunctor.RepCorepresentable Representablefmap$fContravariantIndexing64$fApplicativeIndexing64$fApplyIndexing64$fFunctorIndexing64$fContravariantIndexing$fApplicativeIndexing$fApplyIndexing$fFunctorIndexing$fIndexableiIndexed$fConjoinedIndexed$fArrowLoopIndexed$fArrowApplyIndexed$fArrowChoiceIndexed$fArrowIndexed$fCategory*Indexed$fStrongIndexed$fChoiceIndexed$fCorepresentableIndexed$fCosieveIndexed(,)$fRepresentableIndexed$fSieveIndexed(->)$fCostrongIndexed$fProfunctorIndexed$fMonadFixIndexed$fMonadIndexed $fBindIndexed$fApplicativeIndexed$fApplyIndexed$fFunctorIndexed$fIndexablei(->)$fConjoined(->)comonad-4.2.7.2 ComonadStorepeeksseekseeks experimentcoarr$fContravariantPretextT$fSellablepPretextT$fComonadStoreaPretextT$fIndexedComonadStorePretextT$fComonadPretextT$fIndexedComonadPretextT$fFunctorPretextT$fIndexedFunctorPretextT$fSellablepPretext$fComonadStoreaPretext$fIndexedComonadStorePretext$fComonadPretext$fIndexedComonadPretext$fFunctorPretext$fIndexedFunctorPretext$fSellable(->)Context$fComonadStoreaContext$fComonadContext$fFunctorContext$fIndexedComonadStoreContext$fIndexedComonadContext$fIndexedFunctorContext$fSemigroupBazaarT1$fContravariantBazaarT1$fComonadApplyBazaarT1$fComonadBazaarT1$fApplyBazaarT1$fFunctorBazaarT1$fBizarre1pBazaarT1$fSellablepBazaarT1$fIndexedComonadBazaarT1$fIndexedFunctorBazaarT1$fComonadApplyBazaar1$fComonadBazaar1$fApplyBazaar1$fFunctorBazaar1$fBizarre1pBazaar1$fSellablepBazaar1$fIndexedComonadBazaar1$fIndexedFunctorBazaar1$fMonoidBazaarT$fSemigroupBazaarT$fContravariantBazaarT$fComonadApplyBazaarT$fComonadBazaarT$fApplicativeBazaarT$fApplyBazaarT$fFunctorBazaarT$fBizarrepBazaarT$fSellablepBazaarT$fIndexedComonadBazaarT$fIndexedFunctorBazaarT$fComonadApplyBazaar$fComonadBazaar$fApplicativeBazaar $fApplyBazaar$fFunctorBazaar$fBizarrepBazaar$fSellablepBazaar$fIndexedComonadBazaar$fIndexedFunctorBazaar$fIndexedFunctorTakingWhile$fContravariantTakingWhile$fBizarrepTakingWhile$fApplicativeTakingWhile$fApplyTakingWhile$fFunctorTakingWhile$fIndexedFunctorMafic$fBizarreIndexedMafic$fSellable(->)Mafic$fApplicativeMafic $fApplyMafic$fFunctorMafic$fComonadMolten$fIndexedComonadMolten$fIndexedFunctorMolten$fBizarreIndexedMolten$fSellableIndexedMolten$fApplicativeMolten $fApplyMolten$fFunctorMolten $fShowMagma$fTraversableMagma$fFoldableMagma$fFunctorMagma$fBitraversableAlongsideRight$fBifoldableAlongsideRight$fBifunctorAlongsideRight$fTraversable1AlongsideRight$fFoldable1AlongsideRight$fTraversableAlongsideRight$fFoldableAlongsideRight$fContravariantAlongsideRight$fFunctorAlongsideRight$fBitraversableAlongsideLeft$fBifoldableAlongsideLeft$fBifunctorAlongsideLeft$fTraversable1AlongsideLeft$fFoldable1AlongsideLeft$fTraversableAlongsideLeft$fFoldableAlongsideLeft$fContravariantAlongsideLeft$fFunctorAlongsideLeftJust$fMonoidRightmost$fSemigroupRightmost$fMonoidLeftmost$fSemigroupLeftmost $fMonoidMax$fSemigroupMax $fMonoidMin$fSemigroupMin$fMonoidSequenced$fSemigroupSequenced$fMonoidTraversed$fSemigroupTraversed$fMonoidFolding$fSemigroupFoldingpure<$liftMid.$GHC.NumNumGHC.Real FractionalIntegral GHC.FloatFloating GHC.Classes||Bool&& mtl-2.2.1Control.Monad.State.Class MonadStatemappendControl.Monad.Writer.Classpass MonadWritercensorconstStringChar Control.ArrowArrowstateflipLeftRight void-0.7.1 Data.VoidVoidkan-extensions-4.2.3Data.Functor.YonedaYoneda$fField2(,)(,)bb'$fField1(,)(,)aa'N8N7N6N5N4N3N2N1N0GTSubtractAddFTSZGIxed'gix'GIxedgixGSizeproxyN0proxyN1proxyN2proxyN3proxyN4proxyN5proxyN6proxyN7proxyN8 TFCo:R:GTSS TFCo:R:GTSZ TFCo:R:GTZxTFCo:R:SubtractSSTFCo:R:SubtractZx TFCo:R:AddSy TFCo:R:AddZy$fGIxed'Fnss'st'ab$fGIxed'Tnss'ts'ab$fGIxedn:*::*:ab$fGIxednM1M1ab$fGIxedZK1K1abTFCo:R:GSize:*:TFCo:R:GSizeM1TFCo:R:GSizeK1TFCo:R:GSizeU1$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:*::*:gg'$fField2ProductProductgg'$fField1(,,,,,,,,)(,,,,,,,,)aa'$fField1(,,,,,,,)(,,,,,,,)aa'$fField1(,,,,,,)(,,,,,,)aa'$fField1(,,,,,)(,,,,,)aa'$fField1(,,,,)(,,,,)aa'$fField1(,,,)(,,,)aa'$fField1(,,)(,,)aa'$fField1:*::*:ff'$fField1ProductProductff'$fField1IdentityIdentityab MonadReaderlistengetsNothingGHC.ListGHC.ReadReadGHC.ShowShowshowControl.Monad.Trans.ReaderReaderControl.Monad.Trans.RWS.LazyRWS Control.Monad.Trans.State.StrictControl.Monad.Trans.RWS.StrictControl.Monad.Trans.ErrorError$fMagnify(->)(->)ba$fMagnifyIdentityTIdentityTba$fMagnifyRWSTRWSTba$fMagnifyRWSTRWSTba0$fMagnifyReaderTReaderTba$fZoomExceptTExceptTst$fZoomErrorTErrorTst$fZoomMaybeTMaybeTst$fZoomListTListTst$fZoomWriterTWriterTst$fZoomWriterTWriterTst0$fZoomRWSTRWSTst$fZoomRWSTRWSTst0$fZoomIdentityTIdentityTst$fZoomReaderTReaderTst$fZoomStateTStateTst$fZoomStateTStateTst0containers-0.5.5.1 Data.Set.BaseSetOrdunordered-containers-0.2.5.1 Data.HashSetHashSethashable-1.2.3.3Data.Hashable.ClassHashableEqfoldrrepeat replicateiterateevenGHC.Enumsucc/= takeWhile dropWhilewordslinesfoldMapfoldEndofoldltoListTrueandoranyallProductproductSumsum traverse_for_ sequenceA_forM_ sequence_asum Alternativemsum MonadPluselemnotElem concatMapconcatlengthheadFirstLastnotmaximum fromMaybeGHC.ErrminimumOrdering maximumBy minimumByfindfoldr1foldl1foldr'foldl'foldrMfoldlM listToMaybe Data.Tuplesndifoldr64skipControl.Categoryfor sequenceAmapMforMsequence unwrapMonad WrapMonadControl.Applicative.Backwards BackwardsswaprunStatescanr1scanl1Control.Comonad==Data.Bitraversable BitraversableData.Functor.Kan.RiftRiftinswinspinsparrouts unsafeOutsunconsWithDefaultimapList$fTraverseMaxkMap$fTraverseMaxIntIntMap$fTraverseMinkMap$fTraverseMinIntIntMap Data.Map.Base$fFunctorWithIndexIntSeq Data.SequenceSeq$fFunctorWithIndexInt[]$fTraversableWithIndex[]Tree$fFoldableWithIndex[]Tree$fFunctorWithIndex[]Tree$fFunctorWithIndex(,)TracedT$fFunctorWithIndex(,)ReaderT#$fTraversableWithIndexEitherProduct $fFoldableWithIndexEitherProduct$fFunctorWithIndexEitherProduct $fTraversableWithIndexiIdentityT$fFoldableWithIndexiIdentityT$fFunctorWithIndexiIdentityT $fTraversableWithIndex(,)Compose$fFoldableWithIndex(,)Compose$fFunctorWithIndex(,)Compose$fTraversableWithIndex[]Cofree$fFoldableWithIndex[]Cofree$fFunctorWithIndex[]Cofree$fTraversableWithIndexiArray$fFoldableWithIndexiArray$fFunctorWithIndexiArray$fTraversableWithIndex[]Free$fFoldableWithIndex[]Free$fFunctorWithIndex[]Free$fTraversableWithIndexiMagma$fFoldableWithIndexiMagma$fFunctorWithIndexiMagma$fTraversableWithIndexiLevel$fFoldableWithIndexiLevel$fFunctorWithIndexiLevel$fFunctorWithIndexr(->)$fTraversableWithIndexkHashMap$fFoldableWithIndexkHashMap$fFunctorWithIndexkHashMap$fTraversableWithIndexkMap$fFoldableWithIndexkMap$fFunctorWithIndexkMap$fTraversableWithIndexIntIntMap$fFoldableWithIndexIntIntMap$fFunctorWithIndexIntIntMap$fTraversableWithIndexIntVector$fFoldableWithIndexIntVector$fFunctorWithIndexIntVector$fTraversableWithIndexIntSeq$fFoldableWithIndexIntSeq$fTraversableWithIndex()Maybe$fFoldableWithIndex()Maybe$fFunctorWithIndex()Maybe!$fTraversableWithIndexIntNonEmpty$fFoldableWithIndexIntNonEmpty$fFunctorWithIndexIntNonEmpty$fTraversableWithIndexInt[]$fFoldableWithIndexInt[]$fTraversableWithIndexk(,)$fFoldableWithIndexk(,)$fFunctorWithIndexk(,) $fTraversableWithIndex()Identity$fFoldableWithIndex()Identity$fFunctorWithIndex()Identity$fTraversableWithIndexiReverse$fFoldableWithIndexiReverse$fFunctorWithIndexiReverse $fTraversableWithIndexiBackwards$fFoldableWithIndexiBackwards$fFunctorWithIndexiBackwards<*>levelIns levelOuts rmapConst ilevelIns ilevelOuts Data.DatagmapMDatainlinePerformIOGHC.IOunsafePerformIOFollowerOracle fromOracleAnswerMissFollowHitCacheHitMapDataBox dataBoxKey _dataBoxValIsReflFieldExceptionsteplookuponmightBedataBox sybChildren emptyHitMap insertHitMapfixEqcachereadCacheFollowerinsert2hitTest biplateData uniplateDatapartfollower$fExceptionFieldException$fShowFieldExceptionData.Typeable.InternalTypeablenegate GHC.GenericsGenericgplate' $fGPlatedaV1 $fGPlatedaU1 $fGPlatedaK1 $fGPlatedaK10 $fGPlateda:*: $fGPlateda:+: $fGPlatedaM1 $fPlatedPat $fPlatedStmt $fPlatedType $fPlatedCon $fPlatedDec $fPlatedExp $fPlatedTree$fPlatedCofree$fPlatedCofreeT $fPlatedF $fPlatedFreeT $fPlatedFree $fPlated[]bytestring-0.10.4.0Data.ByteString.InternalData.ByteString.Lazy.Internalw2cGHC.WordWord8c2w unsafeCreatecreategrainimapBifoldrBimapB8ifoldrB8imapBLifoldrBLimapBL8 ifoldrBL8 fromStrict foldrChunks text-1.2.1.3EnumDoubleFloat integer-gmpGHC.Integer.TypeIntegercurryuncurry$fStrictRWSTRWST$fStrictWriterTWriterT$fStrictStateTStateT$fStrictTextText$fStrictByteStringByteString$fSwappedEither $fSwapped(,)$fRewrappedSett$fRewrappedMapt$fRewrappedIntSettData.IntSet.Base$fRewrappedIntMaptData.IntMap.Base$fRewrappedHashSett$fRewrappedHashMaptData.HashMap.Base getErrorCallgetRecUpdErrorgetRecSelErrorgetRecConErrorgetPatternMatchFailgetNoMethodErrorfailedAssertion getArrowMonad$fWrappedErrorCall$fRewrappedErrorCallt$fWrappedRecUpdError$fRewrappedRecUpdErrort$fWrappedRecSelError$fRewrappedRecSelErrort$fWrappedRecConError$fRewrappedRecConErrort$fWrappedPatternMatchFail$fRewrappedPatternMatchFailt$fWrappedNoMethodError$fRewrappedNoMethodErrort$fWrappedAssertionFailed$fRewrappedAssertionFailedt$fWrappedTagged$fRewrappedTaggedt$fWrappedComposeCF$fRewrappedComposeCFt$fWrappedComposeFC$fRewrappedComposeFCt$fWrappedCompose$fRewrappedComposet $fWrappedOp$fRewrappedOpt$fWrappedEquivalence$fRewrappedEquivalencet$fWrappedComparison$fRewrappedComparisont$fWrappedPredicate$fRewrappedPredicatet$fWrappedOption$fRewrappedOptiont$fWrappedWrappedMonoid$fRewrappedWrappedMonoidt $fWrappedLast$fRewrappedLastt$fWrappedFirst$fRewrappedFirstt $fWrappedMax$fRewrappedMaxt $fWrappedMin$fRewrappedMint$fWrappedVector$fRewrappedVectort$fWrappedVector0$fRewrappedVectort0$fWrappedVector1$fRewrappedVectort1$fWrappedVector2$fRewrappedVectort2 $fWrappedSeq$fRewrappedSeqt $fWrappedSet $fWrappedMap$fWrappedIntSet$fWrappedIntMap$fWrappedHashSet$fWrappedHashMap$fWrappedTracedT$fRewrappedTracedTt$fWrappedCoproduct$fRewrappedCoproductt$fWrappedWriterT$fRewrappedWriterTt$fWrappedWriterT0$fRewrappedWriterTt0$fWrappedStateT$fRewrappedStateTt$fWrappedStateT0$fRewrappedStateTt0 $fWrappedRWST$fRewrappedRWSTt$fWrappedRWST0$fRewrappedRWSTt0$fWrappedReverse$fRewrappedReverset$fWrappedReaderT$fRewrappedReaderTt$fWrappedMaybeT$fRewrappedMaybeTt$fWrappedListT$fRewrappedListTt$fWrappedIdentityT$fRewrappedIdentityTt$fWrappedIdentity$fRewrappedIdentityt$fWrappedErrorT$fRewrappedErrorTt$fWrappedContT$fRewrappedContTt$fWrappedConstant$fRewrappedConstantt$fWrappedCompose0$fRewrappedComposet0$fWrappedBackwards$fRewrappedBackwardst $fWrappedDown$fRewrappedDownt$fWrappedArrowMonad$fRewrappedArrowMonadt$fWrappedLast0$fRewrappedLastt0$fWrappedFirst0$fRewrappedFirstt0 $fWrappedEndo$fRewrappedEndot $fWrappedDual$fRewrappedDualt$fWrappedConst$fRewrappedConstt$fWrappedNonEmpty$fRewrappedNonEmptyt$fWrappedZipList$fRewrappedZipListt$fWrappedWrappedArrow$fRewrappedWrappedArrowt$fWrappedWrappedMonad$fRewrappedWrappedMonadt$fWrappedKleisli$fRewrappedKleislit$fWrappedProduct$fRewrappedProductt $fWrappedSum$fRewrappedSumt $fWrappedAny$fRewrappedAnyt $fWrappedAll$fRewrappedAllt$fRewrappingstvector-0.11.0.0Data.Vector.Generic.BaseVectorData.Vector.Fusion.BundleBundleData.Text.ShowData.Text.Internal.BuilderBuilderfromTexttoStrict toLazyText imapStrict ifoldrStrictData.Text.Internal.Lazy fromLazyTextimapLazy ifoldrLazy $fIsTextText $fIsTextText0 $fIsText[] $fAsEmptyText$fAsEmptyText0$fAsEmptyByteString$fAsEmptyByteString0 $fAsEmptySeq$fAsEmptyVector$fAsEmptyVector0$fAsEmptyVector1$fAsEmptyIntSet$fAsEmptyHashSet $fAsEmptySet$fAsEmptyIntMap$fAsEmptyHashMap $fAsEmptyMap $fAsEmpty[] $fAsEmpty(,,) $fAsEmpty(,) $fAsEmptyDual$fAsEmptyFirst $fAsEmptyLast$fAsEmptyMaybe $fAsEmptySum$fAsEmptyProduct$fAsEmptyEvent $fAsEmptyAll $fAsEmptyAny $fAsEmpty()$fAsEmptyOrdering$fEachUArrayUArrayabGHC.ArrIx array-0.5.0.0Data.Array.BaseIArrayUArrayArray$fEachArrayArrayab$fEachByteStringByteStringab$fEachByteStringByteStringab0$fEachTextTextab$fEachTextTextab0$fEachVectorVectorabData.Vector.Unboxed.BaseUnbox$fEachVectorVectorab0Foreign.StorableStorableData.Vector.Storable$fEachVectorVectorab1 primitive-0.6Data.Primitive.TypesPrimData.Vector.Primitive$fEachVectorVectorab2 Data.Vector$fEachTreeTreeab Data.TreeTree$fEachSeqSeqab$fEachMaybeMaybeab$fEachIdentityIdentityab$fEachNonEmptyNonEmptyab $fEach[][]ab$fEachHashMapHashMapabHashMap$fEachIntMapIntMapab$fEachMapMapab$fEachComplexComplexab RealFloat$fEach(,,,,,,,,)(,,,,,,,,)ab$fEach(,,,,,,,)(,,,,,,,)ab$fEach(,,,,,,)(,,,,,,)ab$fEach(,,,,,)(,,,,,)ab$fEach(,,,,)(,,,,)ab$fEach(,,,)(,,,)ab$fEach(,,)(,,)ab$fEach(,)(,)abtail$fSnocTextTextCharChar$fSnocTextTextCharChar0$$fSnocByteStringByteStringWord8Word8%$fSnocByteStringByteStringWord8Word80$fSnocVectorVectorab$fSnocVectorVectorab0$fSnocVectorVectorab1$fSnocVectorVectorab2$fSnocSeqSeqab$fSnocNonEmptyNonEmptyab $fSnoc[][]ab$fConsVectorVectorab$fConsVectorVectorab0$fConsVectorVectorab1$fConsVectorVectorab2$fConsTextTextCharChar$fConsTextTextCharChar0$$fConsByteStringByteStringWord8Word8%$fConsByteStringByteStringWord8Word80$fConsSeqSeqab$fConsNonEmptyNonEmptyab $fCons[][]abemptycheck$fSnocDequeDequeab$fConsDequeDequeab $fMonoidDeque$fSemigroupDeque$fTraversableWithIndexIntDeque$fTraversableDeque$fFoldableWithIndexIntDeque$fFoldableDeque$fMonadPlusDeque $fMonadDeque $fBindDeque$fReversingDeque$fAlternativeDeque $fPlusDeque $fAltDeque$fApplicativeDeque $fApplyDeque$fFunctorWithIndexIntDeque$fFunctorDeque $fOrdDeque $fEqDequeTFCo:R:IxValue(,,,,,,,,)TFCo:R:IxValue(,,,,,,,)TFCo:R:IxValue(,,,,,,)TFCo:R:IxValue(,,,,,)TFCo:R:IxValue(,,,,)TFCo:R:IxValue(,,,)TFCo:R:IxValue(,,)TFCo:R:IxValue(,) $fIxedUArray!// $fIxedArray$fIxed(,,,,,,,,)$fIxed(,,,,,,,)$fIxed(,,,,,,) $fIxed(,,,,,) $fIxed(,,,,) $fIxed(,,,) $fIxed(,,) $fIxed(,) $fAtHashSet$fAtSet $fAtIntSet $fAtHashMap$fAtMap $fAtIntMap $fAtMaybe$fIxedByteStringTFCo:R:IxValueByteString$fIxedByteString0TFCo:R:IxValueByteString0 $fIxedTextTFCo:R:IxValueText $fIxedText0TFCo:R:IxValueText0 $fIxedVectorTFCo:R:IxValueVector $fIxedVector0TFCo:R:IxValueVector0 $fIxedVector1TFCo:R:IxValueVector1 $fIxedVector2TFCo:R:IxValueVector2TFCo:R:IxValueUArrayTFCo:R:IxValueArray $fIxedHashSetTFCo:R:IxValueHashSet $fIxedIntSetTFCo:R:IxValueIntSet $fIxedSetTFCo:R:IxValueSet $fIxedHashMapTFCo:R:IxValueHashMap $fIxedMapTFCo:R:IxValueMap $fIxedIntMapTFCo:R:IxValueIntMap $fIxedSeqTFCo:R:IxValueSeq $fIxedTreeTFCo:R:IxValueTree$fIxedIdentityTFCo:R:IxValueIdentity$fIxedNonEmptyTFCo:R:IxValueNonEmpty$fIxed[]TFCo:R:IxValue[] $fIxedMaybeTFCo:R:IxValueMaybe $fIxed(->)TFCo:R:IxValue(->)$fContainsHashSet $fContainsSet$fContainsIntSetTFCo:R:IndexByteStringTFCo:R:IndexByteString0TFCo:R:IndexTextTFCo:R:IndexText0TFCo:R:IndexTreeTFCo:R:IndexMaybeTFCo:R:IndexIdentityTFCo:R:IndexComplexTFCo:R:IndexVectorTFCo:R:IndexVector0TFCo:R:IndexVector1TFCo:R:IndexVector2TFCo:R:IndexUArrayTFCo:R:IndexArrayTFCo:R:IndexHashMapTFCo:R:IndexMapTFCo:R:IndexIntMapTFCo:R:Index(,,,,,,,,)TFCo:R:Index(,,,,,,,)TFCo:R:Index(,,,,,,)TFCo:R:Index(,,,,,)TFCo:R:Index(,,,,)TFCo:R:Index(,,,)TFCo:R:Index(,,)TFCo:R:Index(,)TFCo:R:IndexSeqTFCo:R:IndexNonEmptyTFCo:R:Index[]TFCo:R:IndexHashSetTFCo:R:IndexSetTFCo:R:IndexIntSetTFCo:R:Index(->)newNameType$fSubstTypePred $fSubstType[]$fSubstTypeType$fHasTypeVarsMaybe$fHasTypeVars[]$fHasTypeVarsCon$fHasTypeVarsPred$fHasTypeVarsType$fHasTypeVarsName$fHasTypeVarsTyVarBndr $fHasTypes[] $fHasTypesCon$fHasTypesType $fHasNameCon $fHasNameName$fHasNameTyVarBndrmakeFieldOpticsForDec'normalizeConstructor buildScaffold buildStab OpticStabmakeFieldOpticmakePureClausemakeGetterClausemakeFieldOpticClause makeIsoClause unifyTypesunify1 limitedSubstapplyTypeSubst quantifyType quantifyType'OpticSa OpticTypeIsoTypeLensType GetterType stabToType stabToContext stabToOpticstabToSstabToAmakeClassyDrivermakeClassyClassmakeClassyInstancemakeFieldClassmakeFieldInstancemakeFieldClauses inlinePragmaNCon makePrisms'DecmakeConsPrismscomputePrismTypemakeConOpticExp makeConIsomakeConPrismExp makeConIsoExpmakeConReviewExp makeReviewermakeSimpleRemittermakeFullRemittermakeIsoRemittermakeClassyPrismClassmakeClassyPrismInstance normalizeConCon prismNameclose _nconName_nconCxt _nconTypesStab ReviewType PrismType simplifyStab stabSimplestabTypecomputeOpticTypecomputeReviewTypecomputeIsoTypenconNamenconCxt nconTypes$fHasTypeVarsNConDeclareDataDecl dataContext tyConNamedataParametersfullType constructors$!classyRulesFor deNewtypefreshMaptraverseDataAndNewtype mkNameLookupapps makeDataDeclmakeWrappedForDecmakeRewrappedInstancemakeWrappedInstanceoverHeadunderscoreNamercamelCaseNamerabbreviatedNamer declareWith runDeclareemit stripFieldsdeRecordHandling GHC.Exception Exceptionexceptions-0.8.0.2Control.Monad.Catch System.IOprint++ SomeExceptionIOreturn handlerIOhandlerCatchIO$fExceptionHandling$fShowHandling$fExceptionHandlingException!$fHandleableSomeExceptionmHandler"$fHandleableSomeExceptionIOHandlerControl.Monad.Error.Class MonadError throwError$fHandleableemHandler$fMonoidHandler $fPlusHandler $fAltHandler$fSemigroupHandler$fFunctorHandlerparallel-3.2.0.6Control.Parallel.StrategiesStrategyevalTraversableEvalparTraversablerdeepseq Control.Seq seqFoldableixmapbounds Data.Bits.|.Bits.&.<=<bitSize undefineddiv$fIsByteStringByteString$fIsByteStringByteString0realPartimagPartpolar magnitudephasepi conjugateIntSetViewLviewlViewRviewr subForestgcast tinplated maybeArg1Of$fGTraversalM1$fGTraversal:+:$fGTraversal:*:$fGTraversalV1$fGTraversalU1$fGTraversalK1FilePath intToDigit' digitToInt' digitToIntMayisDigit' showSigned' readSigned' ErrorCallControl.Exception.Base RecConErrorPatternMatchFail NoMethodErrorGHC.IO.ExceptionDeadlockBlockedIndefinitelyOnSTMBlockedIndefinitelyOnMVarNestedAtomicallyNonTerminationAsyncExceptionassertAssertionFailedArrayException IOException MonadCatch MonadThrow GHC.Conc.SyncthrowToThreadId mapExceptionArithException HeapOverflowtrivial"$fAsHandlingExceptionSomeException&$fAsHandlingExceptionHandlingException$fAsErrorCallSomeException$fAsErrorCallErrorCall$fAsRecUpdErrorSomeException$fAsRecUpdErrorRecUpdError$fAsRecSelErrorSomeException$fAsRecSelErrorRecSelError$fAsRecConErrorSomeException$fAsRecConErrorRecConError!$fAsPatternMatchFailSomeException$$fAsPatternMatchFailPatternMatchFail$fAsNoMethodErrorSomeException$fAsNoMethodErrorNoMethodError$fAsDeadlockSomeException$fAsDeadlockDeadlock)$fAsBlockedIndefinitelyOnSTMSomeException4$fAsBlockedIndefinitelyOnSTMBlockedIndefinitelyOnSTM*$fAsBlockedIndefinitelyOnMVarSomeException6$fAsBlockedIndefinitelyOnMVarBlockedIndefinitelyOnMVar!$fAsNestedAtomicallySomeException$$fAsNestedAtomicallyNestedAtomically$fAsNonTerminationSomeException $fAsNonTerminationNonTermination$fAsAsyncExceptionSomeException $fAsAsyncExceptionAsyncException $fAsAssertionFailedSomeException"$fAsAssertionFailedAssertionFailed$fAsArrayExceptionSomeException $fAsArrayExceptionArrayException$fAsArithExceptionSomeException $fAsArithExceptionArithException$fAsIOExceptionSomeException$fAsIOExceptionIOException Data.DynamicDynamic$fAsDynamicSomeException$fAsDynamicDynamicExitCode$fAsExitCodeSomeException$fAsExitCodeExitCode