l      !"#$%&'()*+,-./0123456789:;<=>? @ A B C D E F G H I J K L M N O P Q R S T U V WXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~         !!!!!!!!!!!!!!!!!!! ! ! ! ! !!!!!!!!!!!!!"""""" "!"""#"$%&'()*+,-./0123456789:;<=>?@ABC#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){)|)})~))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) ) ) ) ) ))))))))))))))***** *!*"*#*$*%*&*'*(+)+*++,,,-,.,/,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.{.|.}.~........./////0111111111122222222234444567777777777777777888888999999:::::::;;;;;;<<<=====>>>>>>>>>>>>>>>>??????@@@@@@AAAAAABBBBBBCCDDEEEEE F F F F FFFFGGGGHHHHHHHHIII I!I"I#I$I%I&I'I(I)I*I+I,I-J.J/J0J1J2J3J4J5J6J7J8J9J:J;J<J=J>J?J@JAJBJCJDJEJFKGKHKIKJKKKLKMKNKOKPKQKRLSLTLULVLWLXLYLZL[L\L]L^L_L`LaLbLcLdLeLfLgLhLiLjLkLlLmLnLoLpLqLrLsLtLuLvLwLxLyLzL{L|L}L~LLLLLLLLLLLLLLMMNNNNUO Safe-InferredP Safe-Inferred   non-portable experimentalEdward Kmett <ekmett@gmail.com> Trustworthy9Compatibility 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. 5Construct a tuple value given a list of expressions. 4Construct a tuple pattern given a list of patterns. 'Apply arguments to a type constructor. Return  contained in a . & !"#$%&'()*+,-./0123456789:;<& !"#$%&'()*+,-./0123456789:;<& !"#$%&'()*+,-./0123456789:;<& !"#$%&'()*+,-./0123456789:;< non-portable experimentalEdward Kmett <ekmett@gmail.com> Trustworthy>%Reify a value at the type level in a *-compatible fashion, to be recovered with .       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~>      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~>>      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~>      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~Q non-portable experimentalEdward Kmett <ekmett@gmail.com> Safe-Inferred  non-portable provisionalEdward Kmett <ekmett@gmail.com> Trustworthy? Anything ? must be isomorphic to the  . R So you can pass our S- into combinators from other lens libraries. ?@AB?@AB?@AB?@AB  non-portable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferredCIThis class is provided mostly for backwards compatibility with lens 3.8, * but it can also shorten type signatures. D2This is a profunctor used internally to implement Review #It plays a role similar to that of T  or Const do for Control.Lens.Getter CDCDCDCD  non-portable experimentalEdward Kmett <ekmett@gmail.com> TrustworthyE type E a s t = F a a s tF$This type is used internally by the U code to 0 provide efficient access to the two parts of a Prism. EFGEFGFGEEFG  non-portable experimentalEdward Kmett <ekmett@gmail.com> TrustworthyHXThis class provides a generalized notion of list reversal extended to other containers. JThis is used internally by the V code to provide D efficient access to the two functions that make up an isomorphism. HIJKHIJKJKHIHIJK  non-portable experimentalEdward Kmett <ekmett@gmail.com> Trustworthy LThis is an illegal 7 used to replace the contents of a list of consecutive R values ] representing each layer of a structure into the original shape that they were derived from. Attempting to FlowM something back into a shape other than the one it was taken from will fail. OThis is an illegal  used to construct a single R. RJThis data type represents a path-compressed copy of one level of a source N data structure. We can safely use path-compression because we know the depth  of the tree. +Path compression is performed by viewing a R as a PATRICIA trie of the K paths into the structure to leaves at a given depth, similar in many ways  to a WX4, but unlike a regular PATRICIA trie we do not need 6 to store the mask bits merely the depth of the fork. 5One invariant of this structure is that underneath a U node you will not  find any S nodes, so S can only occur at the root. Append a pair of R values to get a new R with path compression. As the R; type is user-visible, we do not expose this as an illegal  ' instance, and just use it directly in O as needed. VGenerate the leaf of a given O based on whether or not we're at the correct depth. Walk down one constructor in a R, veering left. Walk down one constructor in a R, veering right. This is an illegal . This is an illegal . LMNOPQRSTUV LMNOPQRSTUV RUTSOPQVLMNLMNOPQRUTSV non-portable experimentalEdward Kmett <ekmett@gmail.com> Trustworthy W composition of YZ  with a , used  by [. Z composition of YZ  with a , used  by \. ]YA 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 -> b`GThis class permits overloading of function application for things that ( also admit a notion of a key or index. aBuild a function from an a function. b This is a  that is both  by f and  by g such  that f is left adjoint to g2. From this you can derive a lot of structure due - to the preservation of limits and colimits. cb- is strong enough to let us distribute every b   over every Haskell . This is effectively a  generalization of . d_This permits us to make a decision at an outermost point about whether or not we use an index. cIdeally any use of this function should be done in such a way so that you compute the same answer, 0 but this cannot be enforced at the type level. e Transform a ] into an ^ or  a _ into an `, etc.    e :: ] s t a b -> ^  s t a b  e :: U s t a b -> ^  s t a b  e :: a s t a b -> b  s t a b  e :: V s t a b -> b  s t a b  e :: _ s a -> `  s a  e :: c s a -> d  s a  e :: `  p => e (Z f) s t a b -> f p (->) f s t a bf Transform a ] into an ^ or  a _ into an `, etc. This combinator is like e? except that it handles large traversals and folds gracefully.    f :: ] s t a b -> ^  s t a b  f :: U s t a b -> ^  s t a b  f :: a s t a b -> b  s t a b  f :: V s t a b -> b  s t a b  f :: _ s a -> `  s a  f :: c s a -> d  s a  f :: `  p => e (W f) s t a b -> g p f s t a b,WXYZ[\]^_`abcdefWXYZ[\]^_`abcdef]^_bcd`aZ[\eWXYf#WXYZ[\]^_`abcdef non-portable experimentalEdward Kmett <ekmett@gmail.com> Trustworthyg type g p g a s = h p g a a shThis is a generalized form of p) that can be repeatedly cloned with less F impact on its performance, and which permits the use of an arbitrary b  . The extra phantom # is used to let us lie and claim a Gettable instance under U limited circumstances. This is used internally to permit a number of combinators to & gracefully degrade when applied to a _, c  or -h. k type k p a s = l p a a slThis is a generalized form of p) that can be repeatedly cloned with less F impact on its performance, and which permits the use of an arbitrary b   o type o a s = p a a sp0The indexed store can be used to characterize a a  and is used by i. p a b t is isomorphic to  newtype p a b t = p { runContext :: forall f.  f => (a -> f b) -> f t },  and to exists s. (s, a s t a b). A p is like a a4 that has already been applied to a some structure. r'This is used internally to construct a j, p or l  from a singleton value. tThis is an indexed analogue to " for when you are working with an  |. uThis is the generalization of  to an indexed comonad store. vThis is the generalization of  to an indexed comonad store. wThis is the generalization of  to an indexed comonad store. xThis is the generalization of   to an indexed comonad store. yThis is the generalization of   to an indexed comonad store. zThis 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 p. |7This 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. BThe 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. ~:duplicate an indexed comonadic value splitting the index. <extend a indexed comonadic computation splitting the index. 7This 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 b  to a function, < possibly losing information about an index in the process. 2ghijklmnopqrstuvwxyz{|}~                  ghijklmnopqrstuvwxyz{|}~|}~tuvwxyz{rspqolmnkhijg!ghijklmnopqrstuvwxyz{|}~                   non-portable experimentalEdward Kmett <ekmett@gmail.com> Trustworthy OThis 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   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 k , but there  must be a better way! OThis 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 ]. Ta.k.a. indexed Cartesian store comonad, indexed Kleene store comonad, or an indexed FunList.  *http://twanvl.nl/blog/haskell/non-regular1 A  is like a ]2 that has already been applied to some structure. Where a p 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 0 holds many stores and you can easily add more. This is a final encoding of . OThis 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   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 k , but there  must be a better way! OThis 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 ]. Ta.k.a. indexed Cartesian store comonad, indexed Kleene store comonad, or an indexed FunList.  *http://twanvl.nl/blog/haskell/non-regular1 A  is like a ]2 that has already been applied to some structure. Where a p 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 0 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. ;       ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @1       ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ non-portable experimentalEdward Kmett <ekmett@gmail.com> TrustworthyCThis is used to generate an indexed magma from an unindexed source MBy 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  , 1 while the remaining arguments are degraded to a nominal role by the invariants of  CThis is used to generate an indexed magma from an unindexed source UBy 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  ] or ^ Run a < 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. ' A B C D E F G H I J K L M N O P Q R S T U V W X A B C D E F G H I J K L M N O P Q R S T U V W X non-portable provisionalEdward Kmett <ekmett@gmail.com> Trustworthy4Wrap a monadic effect with a phantom type argument. An  - ignores its argument and is isomorphic to a  Y wrapped around a value. That said, the  Y% is possibly rather unrelated to any  structure.  Z [ \ ] ^ _ ` a b  Z [ \ ] ^ _ ` a b non-portable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferredIThis class is provided mostly for backwards compatibility with lens 3.8, * but it can also shorten type signatures. This Generalizes  so we can apply simple  ? transformations to it and so we can get nicer error messages. A  you can 4 ignores its argument, which it carries solely as a  phantom type parameter. By the  and   laws, an instance of  will necessarily satisfy:  c =  f =  =   gThe mempty equivalent for a   .  d e f g h i j k l m n o p q r s t u v w x  d e f g h i j k l m n o p q r s t u v w x non-portable experimentalEdward Kmett <ekmett@gmail.com> Trustworthy  Used for l.  Used for m.  Used for n.  Used for o. Used internally by p and the like.  The argument a# of the result should not be used! Used internally by q 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  y ( the moment it sees any element at all.  Extract the @ element. This will fairly eagerly determine that it can return  y ( the moment it sees any element at all. 3 z { | } ~  "" z { | } ~   non-portable experimentalEdward Kmett <ekmett@gmail.com> Trustworthy IWrap a monadic effect with a phantom type argument. Used when magnifying rs. This type family is used by t% to describe the common effect type. Used by u to v into wx. Make a  out of   for error handling. Used by u to v into wx. Make a  out of   for error handling. Used by u to v into   or  . Used by u to v into yz. Used by u to v into rs. Used by u to v into {|. This type family is used by u% to describe the common effect type. 7 %  Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred1wThis 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) wThis is a convenient alias for use when you need to consume either indexed or non-indexed lens-likes based on context. GConvenient 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 q f s a =  ( p q 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  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 .,(, ...  whenever the type variables don't change upon setting a value.    ;} ::  . (~ a) a   ::  ($ ) [a] a .Note: To use this alias in your own code with  f or  , you may have to turn on LiberalTypeSynonyms. "This is commonly abbreviated as a "prime" marker, e.g. - =  .. An   can be used as a  , but when composed with an $,   , or , yields an   respectively. An  is an   enriched with access to a  Y for side-effects. Every   can be used as an (, that simply ignores the access to the  Y. You can compose an  with another  using (  ) from the Prelude. A  is a   enriched with access to a  Y for side-effects. A d can use side-effects to produce parts of the structure being folded (e.g. reading them from file). Every   can be used as a (, that simply ignores the access to the  Y. You can compose a  with another  using (  ) from the Prelude. An  can be used as a , but when composed with an $,   , or , yields an ,  or  respectively. An  is an  enriched with access to a  Y for side-effects. Every  can be used as an . You can compose an  with another  using (  ) from the Prelude. An  is a  enriched with access to a  Y for side-effects. Every  can be used as an . You can compose an  with another  using (  ) from the Prelude.  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 _ and can be used for .  A  I 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 ] 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 ` and can be used for  like a . A ? 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 . 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 _,  since it just ignores the .  Composable  !. 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 m or use (), I will get it back:    m l ( l b) "a  y 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 m l s "a  y a then  l a "a s These 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     allows you to always  go from a  to an  ,, and provide you with tools to check if an   is  a  and/or to edit one if it is.    nat ::      nat =      \ i ->  if i   0  then   i  else   (  i) Now we can ask if an   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  . 5 ^. re nat -- :: Natural5Similarly we can use a  to  the   half of an  : Left "hello" & _Left %~ lengthLeft 5or to construct an  :  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.    type  =   2Isomorphism families can be composed with another . using ( ) and  c. 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 ::        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 3 in general, so the other two laws are irrelevant.  However, two  laws apply to a :     l  c "a  c   l f    l g "a  l (f   g) #These can be stated more directly:    l   "a    l f   @   l g "a l (f   @   g) You can compose a  with a . or a ( using (  ) from the Prelude ! and the result is always only a  and nothing more. 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 ] or  `. The ] constraint is used to allow an $ to be used  directly as a ]. The ]" laws are still required to hold. In addition, the index i. 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 S or a   (but not as a .) and provides V the ability to both read and update multiple fields, subject to some relatively weak ( laws. UThese have also been known as multilenses, but they have the signature and spirit of     ::  f => ( (f a) (f b) a b 8and 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  as stated in "#The Essence of the Iterator Pattern".    t   "a     (t f)   t g "a    t (    f   g) .One consequence of this requirement is that a (1 needs to leave the same number of elements as a  candidate for subsequent (G that it started with. Another testament to the strength of these laws 4 is that the caveat expressed in section 5.5 of the "Essence of the Iterator Pattern" about exotic   instances that E the same entry multiple times was actually already ruled out by the  second law in that same paper! )   type ) =  * *An *- leaves any index it is composed with alone. +   type + i =  (, i) ,Every , is a valid . and a valid ^. -   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 "2) 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 . cannot C vary fully independently. For more on how they interact, read the "Why is  it a Lens Family?" section of   /http://comonad.com/reader/2012/mirrored-lenses/. 2There are some emergent properties of these laws: 1)  l s must be injective for every s This is a consequence of law #1 2)  l$ must be surjective, because of law #52, which indicates that it is possible to obtain any v from some s such that  s v = s D3) 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 S 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     (l f)   l g "a    l (    f   g)    type . s t a b = forall f.  f =>  f s t a b <      !"#$%&'()*+,-.<      !"#$%&'()*+,-.<.-('&%  ,+$#"! *)   <      !"#$%&'()*+,-. Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Trustworthy>/QThis is a convenient alias when defining highly polymorphic code that takes both  3 and 10 as appropriate. If a function takes this it is 5 expecting one of those two things based on context. 0QThis is a convenient alias when defining highly polymorphic code that takes both  4 and 20 as appropriate. If a function takes this it is 5 expecting one of those two things based on context. 1   type 1 i =  (2 i) 2 Running an % instantiates it to a concrete type. WWhen consuming a setter directly to perform a mapping, you can use this type, but most + user code will not need to use this type. 30This is a useful alias for use when consuming a . 1Most user code will never have to use this type.   type 3 =  4 4 Running a % instantiates it to a concrete type. WWhen consuming a setter directly to perform a mapping, you can use this type, but most + user code will not need to use this type. 5This 0 can be used to map over all of the values in a .     "a > 5   "a >   ( ) "a ? 5 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)]   5 ::  f =>  (f a) (f b) a b If you want an  use 9 . 6This setter. can be used to modify all of the values in a  Y. +You sometimes have to use this rather than 5 -- due to  temporary insanity  is not a superclass of  Y.      "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 9  . 7This 0 can be used to map over all of the inputs to a  .      "a > 7 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]8This ( 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) yFMap over the argument of the result of a function -- i.e., its second  argument: (mapped.argument %~ f) h x y h x (f y)   8 ::  (b -> r) (a -> r) a b 9Build an index-preserving  from a map-like function. Your supplied function f is required to satisfy:    f  c "a  c  f g   f h "a f (g   h) Equational reasoning:    9   > "a  c  >   9 "a  c Another way to view : is that it takes a "semantic editor combinator"  and transforms it into a .   9 :: ((a -> b) -> s -> t) ->  s t a b :Build a ,  or  depending on your choice of .   : :: ((a -> b) -> s -> t) ->  s t a b ;Restore 4 to a full . < Build an  from any . = Clone an . >Modify the target of a . or all the targets of a  or (  with a function.     "a > 5   "a >   :   > "a  c  >   : "a  c Given any valid  l , you can also rely on the law:    > l f   > l g = > 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 > 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)   > ::  s t a b -> (a -> b) -> s -> t  > :: 4 s t a b -> (a -> b) -> s -> t ?Replace the target of a . or all of the targets of a   or ( with a constant value.    ( ) "a ? 5 set _2 "hello" (1,()) (1,"hello")set mapped () [1,2,3,4] [(),(),(),()]Note: Attempting to ? a   or # will fail at compile time with an  relatively nice error message.   ? ::  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 @Replace the target of a . or all of the targets of a   or (3 with a constant value, without changing its type. %This is a type restricted version of ?*, 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 @ a   or # will fail at compile time with an  relatively nice error message.   @ ::  s a -> a -> s -> s  @ ::  s a -> a -> s -> s  @ :: - s a -> a -> s -> s  @ :: ' s a -> a -> s -> s AModifies the target of a . or all of the targets of a  or  ( with a user supplied function. This is an infix version of >.     f "a 5 A f   f "a  A 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]]   (A) :: " s t a b -> (a -> b) -> s -> t  (A) :: % s t a b -> (a -> b) -> s -> t  (A) :: .$ s t a b -> (a -> b) -> s -> t  (A) :: ( s t a b -> (a -> b) -> s -> t BReplace the target of a . or all of the targets of a   or ( with a constant value. This is an infix version of ?!, provided for consistency with (P).    f   a "a 5 B f   a (a,b,c,d) & _4 .~ e (a,b,c,e)(42,"world") & _1 .~ "hello"("hello","world")(a,b) & both .~ c(c,c)   (B) ::  s t a b -> b -> s -> t  (B) ::  s t a b -> b -> s -> t  (B) :: . s t a b -> b -> s -> t  (B) :: ( s t a b -> b -> s -> t CSet the target of a ., ( or  to  y a value.    l C t "a ? l ( y t) Nothing & id ?~ aJust aMap.empty & at 3 ?~ xfromList [(3,x)]   (C) ::  s t a (  b) -> b -> s -> t  (C) ::  s t a (  b) -> b -> s -> t  (C) :: . s t a (  b) -> b -> s -> t  (C) :: ( s t a (  b) -> b -> s -> t DSet with pass-through. XThis 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 B 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")]))   (D) ::  s t a b -> b -> s -> (b, t)  (D) :: # s t a b -> b -> s -> (b, t)  (D) :: ." s t a b -> b -> s -> (b, t)  (D) :: ( s t a b -> b -> s -> (b, t) ESet to  y a value with pass-through. XThis 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 C 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")]))   (E) ::  s t a (  b) -> b -> s -> (b, t)  (E) ::  s t a (  b) -> b -> s -> (b, t)  (E) :: . s t a (  b) -> b -> s -> (b, t)  (E) :: ( s t a (  b) -> b -> s -> (b, t) F0Increment 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)]   (F) ::   a =>  s a -> a -> s -> s  (F) ::   a =>  s a -> a -> s -> s  (F) ::   a => - s a -> a -> s -> s  (F) ::   a => ' s a -> a -> s -> s G/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   (G) ::   a =>  s a -> a -> s -> s  (G) ::   a =>  s a -> a -> s -> s  (G) ::   a => - s a -> a -> s -> s  (G) ::   a => ' s a -> a -> s -> s H0Decrement 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]]   (H) ::   a =>  s a -> a -> s -> s  (H) ::   a =>  s a -> a -> s -> s  (H) ::   a => - s a -> a -> s -> s  (H) ::   a => ' s a -> a -> s -> s I-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)   (I) ::   a =>  s a -> a -> s -> s  (I) ::   a =>  s a -> a -> s -> s  (I) ::   a => - s a -> a -> s -> s  (I) ::   a => ' s a -> a -> s -> s J,Raise the target(s) of a numerically valued .,  or (# to a non-negative integral power. (1,3) & _2 ^~ 2(1,9)   (J) :: (  a,   e) =>  s a -> e -> s -> s  (J) :: (  a,   e) =>  s a -> e -> s -> s  (J) :: (  a,   e) => - s a -> e -> s -> s  (J) :: (  a,   e) => ' s a -> e -> s -> s K-Raise the target(s) of a fractionally valued .,  or ( to an integral power. (1,2) & _2 ^^~ (-1)(1,0.5)   (K) :: (  a,   e) =>  s a -> e -> s -> s  (K) :: (  a,   e) =>  s a -> e -> s -> s  (K) :: (  a,   e) => - s a -> e -> s -> s  (K) :: (  a,   e) => ' s a -> e -> s -> s L/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)   (L) ::   a =>  s a -> a -> s -> s  (L) ::   a =>  s a -> a -> s -> s  (L) ::   a => - s a -> a -> s -> s  (L) ::   a => ' s a -> a -> s -> s M Logically   the target(s) of a  -valued . or . both ||~ True $ (False,True) (True,True)both ||~ False $ (False,True) (False,True)   (M) ::  s   ->   -> s -> s  (M) ::  s   ->   -> s -> s  (M) :: - s   ->   -> s -> s  (M) :: ' s   ->   -> s -> s N Logically   the target(s) of a  -valued . or . both &&~ True $ (False, True) (False,True)both &&~ False $ (False, True) (False,False)   (N) ::  s   ->   -> s -> s  (N) ::  s   ->   -> s -> s  (N) :: - s   ->   -> s -> s  (N) :: ' s   ->   -> s -> s OReplace the target of a . or all of the targets of a  or ( in our monadic 2 state with a new value, irrespective of the old. This is an alias for (P). -execState (do assign _1 c; assign _2 d) (a,b)(c,d)execState (both .= c) (a,b)(c,c)   O ::   s m =>  s a -> a -> m ()  O ::   s m => - s a -> a -> m ()  O ::   s m => ' s a -> a -> m ()  O ::   s m =>  s a -> a -> m () PReplace the target of a . or all of the targets of a   or (< in our monadic state with a new value, irrespective of the  old. This is an infix version of O. %execState (do _1 .= c; _2 .= d) (a,b)(c,d)execState (both .= c) (a,b)(c,c)   (P) ::   s m =>  s a -> a -> m ()  (P) ::   s m => - s a -> a -> m ()  (P) ::   s m => ' s a -> a -> m ()  (P) ::   s m =>  s a -> a -> m () 9It puts the state in the monad or it gets the hose again. QMap 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)   (Q) ::   s m =>  s a -> (a -> a) -> m ()  (Q) ::   s m => - s a -> (a -> a) -> m ()  (Q) ::   s m => ' s a -> (a -> a) -> m ()  (Q) ::   s m =>  s a -> (a -> a) -> m ()    (Q) ::   s m => 4 s s a b -> (a -> b) -> m () RReplace the target of a . or all of the targets of a  or ( in our monadic  state with  y' 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)   (R) ::   s m =>  s (  a) -> a -> m ()  (R) ::   s m => - s (  a) -> a -> m ()  (R) ::   s m => ' s (  a) -> a -> m ()  (R) ::   s m =>  s (  a) -> a -> m () SModify the target(s) of a -, ,  or ( by adding a value.  Example:    fresh ::    m => m   fresh = do   c S 1    c %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")   (S) :: (  s m,   a) =>  s a -> a -> m ()  (S) :: (  s m,   a) =>  s a -> a -> m ()  (S) :: (  s m,   a) => - s a -> a -> m ()  (S) :: (  s m,   a) => ' s a -> a -> m () TModify the target(s) of a -, ,  or ( by subtracting a value. %execState (do _1 -= c; _2 -= d) (a,b) (a - c,b - d)   (T) :: (  s m,   a) =>  s a -> a -> m ()  (T) :: (  s m,   a) =>  s a -> a -> m ()  (T) :: (  s m,   a) => - s a -> a -> m ()  (T) :: (  s m,   a) => ' s a -> a -> m () UModify the target(s) of a -, ,  or ( by multiplying by value. %execState (do _1 *= c; _2 *= d) (a,b) (a * c,b * d)   (U) :: (  s m,   a) =>  s a -> a -> m ()  (U) :: (  s m,   a) =>  s a -> a -> m ()  (U) :: (  s m,   a) => - s a -> a -> m ()  (U) :: (  s m,   a) => ' s a -> a -> m () VModify the target(s) of a -, ,  or ( by dividing by a value. 'execState (do _1 //= c; _2 //= d) (a,b) (a / c,b / d)   (V) :: (  s m,   a) =>  s a -> a -> m ()  (V) :: (  s m,   a) =>  s a -> a -> m ()  (V) :: (  s m,   a) => - s a -> a -> m ()  (V) :: (  s m,   a) => ' s a -> a -> m () W,Raise the target(s) of a numerically valued .,  or (# to a non-negative integral power.   (W) :: (  s m,   a,   e) =>  s a -> e -> m ()  (W) :: (  s m,   a,   e) =>  s a -> e -> m ()  (W) :: (  s m,   a,   e) => - s a -> e -> m ()  (W) :: (  s m,   a,   e) => ' s a -> e -> m () X,Raise the target(s) of a numerically valued .,  or ( to an integral power.   (X) :: (  s m,   a,   e) =>  s a -> e -> m ()  (X) :: (  s m,   a,   e) =>  s a -> e -> m ()  (X) :: (  s m,   a,   e) => - s a -> e -> m ()  (X) :: (  s m,   a,   e) => ' s a -> e -> m () Y,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)   (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 () ZModify 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)   (Z) ::   s m =>  s   ->   -> m ()  (Z) ::   s m =>  s   ->   -> m ()  (Z) ::   s m => - s   ->   -> m ()  (Z) ::   s m => ' s   ->   -> m () [Modify 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)   ([) ::   s m =>  s   ->   -> m ()  ([) ::   s m =>  s   ->   -> m ()  ([) ::   s m => - s   ->   -> m ()  ([) ::   s m => ' s   ->   -> m () \6Run a monadic action, and set all of the targets of a .,  or ( to its result.    (\) ::   s m =>  s s a b -> m b -> m ()  (\) ::   s m => . s s a b -> m b -> m ()  (\) ::   s m => ( s s a b -> m b -> m ()  (\) ::   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 \ bar  ... will store the result in a ., , or (. ]Set with pass-through KThis is useful for chaining assignment without round-tripping through your  Y stack.    do x <-  ]) ninety_nine_bottles_of_beer_on_the_wall AIf you do not need a copy of the intermediate result, then using l P d% will avoid unused binding warnings.   (]) ::   s m =>  s s a b -> b -> m b  (]) ::   s m =>  s s a b -> b -> m b  (]) ::   s m => . s s a b -> b -> m b  (]) ::   s m => ( s s a b -> b -> m b ^Set  y a value with pass-through KThis is useful for chaining assignment without round-tripping through your  Y stack.    do x <- ( foo ^) ninety_nine_bottles_of_beer_on_the_wall AIf you do not need a copy of the intermediate result, then using l R d% will avoid unused binding warnings.   (^) ::   s m =>  s s a (  b) -> b -> m b  (^) ::   s m =>  s s a (  b) -> b -> m b  (^) ::   s m => . s s a (  b) -> b -> m b  (^) ::   s m => ( s s a (  b) -> b -> m b _,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!!!")   (_) ::  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 => ( s t a a -> a -> s -> t `Modify 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!!!")   (`) :: (  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 () a Write to a fragment of a larger Writer format. bThis is a generalization of  ! that alows you to modify just a  portion of the resulting  . cThis is a generalization of  ! that alows you to modify just a  portion of the resulting   with access to the index of an  . dThis is a generalization of   that alows you to   just a  portion of the resulting  . eThis is a generalization of   that alows you to   just a  portion of the resulting  !, with access to the index of an  . f%Map with index. This is an alias for l. /When you do not need access to the index, then >( is more liberal in what it can accept.    > l "a f l      f l "a > l   ]    f :: ) i s t a b -> (i -> a -> b) -> s -> t  f :: ,+ i s t a b -> (i -> a -> b) -> s -> t  f :: $& i s t a b -> (i -> a -> b) -> s -> t g Build an  from an -like function. Your supplied function f is required to satisfy:    f  c "a  c  f g   f h "a f (g   h) Equational reasoning:    g   f "a  c  f   g "a  c Another way to view : is that it takes a "semantic editor combinator"  and transforms it into a . hAdjust every target of an , , or $  with access to the index.    (h) "a l /When you do not need access to the index then (h)) is more liberal in what it can accept.    l A f "a l h   f    (h) :: ) i s t a b -> (i -> a -> b) -> s -> t  (h) :: ,+ i s t a b -> (i -> a -> b) -> s -> t  (h) :: $& i s t a b -> (i -> a -> b) -> s -> t i/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 (Q)) is more liberal in what it can accept.    l Q f "a l i   f    (i) ::   s m => ' i s s a b -> (i -> a -> b) -> m ()  (i) ::   s m => ,) i s s a b -> (i -> a -> b) -> m ()  (i) ::   s m => $$ i s t a b -> (i -> a -> b) -> m () jBRun an arrow command and use the output to set all the targets of  a .,  or ( to the result. j can be used very similarly to (\), except that the type of 4 the object being modified can change; for example:   & runKleisli action ((), (), ()) where 6 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     (,  ,  )   j ::   p => ! s t a b -> p s b -> p s t  j ::   p => . s t a b -> p s b -> p s t  j ::   p => ( s t a b -> p s b -> p s t  j ::   p =>  s t a b -> p s b -> p s t kk is a deprecated alias for >. l&Map with index. (Deprecated alias for f). /When you do not need access to the index, then k( is more liberal in what it can accept.    k l "a l l        l :: ) i s t a b -> (i -> a -> b) -> s -> t  l :: ,+ i s t a b -> (i -> a -> b) -> s -> t  l :: $& i s t a b -> (i -> a -> b) -> s -> t >/0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklF?/0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklF43210/:9;<=5678>?BAFHGIJKLM_NDCEOPQSTUVWXY[`Z]R^\abcde@lfghij?k>/0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijkl Rank2Types provisionalEdward Kmett <ekmett@gmail.com> TrustworthyYm   type m =  (n i) n>When you see this as an argument to a function, it expects an , o   type o =  p p=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 . in a container, 3 since it is rank-1. You can turn them back into a . with , * or use it directly with combinators like  and (). qBuild a . from a getter and a setter.    q :: : 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))   q! :: (s -> a) -> (s -> a -> s) -> - s a rBuild an index-preserving . from a c and a  S. s Build an , from a c and  a S. t0This 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)u(u') can be used in one of two scenarios: When applied to a . , it can edit the target of the . in a , structure, extracting a functorial result. When applied to a (, it can edit the E targets of the traversals, extracting an applicative summary of its  actions. 8For all that the definition of this combinator is just:    (u) "a  c DIt may be beneficial to think about it as if it had these even more  restricted types, however:    (u) ::  f => V) s t a b -> (a -> f b) -> s -> f t  (u) ::  f => .( s t a b -> (a -> f b) -> s -> f t  (u) ::  f => ]# s t a b -> (a -> f b) -> s -> f t When applied to a (, it can edit the G targets of the traversals, extracting a supplemental monoidal summary  of its actions, by choosing  f = ((,) m)   (u) :: V/ s t a b -> (a -> (r, b)) -> s -> (r, t)  (u) :: .. s t a b -> (a -> (r, b)) -> s -> (r, t)  (u) ::  m => ]) s t a b -> (a -> (m, b)) -> s -> (m, t) vModify the target of a .+ in the current state returning some extra  information of type r or modify all targets of a  ]( in the current state, extracting extra  information of type r/ and return a monoidal summary of the changes. (runState (_1 %%= \x -> (f x, g x)) (a,b) (f a,(g a,b))   (v) "a (   ) It may be useful to think of (v$), instead, as having either of the , following more restricted type signatures:   (v) ::   s m => V' s s a b -> (a -> (r, b)) -> m r  (v) ::   s m => .& s s a b -> (a -> (r, b)) -> m r  (v) :: (  s m,  r) => ]! s s a b -> (a -> (r, b)) -> m r w^Passes the result of the left side to the function on the right side (forward pipe operator).  This is the flipped version of ( +), which is more common in languages like F# as (|>) where it is needed e for inference. Here it is supplied for notational convenience and given a precedence that allows it  to be nested inside uses of ( ). 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")xInfix flipped .   (x) =    yThis is convenient to  ( argument order of composite functions. %over _2 ?? ("hello","world") $ length ("hello",5)(over ?? length ?? ("hello","world") $ _2 ("hello",5)zLift a .G so it can run under a function (or other corepresentable profunctor).   z :: . s t a b -> .% (e -> s) (e -> t) (e -> a) (e -> b) {9Merge two lenses, getters, setters, folds or traversals.    | "a {  c  c    { :: c s a -> c s' a -> c (  s s') a  { :: _ s a -> _ s' a -> _ (  s s') a  { :: - s a -> - s' a -> - (  s s') a  { ::  s a ->  s' a ->  (  s s') a  { ::  s a ->  s' a ->  (  s s') a | This is a . that updates either side of an  ', where both sides have the same type.    | "a {  c  c Left a^.chosenaRight a^.chosenaRight "hello"^.chosen"hello"Right a & chosen *~ b Right (a * b)   | :: . (  a a) (  b b) a b  | f (  a) =     f a  | f (  a) =     f a }} makes a . from two other lenses or a  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)   } :: . s t a b -> . s' t' a' b' -> . (s,s') (t,t') (a,a') (b,b')  } ::  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 seek) to a new position. This reduces the API ) for working these instances to a single ..    u w "a w  ~  x s w "a w w ~  s  y f w "a w w ~  f    ~ :: - (o a s) a  ~ :: b p => - (k p a s) a  ~ :: b p => - (g p g a s) a  Cloning a .! is one way to make sure you aren't given  something weaker, such as a ] and can be D used as a way to pass around lenses that have to be monomorphic in f. !Note: This only accepts a proper .. 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 IndexedPreservingLens# 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)  () :: V* s t a b -> (a -> b) -> s -> (b, t)  () ::  b => ]$ s t a b -> (a -> b) -> s -> (b, t) -Increment the target of a numerically valued . and return the result. 2When you do not need the result of the addition, () 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)  () :: V* s t a b -> (a -> b) -> s -> (a, t)  () ::  a => ]$ 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)  () :: V# s t a b -> b -> s -> (a, t)  () ::  a => ] 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 .3 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 .0 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 .1 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 ]D, 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'\'s 4 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'\'s state by a user supplied  function and return the old value that was replaced. When applied to a ]B, it this will return a monoidal summary of all of the old values  present. 3When you do not need the result of the operation, () is more flexible.    () ::   s m => - s a -> (a -> a) -> m a  () ::   s m =>  s a -> (a -> a) -> m a  () :: (  s m,  b) =>  s a -> (a -> a) -> m a  () ::   s m => " ((,)a) s s a b -> (a -> b) -> m aReplace the target of a . into your  'Monad'\'s state with a user supplied  value and return the old value that was replaced. When applied to a ]B, it this will return a monoidal summary of all of the old values  present. 3When you do not need the result of the operation, () 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  Ys 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 => V s s a b -> m b -> m b  () ::   s m => . s s a b -> m b -> m b (NB: This is limited to taking an actual . than admitting a ] because 5 there are potential loss of state issues otherwise.  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  S%, but requires a full lens, or close  enough.  7 overA :: Arrow ar => Lens s t a b -> ar a b -> ar s t Adjust the target of an ,' returning the intermediate result, or ! adjust all of the targets of an ^ 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 ().   () :: ,0 i s t a b -> (i -> a -> b) -> s -> (b, t)  () ::  b => ^+ 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 ^ and return a monoidal summary * of the old values along with the answer.   () :: ,0 i s t a b -> (i -> a -> b) -> s -> (a, t)  () ::  a => ^+ i s t a b -> (i -> a -> b) -> s -> (a, t) Adjust the target of an ,& returning a supplementary result, or ! adjust all of the targets of an ^ and return a monoidal summary . of the supplementary results and the answer.  () "a    () ::  f => ,/ 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 ]In particular, it is often useful to think of this function as having one of these even more  restricted type signatures:   () :: ,5 i s t a b -> (i -> a -> (r, b)) -> s -> (r, t)  () ::  r => ^0 i s t a b -> (i -> a -> (r, b)) -> s -> (r, t) Adjust the target of an ,& returning a supplementary result, or ! adjust all of the targets of an ^ within the current state, and 9 return a monoidal summary of the supplementary results.  l  f "a   (l  f)   () ::   s m => ,2 i s s a b -> (i -> a -> (r, b)) -> s -> m r  () :: (  s m,  r) => ^- i s s a b -> (i -> a -> (r, b)) -> s -> m r Adjust the target of an ,' returning the intermediate result, or ! adjust all of the targets of an ^ within the current state, and 8 return a monoidal summary of the intermediate results.   () ::   s m => ,( i s s a b -> (i -> a -> b) -> m b  () :: (  s m,  b) => ^# 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 ^ 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) => ^# i s s a b -> (i -> a -> b) -> m a A version of () that works on p. ("hello","world")^#_2"world" A version of  that works on p. $storing _2 "world" ("hello","there")("hello","world")A version of () that works on p. !("hello","there") & _2 #~ "world"("hello","world")A version of () that works on p. !("hello","world") & _2 #%~ length ("hello",5)A version of (u) that works on p. 6("hello","world") & _2 #%%~ \x -> (length x, x ++ "!")(5,("hello","world!"))A version of () that works on p. A version of () that works on p. A version of () that works on p. "("hello","world") & _2 <#%~ length(5,("hello",5))A version of () that works on p. A version of (v) that works on p. A version of () that works on p. "("hello","there") & _2 <#~ "world"("world",("hello","world"))A version of () that works on p. '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"Ymnopqrstuvwxyz{|}~`opq+,-.mnopqrstuvwxyz{|}~`.-,+ponmqsruvwxyt{|}zpqo~Ymnopqrstuvwxyz{|}~ Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred   type  =   Deprecated for two reasons.  is now p#, and we no longer use the verbose  SimpleFoo naming , convention, this has since been renamed to o for consistency. [This is an older alias for a type-restricted form of lens that is able to be passed around  in containers monomorphically. +Deprecated. This has since been renamed to p for consistency. oppo Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Trustworthy-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")0This 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'     k ~(a,b) = (\b' -> (a,b'))  k b     k ~(a,b) = (\a' -> (a',b))  k a e                        Z                           Rank2Types provisionalEdward Kmett <ekmett@gmail.com> TrustworthyUThis is a convenient alias used when consuming (indexed) getters and (indexed) folds  in a highly general fashion. Used to consume an `. @When you see this in a type signature it indicates that you can  pass the function a ., ,  ], _,  U, V , 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  _2 in limited situations, to do so, they need to be 2 monomorphic in what we are going to extract with . To be compatible  with ., ] and  V. 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 _ (or  ]&), otherwise you can only pass this a   or .. Build a % 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 abs5View the value pointed to by a , V or  .4 or the result of folding over all the results of a  _ or ] that points  at a monoidal value.        "a  c  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  , T It may be useful to think of it as having one of these more restricted signatures:     ::  s a -> s -> a   ::  m => _ 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  Y transformer stack you can use:    ::   s m =>  s a -> m a   :: (  s m,  a) => _ s a -> m a   ::   s m =>  s a -> m a   ::   s m => - s a -> m a   :: (  s m,  a) =>  s a -> m a -View a function of the value pointed to by a  or . or the result of 5 folding over the result of mapping the targets of a _ or  ].     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  , T It may be useful to think of it as having one of these more restricted signatures:     ::  s a -> (a -> r) -> s -> r   ::  m => _! 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  Y transformer stack you can use:     ::   s m =>  s a -> m a   :: (  s m,  a) => _ s a -> m a   ::   s m =>  s a -> m a   ::   s m => - s a -> m a   :: (  s m,  a) =>  s a -> m a     ::   s m =>  r s a -> (a -> r) -> m r View the value pointed to by a  or . or the - result of folding over all the results of a _ or  ]# that points at a monoidal values. This is the same operation as  with the arguments flipped. HThe fixity and semantics are such that subsequent field accesses can be  performed with ( ).  (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 -> _ s m -> m  () :: s ->  s a -> a  () :: s -> - s a -> a  () ::  m => s ->  s m -> m Use the target of a ., V, or  - in the current state, or use a summary of a  _ or ] 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) => _ 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 ., V or  - in the current state, or use a summary of a  _ or ] that  points to a monoidal value. ,evalState (uses _1 length) ("hello","world")5    ::   s m =>  s a -> (a -> r) -> m r   :: (  s m,  r) => _ 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  # that only extracts the portion of ! the log that is focused on by a  . If given a   or a ( J 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  # that only extracts the portion of ! the log that is focused on by a  . If given a   or a ( J 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  # that only extracts the portion of ! the log that is focused on by a  . If given a   or a ( J 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  # that only extracts the portion of ! the log that is focused on by a  . If given a   or a ( J 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  B the result will most likely be a nonsensical monoidal summary of f 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  C 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  B the result will most likely be a nonsensical monoidal summary of f 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  C 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. HThe 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) The result probably doesn''t have much meaning when applied to an  .  Coerce a   to a  . This is useful  when using a ( that is not simple as a  or a  .  = = non-portable provisionalEdward Kmett <ekmett@gmail.com> Trustworthy A   KIf you see this in a signature for a function, the function is expecting a  $ (in practice, this usually means a ). A   This is a limited form of a  that can only be used for  operations.  Like with a #, there are no laws to state for a . You can generate a  by using . You can also use any  or   directly as a . An analogue of  for .     :: (b -> t) ->  t b     =  .  Turn a  around to get a      =  .    =  .  un (to length) # [1,2,3]3Turn a  or V around to build a . If you have an V, - is a more powerful version of this function  that will return an V 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 V or  around and @ a value (or the current environment) through it the other way.     "a       .  "a  c review _Left "mustard"Left "mustard"review (unto succ) 56Usually  is used in the (->)  Y with a  or V-, 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  Y9 transformer stack, it is sometimes useful to be able to / the current environment, in which case one of ^ these more slightly more liberal type signatures may be beneficial to think of it as having:    ::   a m =>  s a -> m s   ::   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 V or  around and @ 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 (->)  Y with a  or V-, 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  Y9 transformer stack, it is sometimes useful to be able to / the current environment, in which case one of ^ these more slightly more liberal type signatures may be beneficial to think of it as having:    ::   a m =>  s a -> (s -> r) -> m r   ::   a m =>  s a -> (s -> r) -> m r This can be used to turn an V or  around and @ a value (or the current environment) through it the other way.     "a          "a   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 V or  around and - the current state through it the other way,  applying a function.     "a       ( f) g "a   (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  CDDC  non-portable provisionalEdward Kmett <ekmett@gmail.com> Trustworthy   type APrism' =   KIf you see this in a signature for a function, the function is expecting a . Convert 0 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 0 for examples of why you might want to do this. Build a U.   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 }. 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 . 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  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 NothingThis  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 5This  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 5This  provides a () for tweaking the target of the value of  y 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   in a  . Nothing ^? _NothingJust ()Just () ^? _NothingNothing3But you can turn it around and use it to construct   as well:  _Nothing # ()Nothing  ' is a logically uninhabited data type.  This is a ! that will always fail to match.  This 1 compares for exact equality with a given value.  only 4 # ()4 5 ^? only 4Nothing This S compares for approximate equality with a given value and a predicate for testing. 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  ! and  ". This  is "improper"I 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                        Rank2Types provisionalEdward Kmett <ekmett@gmail.com> TrustworthyThis class allows us to use ? part of the environment, changing the environment supplied by  many different  Y transformers. Unlike 4 this can change the environment of a deeply nested  Y 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 D, but can in many cases change the type of the environment as well. 3This is commonly used to lift actions in a simpler  $  Y into a  Y! with a larger environment type. )This can be used to edit pretty much any  Y. 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  Y! transformers, potentially quite  deep in a  Y 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  &   Y into a  &  Y with a larger  & type. When applied to a  ] over H multiple values, the actions for each target are executed sequentially ! and the results are aggregated. )This can be used to edit pretty much any  Y 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    ::  Y m => - s t ->  ' t m a ->  ' s m a   :: ( Y m,  c) =>  s t ->  ' t m c ->  ' s m c   :: ( Y m,  w) => - s t ->  ( r w t m c ->  ( r w s m c   :: ( Y m,  w,  c) =>  s t ->  ( r w t m c ->  ( r w s m c   :: ( Y m,  w,  ) e) => - s t ->  * e ( ( r w t m) c ->  * e ( ( r w s m) c   :: ( Y m,  w,  c,  ) e) =>  s t ->  * e ( ( r w t m) c ->  * e ( ( r w s m) c  ...  +    =   , - . + / 0 1 2 3 4 5 6 7 8 9 : ; , - . + / 0 1 2 3 4 5 6 7 8 9 : ;portable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferredThis % can be used to change the type of a  < by mapping  the elements to new values. Sadly, you can't create a valid ( for a  <, but you can  manipulate it by reading using  and reindexing it via . (over setmapped (+1) (fromList [1,2,3,4])fromList [2,3,4,5]Construct a set from a , _, ], a or V. setOf folded ["hello","world"]fromList ["hello","world"]5setOf (folded._2) [("hello",1),("world",2),("!!!",3)]fromList [1,2,3]    ::  s a -> s ->  < a   ::  = a =>   s a -> s ->  < a   ::  s a -> s ->  < a   :: - s a -> s ->  < a   ::  = a => ' s a -> s ->  < a portable provisionalEdward Kmett <ekmett@gmail.com> TrustworthyThis % can be used to change the type of a  > by mapping  the elements to new values. Sadly, you can't create a valid ( for a Set, but you can  manipulate it by reading using  and reindexing it via . Construct a set from a , _, ], a or V.    ::  ? a =>  s a -> s ->  > a   :: ( @ a,  ? a) =>   s a -> s ->  > a   ::  ? a =>  s a -> s ->  > a   ::  ? a => - s a -> s ->  > a   :: ( @ a,  ? a) => ' s a -> s ->  > a  Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Trustworthya Obtain a  ( by lifting an operation that returns a  A 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   from any  A indexed by ordinal position. Just 3^..folded[3]Nothing^..folded[][(1,2),(3,4)]^..folded.both [1,2,3,4] Obtain a   from any  A indexed by ordinal position. Form a  ! by repeating the input forever.     B "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   that replicates its input n times.     C 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]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  D f a  Obtain an  - that can be composed with to filter another ., , ,   (or (). Note: This is not a legal (M, unless you are very careful not to invalidate the predicate on the target. Note: This is also not a legal P, unless you are very careful not to inject a value that matches the predicate. *As a counter example, consider that given evens =   E the second ( law is violated:     evens  F    evens  F  G  evens ( F    F) ,So, in order for this to qualify as a legal (L 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.     H 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 (^ 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.     I 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 jNote: 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 j new values you assign also pass the predicate! Otherwise subsequent traversals will visit fewer elements  and ( fusion is not sound. "A   over the individual  J of a  .    " ::        " :: '        " ::         " :: #      %Note: This function type-checks as a ( but it doesn't satisfy the laws. It's only valid to use it  when you don'Jt insert any whitespace characters while traversing, and if your original   contains only g isolated space characters (and no other characters that count as space, such as non-breaking spaces). #A   over the individual  K of a  .    # ::        # :: '        # ::         # :: #      %Note: This function type-checks as a ( but it doesn't satisfy the laws. It's only valid to use it  when you don'Gt insert any newline characters while traversing, and if your original   contains only  isolated newline characters. $    = $     $ "a   _ 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 %    = %     % "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    ` l "a & l   ]    & ::  ( 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]]^..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  M if every target of a   is  M. andOf both (True,False)FalseandOf both (True,True)True    "a *     * ::  s   -> s ->    * ::   s   -> s ->    * :: - s   -> s ->    * ::  s   -> s ->    * :: ' s   -> s ->    * ::  s   -> s ->   +Returns  M if any target of a   is  M. orOf both (True,False)TrueorOf both (False,False)False    "a +     + ::  s   -> s ->    + ::   s   -> s ->    + :: - s   -> s ->    + ::  s   -> s ->    + :: ' s   -> s ->    + ::  s   -> s ->   ,Returns  M 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 ,     b l "a - l   ]    , ::  s a -> (a ->   ) -> s ->    , ::   s a -> (a ->   ) -> s ->    , :: - s a -> (a ->   ) -> s ->    , ::  s a -> (a ->   ) -> s ->    , :: ' s a -> (a ->   ) -> s ->    , ::  s a -> (a ->   ) -> s ->   -Returns  M if every target of a   satisfies a predicate. allOf both (>=3) (4,5)TrueallOf folded (>=2) [1..10]False    "a -     c l = - l   ]    - ::  s a -> (a ->   ) -> s ->    - ::   s a -> (a ->   ) -> s ->    - :: - s a -> (a ->   ) -> s ->    - ::  s a -> (a ->   ) -> s ->    - :: ' s a -> (a ->   ) -> s ->    - ::  s a -> (a ->   ) -> s ->   .Returns  M 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   d l = . l   ]    . ::  s a -> (a ->   ) -> s ->    . ::   s a -> (a ->   ) -> s ->    . :: - s a -> (a ->   ) -> s ->    . ::  s a -> (a ->   ) -> s ->    . :: ' s a -> (a ->   ) -> s ->    . ::  s a -> (a ->   ) -> s ->   /Calculate the  N of every number targeted by a  . productOf both (4,5)20productOf folded [1,2,3,4,5]120    "a /  @This operation may be more strict than you would expect. If you  want a lazier version use ala  N   $   / ::   a =>  s a -> s -> a  / ::   a =>   s a -> s -> a  / ::   a => - s a -> s -> a  / ::   a =>  s a -> s -> a  / ::   a => ' s a -> s -> a  / ::   a =>  s a -> s -> a 0Calculate the  O 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 0  @This operation may be more strict than you would expect. If you  want a lazier version use ala  O   $    0 _1 ::   a => (a, b) -> a  0 (   ) :: ( A f,   a) => f (a, b) -> a    0 ::   a =>  s a -> s -> a  0 ::   a =>   s a -> s -> a  0 ::   a => - s a -> s -> a  0 ::   a =>  s a -> s -> a  0 ::   a => ' s a -> s -> a  0 ::   a =>  s a -> s -> a 1&Traverse over all of the targets of a   (or ), computing an  (or )-based answer,  but unlike # do not construct a new structure. 1 generalizes   to work over any  . When passed a , 1 can work over any , but when passed a  , 1 requires  an . +traverseOf_ both putStrLn ("hello","world")helloworld    "a 1     1 _2 :: # f => (c -> f r) -> (d, c) -> f ()  1  ::  f => (a -> f b) ->   a c -> f ()    e l "a 1 l   ] !The rather specific signature of 16 allows it to be used as if the signature was any of:   1 ::  f => $ s a -> (a -> f r) -> s -> f ()  1 ::  f =>  & s a -> (a -> f r) -> s -> f ()  1 ::  f => -% s a -> (a -> f r) -> s -> f ()  1 ::  f => & s a -> (a -> f r) -> s -> f ()  1 ::  f => ' s a -> (a -> f r) -> s -> f ()  1 ::  f => $ s a -> (a -> f r) -> s -> f () 2&Traverse over all of the targets of a   (or ), computing an  (or )-based answer,  but unlike # do not construct a new structure. 2 generalizes   to work over any  . When passed a , 2 can work over any , but when passed a  , 2 requires  an .     P "a 2  &forOf_ both ("hello","world") putStrLnhelloworld!The rather specific signature of 26 allows it to be used as if the signature was any of:    f l s "a 2 l s   ]    2 ::  f => $ s a -> s -> (a -> f r) -> f ()  2 ::  f =>  & s a -> s -> (a -> f r) -> f ()  2 ::  f => -% s a -> s -> (a -> f r) -> f ()  2 ::  f => & s a -> s -> (a -> f r) -> f ()  2 ::  f => ' s a -> s -> (a -> f r) -> f ()  2 ::  f => $ s a -> s -> (a -> f r) -> f () 3&Evaluate each action in observed by a  : on a structure from left to right, ignoring the results.     Q "a 3  5sequenceAOf_ both (putStrLn "hello",putStrLn "world")helloworld   3 ::  f =>  s (f a) -> s -> f ()  3 ::  f =>   s (f a) -> s -> f ()  3 ::  f => - s (f a) -> s -> f ()  3 ::  f =>  s (f a) -> s -> f ()  3 ::  f => ' s (f a) -> s -> f ()  3 ::  f =>  s (f a) -> s -> f () 4Map each target of a  h on a structure to a monadic action, evaluate these actions from left to right, and ignore the results. 'mapMOf_ both putStrLn ("hello","world")helloworld   p "a 4     4 ::  Y m => $ s a -> (a -> m r) -> s -> m ()  4 ::  Y m =>  & s a -> (a -> m r) -> s -> m ()  4 ::  Y m => -% s a -> (a -> m r) -> s -> m ()  4 ::  Y m => & s a -> (a -> m r) -> s -> m ()  4 ::  Y m => ' s a -> (a -> m r) -> s -> m ()  4 ::  Y m => $ s a -> (a -> m r) -> s -> m () 55 is 4$ with two of its arguments flipped. 'forMOf_ both ("hello","world") putStrLnhelloworld    "a 5     5 ::  Y m => $ s a -> s -> (a -> m r) -> m ()  5 ::  Y m =>  & s a -> s -> (a -> m r) -> m ()  5 ::  Y m => -% s a -> s -> (a -> m r) -> m ()  5 ::  Y m => & s a -> s -> (a -> m r) -> m ()  5 ::  Y m => ' s a -> s -> (a -> m r) -> m ()  5 ::  Y m => $ s a -> s -> (a -> m r) -> m () 6-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 6     6 ::  Y m =>  s (m a) -> s -> m ()  6 ::  Y m =>   s (m a) -> s -> m ()  6 ::  Y m => - s (m a) -> s -> m ()  6 ::  Y m =>  s (m a) -> s -> m ()  6 ::  Y m => ' s (m a) -> s -> m ()  6 ::  Y m =>  s (m a) -> s -> m () 71The sum of a collection of actions, generalizing <. asumOf both ("hello","world") "helloworld",asumOf each (Nothing, Just "hello", Nothing) Just "hello"    R "a 7     7 ::  S f =>  s (f a) -> s -> f a  7 ::  S f =>   s (f a) -> s -> f a  7 ::  S f => - s (f a) -> s -> f a  7 ::  S f =>  s (f a) -> s -> f a  7 ::  S f => ' s (f a) -> s -> f a  7 ::  S f =>  s (f a) -> s -> f a 81The sum of a collection of actions, generalizing <. msumOf both ("hello","world") "helloworld",msumOf each (Nothing, Just "hello", Nothing) Just "hello"    T "a 8     8 ::  U m =>  s (m a) -> s -> m a  8 ::  U m =>   s (m a) -> s -> m a  8 ::  U m => - s (m a) -> s -> m a  8 ::  U m =>  s (m a) -> s -> m a  8 ::  U m => ' s (m a) -> s -> m a  8 ::  U m =>  s (m a) -> s -> m a 9/Does the element occur anywhere within a given   of the structure? %elemOf both "hello" ("hello","world")True    V "a 9     9 ::  @ a =>  s a -> a -> s ->    9 ::  @ a =>   s a -> a -> s ->    9 ::  @ a => - s a -> a -> s ->    9 ::  @ a =>  s a -> a -> s ->    9 ::  @ a => ' s a -> a -> s ->    9 ::  @ 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    W "a :     : ::  @ a =>  s a -> a -> s ->    : ::  @ a =>   s a -> a -> s ->    : ::  @ a =>  s a -> a -> s ->    : ::  @ a => - s a -> a -> s ->    : ::  @ a => ' s a -> a -> s ->    : ::  @ a =>  s a -> a -> s ->   ;)Map a function over all the targets of a  5 of a container and concatenate the resulting lists. )concatMapOf both (\x -> [x, x + 1]) (1,3) [1,2,3,4]    X "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] <+Concatenate all of the lists targeted by a   into a longer list. concatOf both ("pan","ama")"panama"    Y "a <   < "a     < ::  s [r] -> s -> [r]  < ::   s [r] -> s -> [r]  < ::  s [r] -> s -> [r]  < :: - s [r] -> s -> [r]  < :: ' s [r] -> s -> [r] =0Calculate 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  Z, - this will not terminate for infinite folds.     Z "a =  lengthOf _1 ("hello",())1lengthOf traverse [1..10]100lengthOf (traverse.traverse) [[1,2],[3,4],[5,6]]6   = (   ) :: ( A f,  A g) => f (g a) ->     = ::  s a -> s ->   = ::   s a -> s ->   = :: - s a -> s ->   = ::  s a -> s ->   = :: ' s a -> s ->  >Perform a safe  [ of a   or ( or retrieve  y 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 @ instead, which can deal 1 more gracefully with heavily left-biased trees. Left 4 ^?_LeftJust 4Right 4 ^?_LeftNothing"world" ^? ix 3Just 'l'"world" ^? ix 20Nothing   (>) "a   V    (> ) :: s ->  s a ->   a  (> ) :: s ->   s a ->   a  (> ) :: s -> - s a ->   a  (> ) :: s ->  s a ->   a  (> ) :: s -> ' s a ->   a ?Perform an *UNSAFE*  [ of a   or ( assuming that it is there. Left 4 ^?! _Left4"world" ^?! ix 3'l'   (? ) :: s ->  s a -> a  (? ) :: s ->   s a -> a  (? ) :: s -> - s a -> a  (? ) :: s ->  s a -> a  (? ) :: s -> ' s a -> a @ Retrieve the  \ entry of a   or ( or retrieve  y 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  y. constructor more quickly, but may have worse  constant factors. firstOf traverse [1..10]Just 1firstOf both (1,2)Just 1firstOf ignored ()Nothing   @ ::  s a -> s ->   a  @ ::   s a -> s ->   a  @ :: - s a -> s ->   a  @ ::  s a -> s ->   a  @ :: ' s a -> s ->   a A Retrieve the  ] entry of a   or ( or retrieve  y 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  y. constructor more quickly, but may have worse  constant factors. lastOf traverse [1..10]Just 10lastOf both (1,2)Just 2lastOf ignored ()Nothing   A ::  s a -> s ->   a  A ::   s a -> s ->   a  A :: - s a -> s ->   a  A ::  s a -> s ->   a  A :: ' s a -> s ->   a BReturns  M if this   or (( has no targets in the given container. Note: B on a valid , . or  should always return  ^.     _ "a B  /This may be rather inefficient compared to the  _ check of many containers. nullOf _1 (1,2)FalsenullOf ignored ()TruenullOf traverse []TruenullOf (element 20) [1..10]True   B (   _1   ) :: ( A f,  A g) => f (g a, b) ->      B ::  s a -> s ->    B ::   s a -> s ->    B ::  s a -> s ->    B :: - s a -> s ->    B :: ' s a -> s ->   CReturns  M if this   or () has any targets in the given container. A more "conversational" alias for this combinator is R. Note: C on a valid , . or  should always return  M.     _ "a C  /This may be rather inefficient compared to the  `    _ check of many containers. notNullOf _1 (1,2)TruenotNullOf traverse [1..10]TruenotNullOf folded []FalsenotNullOf (element 20) [1..10]False   C (   _1   ) :: ( A f,  A g) => f (g a, b) ->      C ::  s a -> s ->    C ::   s a -> s ->    C ::  s a -> s ->    C :: - s a -> s ->    C :: ' s a -> s ->   D2Obtain the maximum element (if any) targeted by a   or ( safely. Note: D on a valid , . or  will always return  y a value. maximumOf traverse [1..10]Just 10maximumOf traverse []Nothing0maximumOf (folded.filtered even) [1,4,3,6,7,9,2]Just 6    a "a  b ( c "empty")   D  aIn the interest of efficiency, This operation has semantics more strict than strictly necessary.    ($ l )- has lazier semantics but could leak memory.   D ::  = a =>  s a -> s ->   a  D ::  = a =>   s a -> s ->   a  D ::  = a =>  s a -> s ->   a  D ::  = a => - s a -> s ->   a  D ::  = a => ' s a -> s ->   a E2Obtain the minimum element (if any) targeted by a   or ( safely. Note: E on a valid , . or  will always return  y a value. minimumOf traverse [1..10]Just 1minimumOf traverse []Nothing0minimumOf (folded.filtered even) [1,4,3,6,7,9,2]Just 2    d "a  b ( c "empty")   E  aIn the interest of efficiency, This operation has semantics more strict than strictly necessary.    ($ l )- has lazier semantics but could leak memory.   E ::  = a =>  s a -> s ->   a  E ::  = a =>   s a -> s ->   a  E ::  = a =>  s a -> s ->   a  E ::  = a => - s a -> s ->   a  E ::  = a => ' s a -> s ->   a F2Obtain the maximum element (if any) targeted by a  , (, ., ,  or  according to a user supplied  e. EmaximumByOf traverse (compare `on` length) ["mustard","relish","ham"]Just "mustard"aIn the interest of efficiency, This operation has semantics more strict than strictly necessary.     cmp "a  b ( c "empty")   F  cmp    F ::  s a -> (a -> a ->  e ) -> s ->   a  F ::   s a -> (a -> a ->  e ) -> s ->   a  F ::  s a -> (a -> a ->  e ) -> s ->   a  F :: - s a -> (a -> a ->  e ) -> s ->   a  F :: ' s a -> (a -> a ->  e ) -> s ->   a G2Obtain the minimum element (if any) targeted by a  , (, .,   or  according to a user supplied  e. aIn the interest of efficiency, This operation has semantics more strict than strictly necessary. EminimumByOf traverse (compare `on` length) ["mustard","relish","ham"] Just "ham"    f cmp "a  b ( c "empty")   G  cmp    G ::  s a -> (a -> a ->  e ) -> s ->   a  G ::   s a -> (a -> a ->  e ) -> s ->   a  G ::  s a -> (a -> a ->  e ) -> s ->   a  G :: - s a -> (a -> a ->  e ) -> s ->   a  G :: ' s a -> (a -> a ->  e ) -> s ->   a HThe H function takes a . (or , ,  , or (), O a predicate and a structure and returns the leftmost element of the structure  matching the predicate, or   if there is no such element. findOf each even (1,3,4,6)Just 4findOf folded even [1,3,5,7]Nothing   H ::  s a -> (a ->   ) -> s ->   a  H ::   s a -> (a ->   ) -> s ->   a  H ::  s a -> (a ->   ) -> s ->   a  H :: - s a -> (a ->   ) -> s ->   a  H :: ' s a -> (a ->   ) -> s ->   a     "a H   j l "a H l   ] A simpler version that didn't permit indexing, would be:   H ::  ( L (  a)) s a -> (a ->   ) -> s ->   a  H l p = & l (a y -> if p a then  y a else y)   IThe I function takes a . (or , ,  , or (), d a monadic predicate and a structure and returns in the monad the leftmost element of the structure  matching the predicate, or   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   I :: ( Y m,  s a) -> (a -> m   ) -> s -> m (  a)  I :: ( Y m,   s a) -> (a -> m   ) -> s -> m (  a)  I :: ( Y m,  s a) -> (a -> m   ) -> s -> m (  a)  I :: ( Y m, - s a) -> (a -> m   ) -> s -> m (  a)  I :: ( Y m, ' s a) -> (a -> m   ) -> s -> m (  a)    I A :: (Monad m, Foldable f) => (a -> m Bool) -> f a -> m (Maybe a)  k l "a I l   ] A simpler version that didn't permit indexing, would be:   I :: Monad m =>  ( L (m (  a))) s a -> (a -> m   ) -> s -> m (  a)  I l p = & l (a y -> p a >>= x -> if x then return ( y a) else y) $ return   J A variant of &4 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   J l f "a  g f   ( l   "a J     J :: $ s a -> (a -> a -> a) -> s -> a  J ::  & s a -> (a -> a -> a) -> s -> a  J :: & s a -> (a -> a -> a) -> s -> a  J :: -% s a -> (a -> a -> a) -> s -> a  J :: ' s a -> (a -> a -> a) -> s -> a K A variant of 'R 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   K l f "a  h f   ( l   "a K     K :: $ s a -> (a -> a -> a) -> s -> a  K ::  & s a -> (a -> a -> a) -> s -> a  K :: & s a -> (a -> a -> a) -> s -> a  K :: -% s a -> (a -> a -> a) -> s -> a  K :: ' s a -> (a -> a -> a) -> s -> a L6Strictly fold right over the elements of a structure.     "a L     L :: ) s a -> (a -> r -> r) -> r -> s -> r  L ::  + s a -> (a -> r -> r) -> r -> s -> r  L :: + s a -> (a -> r -> r) -> r -> s -> r  L :: -* s a -> (a -> r -> r) -> r -> s -> r  L :: '% s a -> (a -> r -> r) -> r -> s -> r MNFold over the elements of a structure, associating to the left, but strictly.     "a M     M :: ) s a -> (r -> a -> r) -> r -> s -> r  M ::  + s a -> (r -> a -> r) -> r -> s -> r  M :: + s a -> (r -> a -> r) -> r -> s -> r  M :: -* s a -> (r -> a -> r) -> r -> s -> r  M :: '% s a -> (r -> a -> r) -> r -> s -> r N A variant of L4 that has no base case and thus may only be applied N to folds and structures such that the fold views at least one element of the  structure.    J l f "a  g f   ( l    N :: $ s a -> (a -> a -> a) -> s -> a  N ::  & s a -> (a -> a -> a) -> s -> a  N :: & s a -> (a -> a -> a) -> s -> a  N :: -% s a -> (a -> a -> a) -> s -> a  N :: ' s a -> (a -> a -> a) -> s -> a O A variant of M4 that has no base case and thus may only be applied J to folds and structures such that the fold views at least one element of  the structure.    O l f "a  f   ( l    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 PIMonadic fold over the elements of a structure, associating to the right,  i.e. from right to left.     "a P     P ::  Y m => - s a -> (a -> r -> m r) -> r -> s -> m r  P ::  Y m =>  / s a -> (a -> r -> m r) -> r -> s -> m r  P ::  Y m => / s a -> (a -> r -> m r) -> r -> s -> m r  P ::  Y m => -. s a -> (a -> r -> m r) -> r -> s -> m r  P ::  Y m => ') s a -> (a -> r -> m r) -> r -> s -> m r QHMonadic fold over the elements of a structure, associating to the left,  i.e. from left to right.     "a Q     Q ::  Y m => - s a -> (r -> a -> m r) -> r -> s -> m r  Q ::  Y m =>  / s a -> (r -> a -> m r) -> r -> s -> m r  Q ::  Y m => / s a -> (r -> a -> m r) -> r -> s -> m r  Q ::  Y m => -. s a -> (r -> a -> m r) -> r -> s -> m r  Q ::  Y m => ') s a -> (r -> a -> m r) -> r -> s -> m r RCheck 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  M for a . or . has _1 ("hello","world")True   R ::  s a -> s ->    R ::   s a -> s ->    R ::  s a -> s ->    R :: - s a -> s ->    R :: ' s a -> s ->   SCheck to see if this   or ( has no matches. hasn't _Left (Right 12)Truehasn't _Left (Left 12)FalseTThis converts a   to a  ' that returns the first element, if it  exists, as a  .   T ::  s a ->   s (  a)  T ::   s a ->   s (  a)  T ::  ( s a ->   s (  a)  T ::  . s a ->   s (  a)  T ::   s a ->   s (  a)  T ::   s a ->   s (  a) UThis converts an   to an   that returns the first index " and element, if they exist, as a  .   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)) V'Retrieve the first value targeted by a   or ( (or  y the result  from a  or . ). See also (>).     i    j "a V  This is usually applied in the  $   (->) s.    V =    T    V ::  s a -> s ->   a  V ::   s a -> s ->   a  V :: - s a -> s ->   a  V ::  s a -> s ->   a  V :: ' s a -> s ->   a LHowever, it may be useful to think of its full generality when working with  a  transformer stack:   V ::   s m =>  s a -> m (  a)  V ::   s m =>   s a -> m (  a)  V ::   s m => - s a -> m (  a)  V ::   s m =>  s a -> m (  a)  V ::   s m => ' s a -> m (  a) W1Retrieve the first index and value targeted by a   or ( (or  y the result  from a  or . ). See also (r).    W =    U This is usually applied in the  $   (->) s.    W ::  i s a -> s ->   (i, a)  W ::   i s a -> s ->   (i, a)  W :: + i s a -> s ->   (i, a)  W :: # i s a -> s ->   (i, a) LHowever, it may be useful to think of its full generality when working with  a  transformer stack:   W ::   s m =>  s a -> m (  (i, a))  W ::   s m =>   s a -> m (  (i, a))  W ::   s m => + s a -> m (  (i, a))  W ::   s m => # s a -> m (  (i, a)) X5Retrieve a function of the first value targeted by a   or  ( (or  y the result from a  or .). This is usually applied in the  $   (->) s. Y@Retrieve a function of the first index and value targeted by an   or  $ (or  y the result from an  or ,).  See also (r).    Y =    U This is usually applied in the  $   (->) s.    Y :: $ i s a -> (i -> a -> r) -> s ->   r  Y ::  & i s a -> (i -> a -> r) -> s ->   r  Y :: +% i s a -> (i -> a -> r) -> s ->   r  Y :: # i s a -> (i -> a -> r) -> s ->   r LHowever, it may be useful to think of its full generality when working with  a  transformer stack:   Y ::   s m => " i s a -> (i -> a -> r) -> m (  r)  Y ::   s m =>  $ i s a -> (i -> a -> r) -> m (  r)  Y ::   s m => +# i s a -> (i -> a -> r) -> m (  r)  Y ::   s m => # i s a -> (i -> a -> r) -> m (  r) Z'Retrieve the first value targeted by a   or ( (or  y the result  from a  or .) into the current state.    Z =    T    Z ::   s m =>  s a -> m (  a)  Z ::   s m =>   s a -> m (  a)  Z ::   s m => - s a -> m (  a)  Z ::   s m =>  s a -> m (  a)  Z ::   s m => ' s a -> m (  a) [2Retrieve the first index and value targeted by an   or $ (or  y the index  and result from an  or ,) into the current state.    [ =    U    [ ::   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)) \5Retrieve a function of the first value targeted by a   or  ( (or  y the result from a  or .) into the current state.    \ =    T    \ ::   s m =>  s a -> (a -> r) -> m (  r)  \ ::   s m =>   s a -> (a -> r) -> m (  r)  \ ::   s m => - s a -> (a -> r) -> m (  r)  \ ::   s m =>  s a -> (a -> r) -> m (  r)  \ ::   s m => ' s a -> (a -> r) -> m (  r) ]@Retrieve a function of the first index and value targeted by an   or  $ (or a function of  y the index and result from an   or ,) into the current state.    ] =    U    ] ::   s m => " i s a -> (i -> a -> r) -> m (  r)  ] ::   s m =>  $ i s a -> (i -> a -> r) -> m (  r)  ] ::   s m => +# i s a -> (i -> a -> r) -> m (  r)  ] ::   s m => # i s a -> (i -> a -> r) -> m (  r) ^This 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 . _Fold 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 _ l        _ :: & i s a -> (i -> a -> m) -> s -> m  _ ::  m =>  ( i s a -> (i -> a -> m) -> s -> m  _ :: +' i s a -> (i -> a -> m) -> s -> m  _ ::  m => #" i s a -> (i -> a -> m) -> s -> m `JRight-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 ` l        ` :: 0 i s a -> (i -> a -> r -> r) -> r -> s -> r  ` ::  2 i s a -> (i -> a -> r -> r) -> r -> s -> r  ` :: +1 i s a -> (i -> a -> r -> r) -> r -> s -> r  ` :: #, i s a -> (i -> a -> r -> r) -> r -> s -> r aMLeft-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 a l        a :: 0 i s a -> (i -> r -> a -> r) -> r -> s -> r  a ::  2 i s a -> (i -> r -> a -> r) -> r -> s -> r  a :: +1 i s a -> (i -> r -> a -> r) -> r -> s -> r  a :: #, i s a -> (i -> r -> a -> r) -> r -> s -> r b4Return 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 ,& is more flexible in what it accepts.    , l "a b l        b ::  i s a -> (i -> a ->   ) -> s ->    b ::   i s a -> (i -> a ->   ) -> s ->    b :: + i s a -> (i -> a ->   ) -> s ->    b :: # i s a -> (i -> a ->   ) -> s ->   c5Return 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 -& is more flexible in what it accepts.    - l "a c l        c ::  i s a -> (i -> a ->   ) -> s ->    c ::   i s a -> (i -> a ->   ) -> s ->    c :: + i s a -> (i -> a ->   ) -> s ->    c :: # i s a -> (i -> a ->   ) -> s ->   d=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 .& is more flexible in what it accepts.    . l "a d l        d ::  i s a -> (i -> a ->   ) -> s ->    d ::   i s a -> (i -> a ->   ) -> s ->    d :: + i s a -> (i -> a ->   ) -> s ->    d :: # i s a -> (i -> a ->   ) -> s ->   eTraverse the targets of an   or $ with access to the i, discarding the results.  When you don' t need access to the index then 1& is more flexible in what it accepts.    1 l "a  l        e ::  f => + i s a -> (i -> a -> f r) -> s -> f ()  e ::  f =>  - i s a -> (i -> a -> f r) -> s -> f ()  e ::  f => +, i s a -> (i -> a -> f r) -> s -> f ()  e ::  f => #' i s a -> (i -> a -> f r) -> s -> f () fTraverse the targets of an   or $2 with access to the index, discarding the results  (with the arguments flipped).    f "a     e  When you don' t need access to the index then 2& is more flexible in what it accepts.    2 l a "a f l a        f ::  f => + i s a -> s -> (i -> a -> f r) -> f ()  f ::  f =>  - i s a -> s -> (i -> a -> f r) -> f ()  f ::  f => +, i s a -> s -> (i -> a -> f r) -> f ()  f ::  f => #' i s a -> s -> (i -> a -> f r) -> f () g*Run monadic actions for each target of an   or $ with access to the index,  discarding the results.  When you don' t need access to the index then 4& is more flexible in what it accepts.    4 l "a  l        g ::  Y m => + i s a -> (i -> a -> m r) -> s -> m ()  g ::  Y m =>  - i s a -> (i -> a -> m r) -> s -> m ()  g ::  Y m => +, i s a -> (i -> a -> m r) -> s -> m ()  g ::  Y m => #' i s a -> (i -> a -> m r) -> s -> m () h*Run monadic actions for each target of an   or $ with access to the index, 6 discarding the results (with the arguments flipped).    h "a     g  When you don' t need access to the index then 5& is more flexible in what it accepts.    5 l a "a  l a        h ::  Y m => + i s a -> s -> (i -> a -> m r) -> m ()  h ::  Y m =>  - i s a -> s -> (i -> a -> m r) -> m ()  h ::  Y m => +, i s a -> s -> (i -> a -> m r) -> m ()  h ::  Y m => #' i s a -> s -> (i -> a -> m r) -> m () i<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 i l      i "a _    i ::  i s a -> (i -> a -> [r] ) -> s -> [r]  i ::   i s a -> (i -> a -> [r] ) -> s -> [r]  i :: + i s a -> (i -> a -> [r] ) -> s -> [r]  i :: # i s a -> (i -> a -> [r] ) -> s -> [r] jThe j function takes an   or $, a predicate that is also T supplied the index, a structure and returns the left-most element of the structure  matching the predicate, or   if there is no such element.  When you don' t need access to the index then H& is more flexible in what it accepts.    H l "a j l        j ::  i s a -> (i -> a ->   ) -> s ->   a  j ::   i s a -> (i -> a ->   ) -> s ->   a  j :: + i s a -> (i -> a ->   ) -> s ->   a  j :: # i s a -> (i -> a ->   ) -> s ->   a kThe k function takes an   or $#, a monadic predicate that is also a supplied the index, a structure and returns in the monad the left-most element of the structure  matching the predicate, or   if there is no such element.  When you don' t need access to the index then I& is more flexible in what it accepts.    I l "a k l        k ::  Y m =>  i s a -> (i -> a -> m   ) -> s -> m (  a)  k ::  Y m =>   i s a -> (i -> a -> m   ) -> s -> m (  a)  k ::  Y m => + i s a -> (i -> a -> m   ) -> s -> m (  a)  k ::  Y m => # i s a -> (i -> a -> m   ) -> s -> m (  a) lStrictly< fold right over the elements of a structure with an index.  When you don' t need access to the index then L& is more flexible in what it accepts.    L l "a l l        l :: 0 i s a -> (i -> a -> r -> r) -> r -> s -> r  l ::  2 i s a -> (i -> a -> r -> r) -> r -> s -> r  l :: +1 i s a -> (i -> a -> r -> r) -> r -> s -> r  l :: #, i s a -> (i -> a -> r -> r) -> r -> s -> r mRFold 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 M& is more flexible in what it accepts.    M l "a m l        m :: 2 i s a -> (i -> r -> a -> r) -> r -> s -> r  m ::  4 i s a -> (i -> r -> a -> r) -> r -> s -> r  m :: +3 i s a -> (i -> r -> a -> r) -> r -> s -> r  m :: #. i s a -> (i -> r -> a -> r) -> r -> s -> r nCMonadic fold right over the elements of a structure with an index.  When you don' t need access to the index then P& is more flexible in what it accepts.    P l "a n l        n ::  Y m => 4 i s a -> (i -> a -> r -> m r) -> r -> s -> m r  n ::  Y m =>  6 i s a -> (i -> a -> r -> m r) -> r -> s -> m r  n ::  Y m => +5 i s a -> (i -> a -> r -> m r) -> r -> s -> m r  n ::  Y m => #0 i s a -> (i -> a -> r -> m r) -> r -> s -> m r oVMonadic fold over the elements of a structure with an index, associating to the left.  When you don' t need access to the index then Q& is more flexible in what it accepts.    Q l "a o l        o ::  Y m => 4 i s a -> (i -> r -> a -> m r) -> r -> s -> m r  o ::  Y m =>  6 i s a -> (i -> r -> a -> m r) -> r -> s -> m r  o ::  Y m => +5 i s a -> (i -> r -> a -> m r) -> r -> s -> m r  o ::  Y m => #0 i s a -> (i -> r -> a -> m r) -> r -> s -> m r p.Extract the key-value pairs from a structure.  When you don'1t need access to the indices in the result, then (& is more flexible in what it accepts.    ( l "a  k  l   p l    p ::  i s a -> s -> [(i,a)]  p ::   i s a -> s -> [(i,a)]  p :: + i s a -> s -> [(i,a)]  p :: # i s a -> s -> [(i,a)] qAn infix version of p. rPerform a safe  [ (with index) of an   or $ or retrieve  y 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.   (r ) :: s ->  i s a ->   (i, a)  (r ) :: s ->   i s a ->   (i, a)  (r ) :: s -> + i s a ->   (i, a)  (r ) :: s -> # i s a ->   (i, a) sPerform an *UNSAFE*  [ (with index) of an   or $ assuming that it is there.   (s ) :: s ->  i s a -> (i, a)  (s ) :: s ->   i s a -> (i, a)  (s ) :: s -> + i s a -> (i, a)  (s ) :: s -> # i s a -> (i, a) t 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 $M, unless you are very careful not to invalidate the predicate on the target! u Obtain an  ! by taking elements from another   , ,,  or $ while a predicate holds.   u :: (i -> a ->  ) ->   i s a ->   i s a  u :: (i -> a ->  ) -> # i s a ->   i s a  u :: (i -> a ->  ) -> + i s a ->   i s a  u :: (i -> a ->  ) ->  i s a ->   i s a v Obtain an  # by dropping elements from another  , ,,  or $ while a predicate holds.    v :: (i -> a ->  ) ->   i s a ->   i s a  v :: (i -> a ->  ) -> # i s a ->   i s a -- see notes  v :: (i -> a ->  ) -> + i s a ->   i s a -- see notes  v :: (i -> a ->  ) ->  i s a ->   i s a  Applying v to an , or $% will still allow you to use it as a  pseudo-$Q, but if you change the value of the targets to ones where the predicate returns   M, then you will break the ( laws and (! fusion will no longer be sound. wA deprecated alias for @. h m !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvw nxyz{l   !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{l  )>?TUVXWYZ\[]RS^ !"#$%&'(,-.*+/012345678;<9:=BC@ADEFGHILMJKNOPQqrs_`abcdefghijklmnoptuvwxyz{h m !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvw nxyz{ Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Trustworthy@|Allows $$ of the value at the largest index. }$& of the element at the largest index. ~Allows $" the value at the smallest index. $) of the element with the smallest index.    type  f =  ( f) ;When you see this as an argument to a function, it expects  to be indexed if p is an instance of ] i,  to be unindexed if p is (->),  a ( if f is ,  a  if f is only Gettable,  a . if p is only a ,  a   if f is Gettable 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 (, E evaluate these actions from left to right, and collect the results. 0This function is only provided for consistency,  o is strictly more general. traverseOf each print (1,2,3)123 ((),(),())    "a  o   l "a  l  p ]    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   .      q "a      l s "a  q l s  p ]     ::  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 FEvaluate 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)]    r "a    "a    o   l "a  l  o "a l  o     ::  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 . to a monadic action, E 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)]    s "a      l "a  t l  p ]     ::  Y m => ) s t a b -> (a -> m b) -> s -> m t   ::  Y m => .( s t a b -> (a -> m b) -> s -> m t   ::  Y m => (# s t a b -> (a -> m b) -> s -> m t  is a flipped version of $, consistent with the definition of  t. $forMOf both (1,3) $ \x -> [x, x + 1][(1,3),(1,4),(2,3),(2,4)]    t "a      l "a   ( l)   l s "a  t l s  p ]     ::  Y m => ) s t a b -> s -> (a -> m b) -> m t   ::  Y m => .( s t a b -> s -> (a -> m b) -> m t   ::  Y 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)]    u "a      l "a  l  o   l "a  v  p l  w     ::  Y m =>  s t (m b) b -> s -> m t   ::  Y m => . s t (m b) b -> s -> m t   ::  Y m => ( s t (m b) b -> s -> m t This generalizes  to an arbitrary (. Note: F handles ragged inputs more intelligently, but for non-ragged inputs: &transposeOf traverse [[1,2,3],[4,5,6]][[1,4],[2,5],[3,6]]    "a     Since every . is a (, we can use this as a form of  monadic strength as well:     :: (b, [a] ) -> [(b, a)] This generalizes  x to an arbitrary (.     x "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)     ::  ( y ( &A acc)) s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t) This generalizes  z to an arbitrary (.     z "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:X 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)pAny 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)So technically, this is only a .8 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 8 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 t) to be different, it is recommended that  you use . +It is generally safer to traverse with the  rather than use this 2 combinator. However, it is sometimes convenient. !This is unsafe because if you don't supply at least as many b's as you were  given a's, then the reconstruction of t will result in an error! 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 8 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    k  ( l x)  propId l x =   (  x) [  w | w <-  l x]     ::  s a -> s -> [k (->) a s]   :: - s a -> s -> [k (->) a s]   :: ' s a -> s -> [k (->) a s]   :: + i s a -> s -> [k (] i) a s]   :: # i s a -> s -> [k (] i) a s] This converts a ( that you "know"' will target one or more elements to a . . 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    :: ( 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 ( 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.    :: ( 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   ::  m s a ->  m s' a ->  m (s,s') a   ::  m s a ->  m s' a ->  m (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   ::  i m s a ->  i m s' a ->  i m (s,s') a   ::  i m s a ->  i m s' a ->  i m (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   ::  m s a ->  m s' a ->  m (s,s') a   ::  m s a ->  m s' a ->  m (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"    ::  -> ' s a -> ' s a   ::  -> - s a -> ' s a   ::  ->  s a -> ' s a   ::  ->  s a -> ' s a   ::  ->  s a ->   s a   ::  ->   s a ->   s a   ::  -> # i s a -> # i s a   ::  -> + i s a -> # i s a   ::  ->  i s a ->   i s a   ::  ->   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    ::  -> ' s a -> ' s a   ::  -> - s a -> ' s a   ::  ->  s a -> ' s a   ::  ->  s a -> ' s a   ::  ->  s a ->   s a   ::  ->   s a ->   s a   ::  -> # i s a -> # i s a   ::  -> + i s a -> # i s a   ::  ->  i s a ->   i s a   ::  ->   i s a ->   i s a A (2 is completely characterized by its behavior on a .  Cloning a (! is one way to make sure you aren't given  something weaker, such as a   and can be H used as a way to pass around traversals that have to be monomorphic in f. !Note: This only accepts a proper ( (or .). To clone a .  as such, use . "Note: It is usually better to use . and  . than to . The P former can execute at full speed, while the latter needs to round trip through  the . Plet foo l a = (view (coerced (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   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  that passes through % whatever index it is composed with.  Clone an " yielding an " with the same index. Traversal with an index. NB: When you don'8t need access to the index then you can just apply your $  directly as a function!     "a    l =  l  p   =  o     ::  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 4Traverse with an index (and the arguments flipped).     l a "a  l a  p     "a    p      ::  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 . to a monadic action, Q evaluate these actions from left to right, and collect the results, with access  its position.  When you don't need access to the index ( is more liberal in what it can accept.     l "a  l  p       ::  Y m => ,0 i s t a b -> (i -> a -> m b) -> s -> m t   ::  Y 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, Q evaluate these actions from left to right, and collect the results, with access + its position (and the arguments flipped).     l a "a  l a  p     "a    p      ::  Y m => ,/ i s t a b -> s -> (i -> a -> m b) -> m t   ::  Y m => $* i s t a b -> s -> (i -> a -> m b) -> m t  Generalizes  x to an arbitrary $ with access to the index. ' accumulates state from right to left.     l "a  l  p       :: ,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  z to an arbitrary $ with access to the index. ' accumulates state from left to right.     l "a  l  p       :: ,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 element  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 ->  -> #  s a   ::   s a ->  ->    s a  Traverse the nth element of a  container.    "a    *Traverse (or fold) selected elements of a ( (or  3) where their ordinal positions match a predicate.    :: ' s a -> ( ->  ) -> #  s a   ::   s a -> ( ->  ) ->    s a Traverse elements of a > container where their ordinal positions matches 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 (5 is disjoint from the result of the first or returns K exactly the same results. These conditions are trivially met when given a ., , ,  or "affine" Traversal -- one that  has 0 or 1 target. Mutatis mutandis for  .     :: ( 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 gThese 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 jIf both of the inputs are indexed, the result is also indexed, so you can apply this to a pair of indexed N 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 gThese 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 zTry the second traversal. If it returns no entries, try again with for 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 O|}~  X !"#$%&'(|}~X('&%$#"! ~|}M|}~   Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Trustworthy*A  with an additional index. 2An instance must satisfy a (modified) form of the  laws:    (  ) "a    ( f)    g "a     (\i ->     (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. 'ifolded'.'asIndex' 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 M& is more flexible in what it accepts.   M l "a m 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  c Map with access to the index. The  for a .  If you don'!t need access to the index, then 5& 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 , 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")]Remap the index. Composition of ] functions. Mnemonically, the < and >: 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. IFold a container with indices returning both the indices and the values. )The result is only valid to compose in a ( , if you don' t edit the - index as edits to the index have no effect. When composed with an   or $ this yields an  (])   of the 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 GDetermines 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 i7, discarding the results (with the arguments flipped).     "a     When you don' t need access to the index then  P& is more flexible in what it accepts.    P a "a  a     *Run monadic actions for each target of an   or ^ with access to the index,  discarding the results.  When you don' t need access to the index then 4& is more flexible in what it accepts.     "a      *Run monadic actions for each target of an   or ^ with access to the index, 6 discarding the results (with the arguments flipped).     "a     When you don' t need access to the index then 5& is more flexible in what it accepts.   5 l a "a  l a     hConcatenate the results of a function of the elements of an indexed container with access to the index.  When you don' t need access to the index then  X& is more flexible in what it accepts.    X "a        "a  xSearches a container with a predicate that is also supplied the index, returning the left-most element of the structure  matching the predicate, or   if there is no such element.  When you don' t need access to the index then  & is more flexible in what it accepts.     "a      CMonadic fold right over the elements of a structure with an index.  When you don' t need access to the index then  & is more flexible in what it accepts.     "a      VMonadic fold over the elements of a structure with an index, associating to the left.  When you don' t need access to the index then  & is more flexible in what it accepts.     "a      .Extract the key-value pairs from a structure.  When you don'1t need access to the indices in the result, then  j& is more flexible in what it accepts.    j "a       4Traverse with an index (and the arguments flipped).    q a "a  a       "a    5Map each element of a structure to a monadic action, Q evaluate these actions from left to right, and collect the results, with access  the index.  When you don't need access to the index  s( is more liberal in what it can accept.    s "a      5Map each element of a structure to a monadic action, Q evaluate these actions from left to right, and collect the results, with access + its position (and the arguments flipped).    t a "a  a       "a     Generalizes  x to add access to the index. ' accumulates state from right to left.    "a       Generalizes  z to add access to the index. ' accumulates state from left to right.    "a       The position in the   is available as the index. 4The position in the list is available as the index. Z  5]^_`abcdef5`abcd]^_efP   Rank2Types provisionalEdward Kmett <ekmett@gmail.com> TrustworthyThis 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 ( 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 R. 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 0 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 R. =["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.   RR    Rank2Types experimentalEdward Kmett <ekmett@gmail.com> Trustworthy LA generic applicative transformation that maps over the immediate subterms.  is to   what   is to   This really belongs in  Data.Data. Nave ( using  3. This does not attempt to optimize the traversal. ZThis is primarily useful when the children are immediately obvious, and for benchmarking. &Find every occurrence of a given type a recursively that doesn' t require # passing through something of type a using  , while avoiding traversal . of areas that cannot contain a value of type a. This is  with a more liberal signature. Find descendants of type aU non-transitively, while avoiding computation of areas that cannot contain values of  type a using  . $ is a useful default definition for !  performs like , except when s ~ a&, it returns itself and nothing else.  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! nFirst, the user supplied function must access only one field of the specified type. That is to say the target 3 must be a single element that would be visited by  holesOnOf   CNote: 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 tailNothing7Accessing 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    :: (  s,   a) => (s -> a) -> # [Int] s aThe design of  doesn'.t allow it to search inside of values of type a for other values of type a.  % provides this additional recursion. Like , - trusts the user supplied function more than  using it directly : as the accessor. This enables reading from the resulting .* 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] This automatically constructs a ' from a field accessor. The index of the ( can be used as an offset into  (e ) or into the list  returned by  . The design of  doesn'.t allow it to search inside of values of type a for other values of type a.  H 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  instead. This more trusting version of 1 uses your function directly as the getter for a .. This means that reading from  is considerably faster than . 0However, you pay for faster access in two ways:  ( When passed an illegal field accessor,  will give you a . that quietly violates  the laws, unlike , which will give you a legal (# that avoids modifying the target. m Modifying 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   (a ) or into the list returned by  . When in doubt, use  instead.  inlineable   /     $          ! Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Trustworthy$A O type is one where we know how to extract its immediate self-similar children.  Example 1:    import Control.Applicative  import Control.Lens  import Control.Lens.Plated  import Data.Data  import Data.Data.Lens ()    data Expr  = Val   | Neg Expr  | Add Expr Expr  deriving ( @, =, ", !, ,)    instance  Expr where   f (Neg e) = Neg   f e   f (Add a b) = Add   f a   f b   _ a =   a or    instance  Expr where   =   Example 2:    import Control.Applicative  import Control.Lens  import Control.Lens.Plated  import Data.Data  import Data.Data.Lens ()    data Tree a  = Bin (Tree a) (Tree a)  | Tip a  deriving ( @, =, ", !, ,)    instance  (Tree a) where   f (Bin l r) = Bin   f l   f r   _ t =   t or    instance   a =>  (Tree a) where   =  <Note the big distinction between these two implementations. JThe former will only treat children directly in this tree as descendents, I the latter will treat trees contained in the values under the tips also  as descendants! When in doubt, pick a ( and just use the various ...Of combinators  rather than pollute  with orphan instances! >If you want to find something unplated and non-recursive with   use the ...OnOf variant with /, though those usecases are much better served % in most cases by using the existing . combinators! e.g.    (  "a    )This same ability to explicitly pass the ( in question is why there is no  analogue to uniplate's Biplate. UMoreover, since we can allow custom traversals, we implement reasonable defaults for # polymorphic data types, that only  into themselves, and not their  polymorphic arguments. (. of the immediate children of this structure. If you'.re using GHC 7.2 or newer and your type has a   instance,   will default to $ and you can choose to not override  it with your own definition. Compose through a plate <Try to apply a traversal to all transitive descendants of a  container, but . do not recurse through matching descendants.    ::  s =>   s a ->   s a   ::  s =>   s a ->   s a   ::  s => ( s s a b -> ( s s a b   ::  s => $ s s a b -> $ s s a b 'Extract the immediate descendants of a  container.    "a (  LRewrite by applying a rule everywhere you can. Ensures that the rule cannot $ be applied anywhere in the result:    propRewrite r x =   (   r) ( ( r x)) Usually  is more appropriate, but  can give better 4 compositionality. Given two single transformations f and g , you can  construct a -> f a mplus g a3 which performs both rewrites until a fixed point. LRewrite by applying a rule everywhere you can. Ensures that the rule cannot $ be applied anywhere in the result:    propRewriteOf l r x =   (   r) ( l ( l r x)) Usually   is more appropriate, but  can give better 4 compositionality. Given two single transformations f and g , you can  construct a -> f a mplus g a3 which performs both rewrites until a fixed point.    ::  a a -> (a ->   a) -> a -> a   :: - a a -> (a ->   a) -> a -> a   :: ' a a -> (a ->   a) -> a -> a   ::  a a -> (a ->   a) -> a -> a 5Rewrite recursively over part of a larger structure.    ::  a =>  s a -> (a ->   a) -> s -> s   ::  a => - s a -> (a ->   a) -> s -> s   ::  a => ' s a -> (a ->   a) -> s -> s   ::  a => 3 s a -> (a ->   a) -> s -> s FRewrite recursively over part of a larger structure using a specified .    ::  a =>  s a ->  a a -> (a ->   a) -> s -> s   ::  a => - s a -> - a a -> (a ->   a) -> s -> s   ::  a => ' s a -> ' a a -> (a ->   a) -> s -> s   ::  a =>  s a ->  a a -> (a ->   a) -> s -> s TRewrite by applying a monadic rule everywhere you can. Ensures that the rule cannot $ be applied anywhere in the result. RRewrite by applying a monadic rule everywhere you recursing with a user-specified (. A Ensures that the rule cannot be applied anywhere in the result. `Rewrite by applying a monadic rule everywhere inside of a structure located by a user-specified (. A Ensures that the rule cannot be applied anywhere in the result. `Rewrite by applying a monadic rule everywhere inside of a structure located by a user-specified (,  using a user-specified (P for recursion. Ensures that the rule cannot be applied anywhere in the result. 0Retrieve all of the transitive descendants of a  container, including itself. Given a  v that knows how to locate immediate children, retrieve all of the transitive descendants of a node, including itself.    ::   a a -> a -> [a] Given a   that knows how to find O parts of a container retrieve them and all of their descendants, recursively. Given 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  l  <Transform every element in the tree, in a bottom-up manner. 8For example, replacing negative literals with literals:   negLits =  $ \x -> case x of  Neg (Lit i) -> Lit (  i)  _ -> x WTransform every element in the tree in a bottom-up manner over a region indicated by a .    ::  a => ' s a -> (a -> a) -> s -> s   ::  a =>  s a -> (a -> a) -> s -> s  8Transform every element by recursively applying a given  in a bottom-up manner.     :: ' a a -> (a -> a) -> a -> a    ::  a a -> (a -> a) -> a -> a  3Transform every element in a region indicated by a ! by recursively applying another   in a bottom-up manner.     ::  s a -> ' a a -> (a -> a) -> s -> s    ::  s a ->  a a -> (a -> a) -> s -> s  ITransform every element in the tree, in a bottom-up manner, monadically.  HTransform every element in the tree in a region indicated by a supplied (&, in a bottom-up manner, monadically.     :: ( Y m,  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.     ::  Y 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.    ::  Y 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 =  x    k  ( x)  propId x =   (  x) [ w | w <-  x]     "a   wReturn a list of all of the editable contexts for every location in the structure, recursively, using a user-specified ( to walk each layer.    propUniverse l x =  l x    k  ( l x)  propId l x =   (  x) [ w | w <-  l x]     :: ' a a -> a -> [p a a a] {Return a list of all of the editable contexts for every location in the structure in an areas indicated by a user supplied (, recursively using .     b "a  b      ::  a => ' s a -> s -> [p 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 -> [p a a s] The one-level version of {G. 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 x    k  ( l x)  propId x =   (  x) [ w | w <-  l x]     =    An alias for 7, provided for consistency with the other combinators.     "a      ::  s a -> s -> [l (->) a a s]   :: - s a -> s -> [l (->) a a s]   :: ' s a -> s -> [l (->) a a s]   :: + i s a -> s -> [l ( i) a a s]   :: # i s a -> s -> [l ( 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 -> [l (->) a a s]   :: - s a -> - a a -> s -> [l (->) a a s]   :: ' s a -> ' a a -> s -> [l (->) a a s]   :: - s a -> + i a a -> s -> [l ( i) a a s]   :: ' s a -> # i a a -> s -> [l ( i) a a s] KPerform a fold-like computation on each value, technically a paramorphism.    ::   a a -> (a -> [r] -> r) -> a -> r KPerform a fold-like computation on each value, technically a paramorphism.    "a   !Fold the immediate children of a  container.    z c f = &  (c   f) z  The original uniplate% combinator, implemented in terms of  as a ..     "a   The resulting . is safer to use as it ignores 'over-application'. and deals gracefully with under-application,  but it is only a proper . if you don't change the list  Z! 0           $     $     /           " Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred 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 ." combinators to make them require J simple lenses, simple traversals, simple prisms or simple isos as input. #CComposition with this isomorphism is occasionally useful when your .,  ] or  has a constraint on an unused 3 argument to force that argument to agree with the # type of a used argument and avoid ScopedTypeVariables or other ugliness.  !"#  !"#  !"#  !"# Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Trustworthy$Ad hoc conversion between "strict" and "lazy" versions of a structure,  such as   or  . &.This class provides for symmetric bifunctors. '   '   ' "a  c  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 . WThis is useful when you need to store an isomorphism as a data type inside a container 6 and later reconstitute it as an overloaded function. See  or 8 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]10/ 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 #. Mnemonically, the German auf plays a similar role to /0The opposite of working  a  is working 0 an isomorphism.    0 "a    +    0 ::  s t a b -> (t -> s) -> b -> a 1BThis isomorphism can be used to convert to or from an instance of  .  LT^.from enum097^.enum :: Char'a'GNote: this is only an isomorphism from the numeric range actually used E 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. 2This can be used to lift any  into an arbitrary . 3If v is an element of a type a, and a' is a sans the element v, then 3 v is an isomorphism from    a' to a.    3 "a 4     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 4 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 00KThis 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 3 should delete its entry from the surrounding one: dfromList [("hello",fromList [("world","!!!")])] & at "hello" . non Map.empty . at "world" .~ Nothing fromList []9It can also be used in reverse to exclude a given value: non 0 # rem 10 4Just 2non 0 # rem 10 5Nothing44 p generalizes 3 (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 []55 a p generalizes 3 a$ to take any value and a predicate. This function assumes that p a holds  M& 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 []6BThe canonical isomorphism for currying and uncurrying a function.    6 = *     (fst^.curried) 3 43view curried fst 3 437BThe canonical isomorphism for uncurrying and currying a function.    7 = *        7 = + 6 ((+)^.uncurried) (1,2)38)The isomorphism for flipping a function. ((,)^.flipped) 1 2(2,1)9An 8 between the strict variant of a structure and its lazy  counterpart.    9 = + % See  4http://hackage.haskell.org/package/strict-base-types for an example  use. :An  between a list,  ,  " 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 ( to see how it associates 3 the structure and it can also be used to bake the ( into a  so / that you can traverse over it multiple times. =+This isomorphism can be used to inspect an $ to see how it associates 3 the structure and it can also be used to bake the $ into a  so S 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' ->  (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) ALift 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) B Lift two s into both arguments of a .   bimapping ::  p =>  s t a b ->  s' t' a' b' ->  (p s s') (p t t') (p a a') (p b b')  bimapping ::  p =>  s a ->  s' a' ->  (p s s') (p a a') &$%&'()*+,-./0123456789:;<=>?@AB       )HI#$%&'()*+,-./0123456789:;<=>?@AB))(*+-,./02#3451678&'$%9HI:;<=>?@AB$$%&'()*+,-./0123456789:;<=>?@AB       #Rank2, MPTCs, fundeps experimentalEdward Kmett <ekmett@gmail.com> TrustworthyEE6 provides isomorphisms to wrap and unwrap newtypes or " data types with one constructor. GAn isomorphism between s and a. IWork under a newtype wrapper. 5Const "hello" & _Wrapped %~ Prelude.length & getConst5   I "a + J  J "a + I KGiven the constructor for a E type, return a $ deconstructor that is its inverse.  Assuming the E% instance is legal, these laws hold:    K f   f "a  c  f   K f "a  c op Identity (Identity 4)4op Const (Const "hello")"hello"L This is a convenient version of I with an argument that' s ignored. The user supplied function is ignored, merely its type is used. M This is a convenient version of I with an argument that' s ignored. The user supplied function is ignored, merely its type is used. N This is a convenient version of I with an argument that' s ignored. The user supplied function is ignored, merely its types are used. O This is a convenient version of J with an argument that' s ignored. The user supplied function is ignored, merely its types are used. PThis combinator is based on ala from Conor McBride's work on Epigram. As with N0, 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]24QThis combinator is based on ala' from Conor McBride's work on Epigram. As with N0, the user supplied function for the newtype is ignored. 1alaf Sum foldMap Prelude.length ["hello","world"]10 Use 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  3. Unwrapping returns some permutation of the list. Use wrapping  3. Unwrapping returns some permutation of the list. CDEFGHIJ ! " # $ % & ' (KLMNOPQ ) * + , - . / 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 { | } ~  CDEFGHIJKLMNOPQEFGHLMDCIJNOKPQCDEFGHIJ ! " # $ % & ' (KLMNOPQ ) * + , - . / 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 { | } ~  $ non-portable provisionalEdward Kmett <ekmett@gmail.com> TrustworthySisn't _Empty [1,2,3]TrueRS RSRSRS % non-portable experimentalEdward Kmett <ekmett@gmail.com> TrustworthyTExtract U3 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  . -over each Char.toUpper ("hello"^.Text.packed)"HELLO"-("hello","world") & each.each %~ Char.toUpper("HELLO","WORLD") U :: (  i,     a,     b) => ( (  i a) (  i b) a b U ::   i => ( (  i a) (  i b) a b U :: (        U :: (        U :: (        U :: (        U :: (  a,   b) => ( (  a) (  b) a b U :: (  a,   b) => ( (  a) (  b) a b U :: (  a,   b) => ( (  a) (  b) a b U :: ( (  a) (  b) a b U :: ( (  a) (  b) a b U :: ( (  a) (  b) a b U :: ( (  a) (  b) a b U :: ( ( a) ( b) a b U :: ( (NonEmpty a) (NonEmpty b) a b U :: ( [a] [b] a b U :: ( (  c a) (  c b) a b U :: ( (  c a) (  c b) a b U :: ( (  c a) (  c b) a b U :: (  a,   b) => ( (  a) (  b) a b U :: (, (a,a,a,a,a,a,a,a,a) (b,b,b,b,b,b,b,b,b) a b U :: (( (a,a,a,a,a,a,a,a) (b,b,b,b,b,b,b,b) a b U :: ($ (a,a,a,a,a,a,a) (b,b,b,b,b,b,b) a b U :: ( (a,a,a,a,a,a) (b,b,b,b,b,b) a b U :: ( (a,a,a,a,a) (b,b,b,b,b) a b U :: ( (a,a,a,a) (b,b,b,b) a b U :: ( (a,a,a) (b,b,b) a b U :: ( (a,a) (b,b) a bTU TUTUTU & non-portable experimentalEdward Kmett <ekmett@gmail.com> TrustworthyVDThis class provides a way to attach or detach elements on the right + side of a structure in a flexible manner. W   W ::  [a] [b] ([a], a) ([b], b)  W ::  (  a) (  b) (  a, a) (  b, b)  W ::  (  a) (  b) (  a, a) (  b, b)  W ::    ( ,  )  W ::    ( ,  )  W ::    ( ,  ) XCThis class provides a way to attach or detach elements on the left + side of a structure in a flexible manner. Y   Y ::  [a] [b] (a, [a]) (b, [b])  Y ::  (  a) (  b) (a,   a) (b,   b)  Y ::  (  a) (  b) (a,   a) (b,   b)  Y ::    ( ,  )  Y ::    ( ,  )  Y ::    ( ,  ) Z[ 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]\pAttempt 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  ] :: ' (  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""This 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)  ^ :: ' (  a) (  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)  _ :: ' (  a) (  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  .  Vector.fromList "abcde" ^? _lastJust 'e'Vector.empty ^? _lastNothing&Vector.fromList "abcde" & _last .~ 'Q'fromList "abcdQ"   ` :: ' [a] a  ` :: ' (  a) a  ` :: ' (  a) a ab) an element onto the end of a container. This is an infix alias for b. Seq.fromList [] |> a fromList [a]Seq.fromList [b, c] |> afromList [b,c,a]LazyT.pack "hello" |> '!'"hello!"bb) 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!"cqAttempt 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"VWXYZ[\]^_`abc     VWXYZ[\]^_`abcXYZ[\]^VWabc_` VWXYZ[\]^_`abc     ' non-portable experimentalEdward Kmett <ekmett@gmail.com> TrustworthydA Banker's deque based on Chris Okasaki's "!Purely Functional Data Structures" fO(1). Determine of a d is  .  null emptyTruenull (singleton 1)FalsegO(1). Generate a singleton d  singleton 1 BD 1 [1] 0 []hO(1). Calculate the size of a d size (fromList [1,4,6])3iO(n) amortized. Construct a d from a list of values. fromList [1,2]BD 1 [1] 1 [2]  Check that a d8 satisfies the balance invariants and rebalance if not. defghi                 defghidehifgdefghi                 ( non-portable experimentalEdward Kmett <ekmett@gmail.com> Trustworthy jj provides a . that can be used to read, 6 write or delete the value associated with a key in a  -like  container on an ad hoc basis. An instance of j should satisfy:   m k "a k k     k!Map.fromList [(1,"world")] ^.at 1 Just "world"at 1 ?~ "hello" $ Map.emptyfromList [(1,"hello")]Note:  5-like containers form a reasonable instance, but not  -like ones, where  you cannot satisfy the . laws. l This simple ( lets you   the value at a given  key in a  0 or element at an ordinal position in a list or  . m This simple ( lets you   the value at a given  key in a  0 or element at an ordinal position in a list or  . NB: Setting the value of this ( will only set the value in  k if it is already present. !If you want to be able to insert missing values, you want k. "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 2NothingnLThis provides a common notion of a value at an index that is shared by both l and j. oThis class provides a simple  IndexedFold (or $") that lets you view (and modify) ? information about whether or not a container contains a given q. p'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]rA definition of m for types with an j instance. This is the default  if you don't specify a definition for m.    arr   i "a arr  m i  arr   [(i,e)] "a m i B e   arr    arr   i "a arr  m i  arr   [(i,e)] "a m i B e   arr 3jklmnopqrs ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7  8 9 : ; < = > ? @ A B C D E F G jklmnopqrs jksqnlmrop0jklmnopqrs ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7  8 9 : ; < = > ? @ A B C D E F G)TemplateHaskell experimentalEdward Kmett <ekmett@gmail.com> Trustworthy t Provides substitution for types uPerform substitution for types vHProvides for the extraction of free type variables, and alpha renaming. w4When performing substitution into this traversal you're not allowed 8 to substitute in a name that is bound internally or you' ll violate  the (. laws, when in doubt generate your names with  H. xHas a  yExtract (or modify) the  of something z 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. tuvwxyz{|}~      I J K L M N O P Q R S T Utuvwxyz{|}~     xyvwtuz{|}~     tuvwxyz{|}~      I J K L M N O P Q R S T U* non-portable experimentalEdward Kmett <ekmett@gmail.com>None(Name to give to generated field optics. ,makeFields-style class name and method name  Simple top-level definiton name $BType Name -> Field Names -> Target Field Name -> Definition Names &ICompute the field optics for the type identified by the given type name. > Lenses will be computed when possible, Traversals otherwise. V1Compute the field optics for a deconstructed Dec A When possible build an Iso otherwise build one optic per field. WBNormalized the Con type into a uniform positional representation, J eliminating the variance between records, infix constructors, and normal  constructors. X:Compute the positional location of the fields involved in > each constructor for a given optic definition as well as the F type of clauses to generate and the type to annotate the declaration  with. Y/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  Z  shortly after creation. [=Build the signature and definition for a single field optic. @ In the case of a singleton constructor irrefutable matches are C used to enable the resulting lenses to be used on a bottom value. \;Construct an optic clause that returns an unmodified value ; given a constructor name and the number of fields on that  constructor. ]8Construct an optic clause suitable for a Getter or Fold ? by visited the fields identified by their 0 indexed positions ^;Build 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 _&Build a clause that constructs an Iso `;Unify 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. a>Attempt to unify two given types using a running substitution b?Perform a limited substitution on type variables. This is used F when unifying rank-2 fields when trying to achieve a Getter or Fold. c<Apply a substitution to a type. This is used after unifying ( the types of the fields in unifyTypes. d?Template Haskell wants type variables declared in a forall, so C we find all free type variables in a given type and declare them. - !"#$% Z e f g h i j&' V W)constructor name, field name, field type X"outer type "normalized constructors "target definition 9optic type, definition type, field count, target fields k l m n Y [ oOuter s type pOuter s type qOuter s type r s t \ ] ^ _ ` a b c d u  !"#$%&'  !"#$%&' !"#$% Z f e g j i h&' V W X k l m n Y [ o p q r s t \ ] ^ _ ` a b c d u+ non-portable experimentalEdward Kmett <ekmett@gmail.com>None vNormalized constructor ( Generate a Prism& for each constructor of a data type.  Isos generated when possible. 9 Reviews are created for constructors with existentially $ quantified constructors and GADTs. e.g.    data FooBarBaz a  = Foo Int  | Bar a  | Baz Int Char  makePrisms '' FooBarBaz  will create   _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. 9 Reviews are created for constructors with existentially $ quantified constructors and GADTs. e.g.    data 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 AsB class of prisms. Names are selected by prefixing the constructor B name with an underscore. Constructors with multiple fields will - construct Prisms to tuples of those fields. wJMain entry point into Prism generation for a given type constructor name. *Generate prisms for the given  x yAGenerate prisms for the given type, normalized constructors, and ; an optional name to be used for generating a prism class. C This function dispatches between Iso generation, normal top-level  prisms, and classy prisms. z?Compute the full type-changing Prism type given an outer type, A list of constructors, and target constructor name. Additionally  return  M if the resulting type is a simple prism. {2Construct either a Review or Prism as appropriate |Construct an iso declaration }Construct prism expression prism  reviewer  remitter ~Construct an Iso expression iso  reviewer  remitter Construct a Review expression unto ((x,y,z) -> Con x y z) )Construct the review portion of a prism. ((x,y,z) -> Con x y z) :: b -> t (Construct the remit portion of a prism. 9 Pattern match only target constructor, no type changing (x -> case s of % Con x y z -> Right (x,y,z)  _ -> Left x  ) :: s -> Either s a 7Pattern match all constructors to enable type-changing (x -> case s of % Con x y z -> Right (x,y,z) * Other_n w -> Left (Other_n w)  ) :: s -> Either t a .Construct the remitter suitable for use in an Iso ((!Con x y z) -> (x,y,z)) :: s -> a EConstruct the classy prisms class for a given type and constructors. class ClassName r  vars in type | r ->  vars in Type where  topMethodName :: Prism' r Type  conMethodName_n :: Prism' r conTypes_n 5 conMethodName_n = topMethodName . conMethodName_n HConstruct the classy prisms instance for a given type and constructors. #instance Classname OuterType where  topMethodName = id  conMethodName_n =  prism  Normalize  * to its constructor name and field types. Compute a prism'-s name by prefixing an underscore for normal ( constructors and period for operators. +Quantify all the free variables in a type. ) v (Type constructor name )Type constructor name w* generate top-level definitions y z { | }constructors target constructor ~  ()*()*" v   () w* y z { | } ~  , non-portable experimentalEdward Kmett <ekmett@gmail.com> Trustworthy& <Monad for emitting top-level declarations as a side effect. @A data, newtype, data instance or newtype instance declaration. Datatype context. >Type constructor name, or Nothing for a data family instance. List of type parameters 6Create a concrete record type given a substitution to  detaParameters.  Constructors  , derivings :: [Name] -- currently not needed + Generate simple5 optics even when type-changing optics are possible.  (e.g. - instead of .) ,CIndicate whether or not to supply the signatures for the generated  lenses. KDisabling this can be useful if you want to provide a more restricted type ; signature or if you want to supply hand-written haddocks. -'Create the class if the constructor is  and the  / rule matches. .-3 to access the convention for naming fields in our . MDefaults 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 L provides the names of all fields in the type as well as the current field. K This extra generality enables field naming conventions that depend on the  full set of names in a type. NThe field naming rule has access to the type name, the names of all the field K of that type (including the field being named), and the name of the field  being named. 7TypeName -> FieldNames -> FieldName -> DefinitionNames /JRetrieve options such as the name of the class and method to put in it to . build a class around monomorphic data types. Classy lenses are generated * when this naming convention is provided. / TypeName -> Maybe (ClassName, MainMethodName) 0JRules for making fairly simple partial lenses, ignoring the special cases > for isomorphisms and traversals, and not making any classes. 1 Construct a , value for generating top-level definitions ; using the given map from field names to definition names. 2?Rules for making lenses and traversals that precompose another .. ?Rules for making lenses and traversals that precompose another . H using a custom function for naming the class, main class method, and a / mapping from field names to definition names. 4EBuild lenses (and traversals) with a sensible default configuration. e.g.    data FooBar  = Foo { _x, _y ::  }  | Bar { _x ::  }  4 ''FooBar  will create    x :: - FooBar   x f (Foo a b) = (\a' -> Foo a' b) <$> f a  x f (Bar a) = Bar <$> f a  y :: ' FooBar   y f (Foo a b) = (\b' -> Foo a b') <$> f b  y _ c@(Bar _) = pure c    4 = 9 0 5CMake lenses and traversals for a type, and create a class when the  type has no arguments. e.g.   " data Foo = Foo { _fooX, _fooY ::  }  5 ''Foo  will create    class HasFoo t where  foo :: - t Foo  fooX :: - t  + fooX = foo . go where go f (Foo x y) = (\x' -> Foo x' y) <$> f x  fooY :: - t  + fooY = foo . go where go f (Foo x y) = (\y' -> Foo x y') <$> f y  instance HasFoo Foo where  foo = id    5 = 9 2 6HMake lenses and traversals for a type, and create a class when the type & has no arguments. Works the same as 5 except that (a) it J expects that record field names do not begin with an underscore, (b) all L record fields are made into lenses, and (c) the resulting lens is prefixed  with an underscore. 7;Derive lenses and traversals, specifying explicit pairings  of (fieldName, lensName). KIf you map multiple names to the same label, and it is present in the same ' constructor then this will generate a (. e.g.   7 [("_foo", "fooLens"), ("baz", "lbaz")] ''Foo  7 [("_barX", "bar"), ("_barY", "bar")] ''Bar 8?Derive lenses and traversals, using a named wrapper class, and ! specifying explicit pairings of (fieldName, traversalName). Example usage:   8 "HasFoo" "foo" [("_foo", "fooLens"), ("bar", "lbar")] ''Foo 9*Build lenses with a custom configuration. :GMake lenses for all records in the given declaration quote. All record + syntax in the input will be stripped off. e.g.    declareLenses [d| " data Foo = Foo { fooX, fooY ::  }  deriving  "  |]  will create   data Foo = Foo   deriving  "  fooX, fooY :: - Foo Int ; Similar to 7!, but takes a declaration quote. <IFor each record in the declaration quote, make lenses and traversals for J it, and create a class when the type has no arguments. All record syntax $ in the input will be stripped off. e.g.    declareClassy [d| " data Foo = Foo { fooX, fooY ::  }  deriving  "  |]  will create   data Foo = Foo   deriving  "  class HasFoo t where  foo :: - t Foo ! instance HasFoo Foo where foo =  c  fooX, fooY :: HasFoo t => - t  = Similar to 8!, but takes a declaration quote. > Generate a Prism) for each constructor of each data type. e.g.    declarePrisms [d| H data Exp = Lit Int | Var String | Lambda{ bound::String, body::Exp }  |]  will create  G data 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 = A GAEDeclare lenses for each records in the given declarations, using the  specified 2. Any record syntax in the input will be stripped  off.  Transform NewtypeDs declarations to DataDs and  NewtypeInstDs to   DataInstDs. KGiven a set of names, build a map from those names to a set of fresh names  based on them. BBuild Wrapped instance for a given newtype C#Field rules for fields in the form  _prefix_fieldname  D#Field rules for fields in the form % prefixFieldname or _prefixFieldname  H 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. E%Generate overloaded field accessors. e.g    data Foo a = Foo { _fooX :: , _fooY : a }  newtype Bar = Bar { _barX ::   }  makeFields ''Foo  makeFields ''Bar  will create    _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    makeFields = 9 G FDeprecated alias for 9 ?Traverse each data, newtype, data instance or newtype instance  declaration. 7 +,-./01 (Field Name, Definition Name) 2 .Type Name -> Maybe (Class Name, Method Name)  (Field Name, Method Name) 3456789:;<=>?@A B C D EFG #()+,-./0123456789:;<=>?@ABCDEFG#47586()BEF:;<=>?@9AGDC0123./+-,1  +,-./01 2 3456789:;<=>?@A B C D EFG - non-portable experimentalEdward Kmett <ekmett@gmail.com> TrustworthyHUsed to evaluate an . IUsed to evaluate an . J Perform an .   J "a   (L) K Perform an  and modify the result.   K ::  Y m => I! m e s a -> (a -> e) -> s -> m e L Perform an . &["hello","world"]^!folded.act putStrLnhelloworldM Perform a + and collect all of the results in a list. ["ab","cd","ef"]^!!folded.acts1["ace","acf","ade","adf","bce","bcf","bde","bdf"] 1,2^!!folded.act (i -> putStr (show i ++ : ) >> getLine).each.to succ  1: aa  2: bb  bbcc N Perform a " and collect the leftmost result. Note:1 this still causes all effects for all elements. &[Just 1, Just 2, Just 3]^!?folded.acts Just (Just 1)[Just 1, Nothing]^!?folded.actsNothingO Construct an  from a monadic side-effect. 2["hello","world"]^!folded.act (\x -> [x,x ++ "!"])9["helloworld","helloworld!","hello!world","hello!world!"]   O ::  Y m => (s -> m a) ->  m s a  O sma afb a =  (sma a      afb) PA self-running , analogous to .    P "a O  c (1,"hello")^!_2.acts.to succ"ifmmp"%(1,getLine)^!!_2.acts.folded.to succ  aa  bb QApply a  Y transformer to an . R Perform an .   R "a   (T) S Perform an  and modify the result. T Perform an . U*Obtain a list of all of the results of an . V Perform an  and collect the  result. Note:1 this still causes all effects for all elements. W Construct an  from a monadic side-effect. HIJKLMNOPQRSTUVWHIJKLMNOPQRSTUVWOPJKQLMNWRSTUVIHHIJKLMNOPQRSTUVW. Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-InferredX   type X =  Y YReify a , so it can be stored safely in a container. \   type \ =  ] ] Reify an , so it can be stored safely in a container. `   type ` i =  (a i) a Reify an , so it can be stored safely in a container. d   type d =  e eReify a , so it can be stored safely in a container. hReify a , so it can be stored safely in a container. nReify a  , so it can be stored safely in a container. :This can also be useful for creatively combining folds as  n s is isomorphic to  ReaderT s [] and provides similar  instances. ;("hello","world")^..runFold ((,) <$> Fold _2 <*> Fold both)%[("world","hello"),("world","world")]q Reify an , so it can be stored safely in a container. tReify a , so it can be stored safely in a container. AThis can also be useful when combining getters in novel ways, as  t is isomorphic to '(->)'! and provides similar instances. P("hello","world","!!!")^.runGetter ((,) <$> Getter _2 <*> Getter (_1.to length)) ("world",5)w   type w =  x x A form of (4 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. xXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ /XYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~/|}~{xyzwtuvqrsnopklmhijefgdabc`]^_\YZ[X^XYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ / non-portable experimentalEdward Kmett <ekmett@gmail.com> Trustworthy $This 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. WThis 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 U (or any  , really).      ... [  L  (s ->     "Assertion Failed\n"   s)  ,  L  (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 2  type provided by Control.Monad.Error.Lens:    ::  e a -> (a -> m r) -> 2  e m r   ::   e a -> (a -> m r) -> 2  e m r   ::   e a -> (a -> m r) -> 2  e m r   ::  e a -> (a -> m r) -> 2  e m r   ::  e a -> (a -> m r) -> 2  e m r This builds a  ! for just the targets of a given U (or any  , really). J that ignores its input and just recovers with the stated monadic action.      ... [  L (  "looped")  ,  L (  "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 2  type provided by Control.Monad.Error.Lens:    ::  e a -> m r -> 2  e m r   ::   e a -> m r -> 2  e m r   ::   e a -> m r -> 2  e m r   ::  e a -> m r -> 2  e m r   ::  e a -> m r -> 2  e m r                        Rank2Types experimentalEdward Kmett <ekmett@gmail.com> Safe-Inferred?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ non-portable experimentalEdward Kmett <ekmett@gmail.com> Safe-Inferred  =?CDHIR]^_`abcdefopq      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcjklmnopqrs()+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ non-portable experimentalEdward Kmett <ekmett@gmail.com> Safe-Inferred =?CDHIR]^_`abcdefopq      !"#$%&'()*+,-./0123456789:;<=>?@Oabcdefgjklmnopqrsz{|}~      !"#$%&'(*+,-./0123456789:;<=@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnoptuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXY[\]^_`bcjklmnopqrs()+,-./0123456789:;<=>?@ABCDEFGHIJKOPQRSWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~0portable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferredCheck to see if this  matches. is _Left (Right 12)False is hex "3f79"True 1 non-portable experimentalEdward Kmett <ekmett@gmail.com> TrustworthyTraverse a strict  ) from left to right in a biased fashion. Traverse a strict  ( from left to right in a biased fashion & pretending the bytes are characters. Traverse a strict  J in a relatively balanced fashion, as a balanced tree with biased runs of  elements at the leaves. Traverse a strict  J in a relatively balanced fashion, as a balanced tree with biased runs of 9 elements at the leaves, pretending the bytes are chars. Unpack a lazy  Bytestring An $# of the individual bytes in a lazy   Unpack a lazy  ! pretending the bytes are chars. An $# of the individual bytes in a lazy  ! pretending the bytes are chars. Conversion between   and  . Should compile to a no-op. Unsafe conversion between   and  . 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. 8A way of creating ByteStrings outside the IO monad. The Int 9 argument gives the final size of the ByteString. Unlike   createAndTrim5 the ByteString is not reallocated if the final size " is less than the estimated size. Create ByteString of size l and use action f to fill it' s contents.              non-portable experimentalEdward Kmett <ekmett@gmail.com> Safe-Inferred|ABCDEFGHIJKLMNPQRSTUVWXYZ[\]^_`hituvwxy)>?qrsZaLMNTUV|LMNTUVZa)>?qrsuvwtxyABCDEFGHIJKLMNPQRSTUVWXYZ[\]^_`hi2Control.Monad.Error provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred 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 K the information about the match. This is particuarly useful when you have  a  e () where the result of the  or   isn't 7 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 . with the arguments swapped around; useful in 7 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 . with the arguments swapped around; useful in 7 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 () to select which exceptions are caught  If the  Exception0 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   1, which we duplicate here in a form suitable for  working with any   instance. DSometimes you want to catch two different sorts of error. You could  do something like    f =  _Foo handleFoo ( _Bar handleBar expr) IHowever, there are a couple of problems with this approach. The first is F that having two exception handlers is inefficient. However, the more J 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  7Helper function to provide conditional catch behavior.    ! " # $     ! " # $3Control.Monad.Primitive provisionalEdward Kmett <ekmett@gmail.com>None4portable provisionalEdward Kmett <ekmett@gmail.com> TrustworthyEvaluate the targets of a . or ( into a data structure  according to the given  %.     & =    =     =  c     :: - s a ->  % a ->  % s   :: ' s a ->  % a ->  % s   :: (a ->  ' a) -> s ->  ' s) ->  % a ->  % s Evaluate the targets of a . or ( according into a % data structure according to a given  % in parallel.   ( =      :: - s a ->  % a ->  % s   :: ' s a ->  % a ->  % s   :: ((a ->  ' a) -> s ->  ' s) ->  % a ->  % s  Transform a .,  , ,  or ( to 3 first evaluates its argument according to a given  % before proceeding.     )   ::  t =>  % a ->  % [a]  Transform a .,  , ,  or ( to , evaluate its argument according to a given  % in parallel with evaluating.     )   ::  t =>  % a ->  % [a] 5portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred$Evaluate the elements targeted by a ., (, ,   or  " according to the given strategy.  * =  6&MPTCs, Rank2Types, LiberalTypeSynonyms provisionalEdward Kmett <ekmett@gmail.com> Safe-InferredThis setter can be used to derive a new   from an old IAarray by E applying a function to each of the indices to look it up in the old  .  This is a  contravariant .    + "a >      "a 9    +  > ( b) f arr  , i "a arr  , f i   - (> ( b) f arr) "a b 7LiberalTypeSynonyms experimentalEdward Kmett <ekmett@gmail.com> Safe-Inferred Bitwise  . the target(s) of a . or . _2 .|.~ 6 $ ("hello",3) ("hello",7)   () ::  / a =>  s t a a -> a -> s -> t  () ::  / a =>  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  0 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  0 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 (), returning the result 0 (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  0 the target(s) of a . or (, returning the result 0 (or a monoidal summary of all of the results). _2 <.&.~ 7 $ ("hello",254)(6,("hello",6))   () ::  / a => # 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  0 with another value, O 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  . with another value, O 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    1 ( 2 :: 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    3 ( 1 ( 2 :: 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 4 can be productively consumed, but not reassembled. CTraverse 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 this function called bytes to match ? Alas, there is already  a function by that name in Data.ByteString.Lens. 8 non-portable experimentalEdward Kmett <ekmett@gmail.com> Safe-Inferred (or ) a list of bytes into a       "a +    x "a x     x "a x  +  "[104,101,108,108,111]^.packedBytes"hello" (or ) a   into a list of bytes     "a +    x "a x     x "a x  +  ""hello"^.packedChars.unpackedBytes[104,101,108,108,111]Traverse each   in a  . This ( walks the   in a tree-like fashion J enable zippers to seek to locations in logarithmic time and accelerating G 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 , 9   can be more efficient.  (or ) a list of characters into a   When writing back to the   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   When writing back to the   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   as characters. When writing back to the   it is assumed that every    lies between '\x00' and '\xff'. This ( walks the   in a tree-like fashion J enable zippers to seek to locations in logarithmic time and accelerating G many monoidal queries, but up to associativity (and constant factors) & it is equivalent to the much slower:     =      anyOf chars (== 'h') "hello"True9 non-portable experimentalEdward Kmett <ekmett@gmail.com> Safe-Inferred (or ) a list of bytes into a  .     "a +    x "a x     x "a x  +  8[104,101,108,108,111]^.packedBytes == Char8.pack "hello"True (or ) a   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  . This ( walks each strict   chunk in a tree-like fashion A enable zippers to seek to locations more quickly and accelerate M 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 , 9   can be more efficient.  (or ) a list of characters into a  . When writing back to the   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   When writing back to the   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   as characters. When writing back to the   it is assumed that every    lies between '\x00' and '\xff'. This ( walks each strict   chunk in a tree-like fashion A enable zippers to seek to locations more quickly and accelerate M many monoidal queries, but up to associativity (and constant factors) it is  equivalent to:     =     anyOf chars (== 'h') "hello"True: non-portable experimentalEdward Kmett <ekmett@gmail.com> Safe-InferredTraversals for ByteStrings.  (or () a list of bytes into a strict or lazy  .    x "a x     x "a x  +    "a +   (or -) a list of characters into a strict or lazy  . When writing back to the   it is assumed that every    lies between '\x00' and '\xff'.    x "a x     x "a x  +    "a +  Traverse each   in a strict or lazy   This ( walks each strict   chunk in a tree-like fashion A enable zippers to seek to locations more quickly and accelerate M many monoidal queries, but up to associativity (and constant factors) it is  equivalent to the much slower:     "a        ,  (  0x80) ::   ->   2Traverse the individual bytes in a strict or lazy   as characters. When writing back to the   it is assumed that every    lies between '\x00' and '\xff'. This ( walks each strict   chunk in a tree-like fashion A enable zippers to seek to locations more quickly and accelerate M many monoidal queries, but up to associativity (and constant factors) it is  equivalent to the much slower:     "a        ,  (  'c') ::   ->    (or ) a   into a list of bytes     "a +    x "a x     x "a x  +      ::   [ ]   ::   [ ]  (or /) a list of characters into a strict (or lazy)   When writing back to the   it is assumed that every    lies between '\x00' and '\xff'.     "a +    x "a x     x "a x  +      ::       ::       4 5 4 5; non-portable experimentalEdward Kmett <ekmett@gmail.com> Safe-Inferred Access the  6 of a   number. (a :+ b)^._realPartaa :+ b & _realPart *~ 2 a * 2 :+ b  ::  f => (a -> f a) ->   a -> f (  a) Access the  7 of a   number. (a :+ b)^._imagPartba :+ b & _imagPart *~ 2 a :+ b * 2  ::  f => (a -> f a) ->   a -> f (  a)This isn't quite a legal .. Notably the   l (? l b a) = blaw is violated when you set a  8 value with 0  9 and non-zero   : as the  :) information is lost, or with a negative  9  which flips the  : and retains a positive  9. So don't do  that! )Otherwise, this is a perfectly cromulent ..  Access the  9 of a   number.  (10.0 :+ 20.0) & _magnitude *~ 2 20.0 :+ 40.0This isn't quite a legal .. Notably the   l (? l b a) = b(law is violated when you set a negative  9. This flips the  :  and retains a positive  9. So don' t do that! )Otherwise, this is a perfectly cromulent ..  Setting the  9 of a zero   number assumes the  : is 0.  Access the  : of a   number. 4(mkPolar 10 (2-pi) & _phase +~ pi & view _phase) "H 2TrueThis isn't quite a legal .. Notably the   l (? l b a) = blaw is violated when you set a  : outside the range (- ;,  ;]. 7 The phase is always in that range when queried. So don' t do that! )Otherwise, this is a perfectly cromulent ..  Access the  < of a   number. *(2.0 :+ 3.0) & _conjugate . _imagPart -~ 1 2.0 :+ 4.02(mkPolar 10.0 2.0 ^. _conjugate . _phase) "H (-2.0)True<portable provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred IntSet isn't Foldable, but this  ) can be used to access the members of an  =. &sumOf members $ setOf folded [1,2,3,4]10This * can be used to change the contents of an  = by mapping  the elements to new values. Sadly, you can't create a valid ( for a Set, because the number of B elements might change but you can manipulate it by reading using  and  reindexing it via . (over setmapped (+1) (fromList [1,2,3,4])fromList [2,3,4,5] 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]    ::  s  -> s ->  =   ::   s  -> s ->  =   ::  s  -> s ->  =   :: - s  -> s ->  =   :: ' s  -> s ->  = =portable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferredA / stripping a prefix from a list when used as a (, 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"This is a deprecated alias for . This is a deprecated alias for . > Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred Obtain a   by splitting another  , .,  or (, according to the given splitting strategy.    ::  > a ->   s a ->   s [a]  Obtain a   by splitting another  , .,  or ( on the given delimiter. Equivalent to     ?    @.    ::  @ a => [a] ->   s a ->   s [a]  Obtain a   by splitting another  , .,  or ( on any of the given elements. Equivalent to     ?    A.    ::  @ a => [a] ->   s a ->   s [a]  Obtain a   by splitting another  , .,  or (- on elements satisfying the given predicate. Equivalent to     ?    B.    :: (a ->  ) ->   s a ->   s [a]  Obtain a   by splitting another  , .,  or (0 into chunks terminated by the given delimiter. Equivalent to     ?    @.    ::  @ a => [a] ->   s a ->   s [a]  Obtain a   by splitting another  , .,  or (6 into chunks terminated by any of the given elements. Equivalent to     C    ?    A.    ::  @ a => [a] ->   s a ->   s [a]  Obtain a   by splitting another  , .,  or ( into words9, with word boundaries indicated by the given predicate. Equivalent to     D    ?    B.    :: (a ->  ) ->   s a ->   s [a]  Obtain a   by splitting another  , .,  or ( into lines9, with line boundaries indicated by the given predicate. Equivalent to     C    ?    B.    :: (a ->  ) ->   s a ->   s [a]  Obtain a   by splitting another  , .,  or ( into length-n pieces. 7"48656c6c6f20776f726c64"^..chunking 2 folded.hex.to chr "Hello world"    ::  ->   s a ->   s [a]  Obtain a   by splitting another  , .,  or (% into chunks of the given lengths, .    ::   n => [n] ->   s a ->   s [a]  Obtain a   by splitting another  , .,  or (+ into chunks of the given lengths. Unlike  , the output  = will always be the same length as the first input argument.    ::   n => [n] ->   s a ->   s [a] 0Modify or retrieve the list of delimiters for a  >. )Modify or retrieve the policy for what a  > to do with delimiters. )Modify or retrieve the policy for what a  >& should about consecutive delimiters. ,Modify or retrieve the policy for whether a  > should drop an initial blank. ,Modify or retrieve the policy for whether a  > should drop a final blank.  n E F E F? non-portable experimentalEdward Kmett <ekmett@gmail.com> Safe-InferredA   is isomorphic to a  G   H m "a m  Seq.fromList [a,b,c] ^. viewLa :< fromList [b,c]Seq.empty ^. viewLEmptyLEmptyL ^. from viewL fromList []"review viewL $ a :< fromList [b,c]fromList [a,b,c]A   is isomorphic to a  I   J m "a m  Seq.fromList [a,b,c] ^. viewRfromList [a,b] :> cSeq.empty ^. viewREmptyREmptyR ^. from viewR fromList []"review viewR $ fromList [a,b] :> 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](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] Construct a   from a , _, ], a or V. seqOf folded ["hello","world"]fromList ["hello","world"]5seqOf (folded._2) [("hello",1),("world",2),("!!!",3)]fromList [1,2,3]    ::  s a -> s ->   a   ::   s a -> s ->   a   ::  s a -> s ->   a   :: - s a -> s ->   a   :: ' s a -> s ->   a @ non-portable experimentalEdward Kmett <ekmett@gmail.com> Trustworthy This isomorphism can be used to  K (or  L ) strict  . "hello"^.packed -- :: Text"hello"    K x "a x     L x "a x  +    "a +    "a *  K  L  This isomorphism can be used to  L (or  K) lazy  . "hello"^.unpacked -- :: String"hello"This M is provided for notational convenience rather than out of great need, since     "a +      K x "a x  +    L x "a x     "a *  L  K Convert between strict   and  M .    N x "a x     O ( P 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 U.     "a  .    "a U $Note that when just using this as a , 9  Q can  be more efficient. EncodeDecode a strict 'Text' to from strict   , via UTF-8.  utf8 # "&""\226\152\131"A non-portable experimentalEdward Kmett <ekmett@gmail.com> Trustworthy This isomorphism can be used to  R (or  S) lazy  . "hello"^.packed -- :: Text"hello"    R x "a x     S x "a x  +    "a +   This isomorphism can be used to  S (or  R) lazy  . "hello"^.unpacked -- :: String"hello"    R x "a x  +    S x "a x   This M 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   and  M .    T x "a x     P x "a x  +  (Traverse the individual characters in a  . anyOf text (=='c') "chello"True    =  .  @When the type is unambiguous, you can also use the more general U.     "a U $Note that when just using this as a , 9   can be more efficient. EncodeDecode a lazy 'Text' to from lazy   , via UTF-8. JNote: This function does not decode lazily, as it must consume the entire 0 input before deciding whether or not it fails. ByteString.unpack (utf8 # "&") [226,152,131]B non-portable experimentalEdward Kmett <ekmett@gmail.com> TrustworthyTraversals for strict or lazy    This isomorphism can be used to  R (or  S) strict or lazy  .    R x "a x     S x "a x  +    "a +  Convert between strict or lazy   and a  M.    N x "a x   5Traverse the individual characters in strict or lazy  .    =  .   This isomorphism can be used to  S (or  R) both strict or lazy  .     S x "a x     R x "a x  +  This M 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"  U V W U V WCMTPCs provisionalEdward Kmett <ekmett@gmail.com> Safe-InferredA . that focuses on the root of a  . view root $ Node 42 []42A .3 returning the direct descendants of the root of a     "a  XD Rank2Types experimentalEdward Kmett <ekmett@gmail.com> TrustworthyA ' for working with a  Y of a  value. A ' for working with a  Z of a  value. E non-portable provisionalEdward Kmett <ekmett@gmail.com> Trustworthy sliced i n provides a . that edits the n elements starting  at index i from a .. This is only a valid .( if you do not change the length of the  resulting  . ?Attempting to return a longer or shorter vector will result in  violations of the . laws. %Vector.fromList [1..10] ^. sliced 2 5fromList [3,4,5,6,7]2Vector.fromList [1..10] & sliced 2 5 . mapped .~ 0fromList [1,2,0,0,0,0,0,8,9,10] Similar to (, but returning a  . toVectorOf both (8,15)fromList [8,15]Convert a list to a   (or back) [1,2,3] ^. vectorfromList [1,2,3][1,2,3] ^. vector . from vector[1,2,3]0Vector.fromList [0,8,15] ^. from vector . vectorfromList [0,8,15] Convert a   to a version that doesn't retain any extra  memory. This (1 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]i starting index n length F non-portable provisionalEdward Kmett <ekmett@gmail.com> Trustworthy  sliced i n provides a . that edits the n elements starting  at index i from a .. This is only a valid .( if you do not change the length of the  resulting  [. ?Attempting to return a longer or shorter vector will result in  violations of the . laws. %Vector.fromList [1..10] ^. sliced 2 5fromList [3,4,5,6,7]2Vector.fromList [1..10] & sliced 2 5 . mapped .~ 0fromList [1,2,0,0,0,0,0,8,9,10]  Similar to (, but returning a  [. +toVectorOf both (8,15) :: Vector.Vector IntfromList [8,15] Convert a list to a  [ (or back.) &[1,2,3] ^. vector :: Vector.Vector IntfromList [1,2,3]'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  [0 back and forth to an initializer that when run  produces a copy of the  [.  Convert a  [ to a version that doesn't retain any extra  memory. This (1 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] i starting index n length                    GGHC experimentalEdward Kmett <ekmett@gmail.com> Safe-InferredUsed to traverse  ] data by uniplate. ;Convert from the data type to its representation (or back) '"hello"^.generic.from generic :: String"hello";Convert from the data type to its representation (or back) A  ] ( that visits every occurrence  of something  anywhere in a container. BallOf tinplate (=="Hello") (1::Int,2::Double,(),"Hello",["Hello"])True:mapMOf_ tinplate putStrLn ("hello",[(2 :: Int, "world!")])helloworld!  ^ _ ` a b c d e  ^ _ ` a b c d eHGHC experimentalEdward Kmett <ekmett@gmail.com> Safe-Inferred I Rank2Types experimentalEdward Kmett <ekmett@gmail.com> Safe-Inferred (Modify the path by adding another path. #both </>~ "bin" $ ("hello","world")("hello/bin","world/bin")   () ::  s a  f  f ->  f -> s -> a  () ::  s a  f  f ->  f -> s -> a  () :: . s a  f  f ->  f -> s -> a  () :: ( s a  f  f ->  f -> s -> a Modify the target(s) of a  ., ,  or ( by adding a path. -execState (both </>= "bin") ("hello","world")("hello/bin","world/bin")   () ::   s m =>  s  f ->  f -> m ()  () ::   s m =>  s  f ->  f -> m ()  () ::   s m => - s  f ->  f -> m ()  () ::   s m => ' s  f ->  f -> m () +Add a path onto the end of the target of a . and return the result 3When you do not need the result of the operation, () is more flexible.  +Add a path onto the end of the target of a . into  your monad's state and return the result. 3When you do not need the result of the operation, () is more flexible. #%Modify the path by adding extension. #both <.>~ "txt" $ ("hello","world")("hello.txt","world.txt")   (#) ::  s a  f  f ->   -> s -> a  (#) ::  s a  f  f ->   -> s -> a  (#) :: . s a  f  f ->   -> s -> a  (#) :: ( s a  f  f ->   -> 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  f ->   -> m ()  ($) ::   s m =>  s  f ->   -> m ()  ($) ::   s m => - s  f ->   -> m ()  ($) ::   s m => ' s  f ->   -> 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. &1Add an extension onto the end of the target of a . 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. )A .) for reading and writing to the basename Note: This is  ` a legal . unless the outer  f has both a directory Z and filename component and the generated basenames are not null and contain no directory  separators. (basename .~ "filename" $ "path/name.png""path/filename.png"*A .* for reading and writing to the directory Note: this is not a legal . unless the outer  f$ already has a directory component, ) and generated directories are not null. !"long/path/name.txt" ^. directory "long/path"+A .* for reading and writing to the extension Note: This is not a legal .2, unless you are careful to ensure that generated  extension  f* components are either null or start with  ! ! and do not contain any internal  !s. %extension .~ ".png" $ "path/name.txt""path/name.png",A .. for reading and writing to the full filename Note: This is not a legal .2, unless you are careful to ensure that generated  filename  f0 components are not null and do not contain any  elements of  "s. (filename .~ "name.txt" $ "path/name.png""path/name.txt" !"#$%&'()*+, !"#$%&'()*+,!#%' "$&()*+, !"#$%&'()*+,J Rank2Types experimentalEdward Kmett <ekmett@gmail.com> Safe-Inferred-Where the error happened. .!Error type specific information. /3The handle used by the action flagging this error. 00 the error is related to. 11 leading to this error, if any. 2What type of error it is -./0123456789:;<=>?@ABCDE-./0123456789:;<=>?@ABCDE-./0123456789:;<=>?@ABCDE-./0123456789:;<=>?@ABCDEKportable provisionalEdward Kmett <ekmett@gmail.com> Safe-InferredFThis 3 extracts can be used to model the fact that every    type is a subset of  . Embedding through the  only succeeds if the   would pass ' through unmodified when re-extracted. G@A prism that shows and reads integers in base-2 through base-36 MNote: This is an improper prism, since leading 0s are stripped when reading. "100" ^? base 16Just 256 1767707668033969 ^. re (base 36) "helloworld" gLike #$, but handles up to base-36 hLike #%, but handles up to base-36 iA safe variant of  h j,Select digits that fall into the given base kA simpler variant of &' that only prepends a dash and  doesn't know about parentheses lA simpler variant of &( that supports any base, only % recognizes an initial dash and doesn't know about parentheses H H = G 2I I = G 8J J = G 10K K = G 16L L n = * (+n) (subtract n)[1..3]^..traverse.adding 1000[1001,1002,1003]M   M n = * (subtract n) ((+n)  M n = + (L n) N N n = iso (*n) (/n)Note: This errors for n = 0 5 & multiplying 1000 +~ 35.003Dlet fahrenheit = multiplying (9/5).adding 32 in 230^.from fahrenheit110.0O   O n = * (/n) (*n)  O n = + (N n)Note: This errors for n = 0 P P n = * (**n) (**recip n)Note: This errors for n = 0 Hau (_Wrapping Sum . from (exponentiating 2)) (foldMapOf each) (3,4) == 5TrueQ Q = *    8au (_Wrapping Sum . negated) (foldMapOf each) (3,4) == 7True9au (_Wrapping Sum) (foldMapOf (each.negated)) (3,4) == -7TrueFG g h i j k lHIJKLMNOPQ FGHIJKLMNOPQ GFHIJKLMNOPQFG g h i j k lHIJKLMNOPQLControl.Exception provisionalEdward Kmett <ekmett@gmail.com> Trustworthy9RThis   is thrown by lens* when the user somehow manages to rethrow  an internal . S%There is no information carried in a .   S ::   ()  S ::    () T#This is thrown when the user calls ). URetrieve the argument given to ).  m is isomorphic to a  . 0catching _ErrorCall (error "touch down!") return "touch down!"V;A record update was performed on a constructor without the G appropriate field. This can only happen with a datatype with multiple I constructors, where some fields are in one constructor but not another. WDInformation about the source location where the record was updated. XGA record selector was applied to a constructor without the appropriate I field. This can only happen with a datatype with multiple constructors, ; where some fields are in one constructor but not another. YKInformation about the source location where the record selection occurred. Z(An uninitialised record field was used. [;Information about the source location where the record was  constructed.   [ ::   n    [ ::      \A pattern match failed. ]6Information about the source location of the pattern.   ] ::   o    ] ::      ^CA 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.   _ ::   p    _ ::      `AThere are no runnable threads, so the program is deadlocked. The   q  $ is raised in the main thread only. a%There is no information carried in a  q  .   a ::   q ()  a ::    () b"The thread is waiting to retry an *+ transaction, C but there are no other references to any TVars involved, so it can't ever  continue. c0There is no additional information carried in a  r  .   c ::   r ()  c ::    () dThe thread is blocked on an ,- , but there  are no other references to the ,- so it can't  ever continue. e0There is no additional information carried in a  s  .   e ::   s ()  e ::    () f>Thrown when the program attempts to call atomically, from the  +- package, inside another call to atomically. g0There is no additional information carried in a  t  .   g ::   t ()  g ::    () hJThrown when the runtime system detects that the computation is guaranteed K not to terminate. Note that there is no guarantee that the runtime system N will notice whether any given computation is guaranteed to terminate or not. i0There is no additional information carried in a  u  .   i ::   u ()  i ::    () jAsynchronous exceptions. kThere are several types of  v.   k ::   v  v  k ::     v l w was applied to .. mThis  B contains provides information about what assertion failed in the  . zhandling _AssertionFailed (\ xs -> "caught" <$ guard ("<interactive>" `isInfixOf` xs) ) $ assert False (return "uncaught")"caught"   m ::   x    m ::      n*Exceptions generated by array operations. oExtract information about an  y.   o ::   y  y  o ::     y pArithmetic exceptions. rExceptions that occur in the IO  Y. An  z records a N more specific error type, a descriptive string and maybe the handle that was " used when the error was flagged. GDue to their richer structure relative to other exceptions, these have ( a more carefully overloaded signature. sUnfortunately the name  ioException is taken by base for  throwing IOExceptions.    s ::   z  z  s ::     z %Many combinators for working with an  z are available  in System.IO.Error.Lens. tTraverse the strongly typed   contained in  ) where the type of your function matches  the desired  .   t :: ( f,   a)  => (a -> f a) ->   -> f   u$Catch exceptions that match a given  (or any  , really). Ucatching _AssertionFailed (assert False (return "uncaught")) $ \ _ -> return "caught""caught"   u ::  { m =>   # a -> m r -> (a -> m r) -> m r  u ::  { m => -  $ a -> m r -> (a -> m r) -> m r  u ::  { m => '   a -> m r -> (a -> m r) -> m r  u ::  { m =>   % a -> m r -> (a -> m r) -> m r  u ::  { m =>   # a -> m r -> (a -> m r) -> m r  u ::  { m =>    % a -> m r -> (a -> m r) -> m r v$Catch exceptions that match a given  (or any ), discarding K the information about the match. This is particuarly useful when you have  a  e () where the result of the  or   isn't 7 particularly valuable, just the fact that it matches. Ocatching_ _AssertionFailed (assert False (return "uncaught")) $ return "caught""caught"   v ::  { m =>    a -> m r -> m r -> m r  v ::  { m => -   a -> m r -> m r -> m r  v ::  { m => '   a -> m r -> m r -> m r  v ::  { m =>    a -> m r -> m r -> m r  v ::  { m =>    a -> m r -> m r -> m r  v ::  { m =>     a -> m r -> m r -> m r w A version of u. with the arguments swapped around; useful in 7 situations where the code for the handler is shorter. Ihandling _NonTermination (\_ -> return "caught") $ throwIO NonTermination"caught"   w ::  { m =>   # a -> (a -> m r) -> m r -> m r  w ::  { m => -  $ a -> (a -> m r) -> m r -> m r  w ::  { m => '   a -> (a -> m r) -> m r -> m r  w ::  { m =>   % a -> (a -> m r) -> m r -> m r  w ::  { m =>    % a -> (a -> m r) -> m r -> m r  w ::  { m =>   # a -> (a -> m r) -> m r -> m r x A version of v. with the arguments swapped around; useful in 7 situations where the code for the handler is shorter. Dhandling_ _NonTermination (return "caught") $ throwIO NonTermination"caught"   x ::  { m =>    a -> m r -> m r -> m r  x ::  { m => -   a -> m r -> m r -> m r  x ::  { m => '   a -> m r -> m r -> m r  x ::  { m =>    a -> m r -> m r -> m r  x ::  { m =>    a -> m r -> m r -> m r  x ::  { m =>     a -> m r -> m r -> m r y A variant of  / that takes a  (or any ) to select which  exceptions are caught (c.f.  0,  1 ). If the   0 does not match the predicate, it is re-thrown.   y ::  { m =>    a -> m r -> m (  a r)  y ::  { m => -   a -> m r -> m (  a r)  y ::  { m => '   a -> m r -> m (  a r)  y ::  { m =>    a -> m r -> m (  a r)  y ::  { m =>    a -> m r -> m (  a r)  y ::  { m =>     a -> m r -> m (  a r) z A version of y. that discards the specific exception thrown.   z ::  { m =>    a -> m r -> m (Maybe r)  z ::  { m => -   a -> m r -> m (Maybe r)  z ::  { m => '   a -> m r -> m (Maybe r)  z ::  { m =>    a -> m r -> m (Maybe r)  z ::  { m =>    a -> m r -> m (Maybe r)  z ::  { 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  Y.    { l "a  l  |    { ::    t -> t -> r  { ::    t -> t -> r | A variant of {" that can only be used within the IO  Y  (or any other  { instance) to throw an   described  by a .  Although |4 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   e 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  Y6 because it guarantees ordering with respect to other  monadic operations, whereas { does not.    | l "a  l 23    | ::  } 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 6 arbitrary expression might throw; it is a variant of   in  the same way that 5 is a variant of .  + 'mapException' "a 'over' 'mappedException' JThis 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 ~, which avoids ! the type ambiguity in the input   when using ?. 9The following maps any exception to arithmetic overflow: lhandling _Overflow (\_ -> return "caught") $ assert False (return "uncaught") & mappedException' .~ Overflow"caught"Handle arithmetic .     "a q        ::        ::      Handle arithmetic .     "a q        ::        ::      %Handle arithmetic loss of precision.     "a q        ::        ::      Handle division by zero.     "a q        ::        ::      0Handle exceptional _Denormalized floating pure.     "a q        ::        ::       Added in base/ 4.6 in response to this libraries discussion:  Mhttp://haskell.1045720.n5.nabble.com/Data-Ratio-and-exceptions-td5711246.html     "a q        ::        ::      CAn attempt was made to index an array outside its declared bounds.     "a o        ::   y     ::      VAn attempt was made to evaluate an element of an array that had not been initialized.     "a o        ::   y     ::      The current thread'%s stack exceeded its limit. Since an   has  been raised, the thread'1s stack will certainly be below its limit again, = but the programmer should take remedial action immediately.    ::   v ()   ::    ()  The program'As 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.    ::   v ()   ::    () This  % is raised by another thread calling  45,, or by the system if it needs to terminate  the thread for some reason.    ::   v ()   ::    () This  = is raised by default in the main thread of the program when G the user requests to terminate the program via the usual mechanism(s)  (e.g. Control-C in the console).    ::   v ()   ::    () ]RSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ =RSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~=uvwxyz{|}~trspqnolmjkhifgdebc`a^_\]Z[XYVWTURSLRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ M non-portable experimentalEdward Kmett <ekmett@gmail.com> Safe-InferredAny   can be thrown as an   This 7 allows you to traverse the typed value contained in a   7 where the type required by your function matches that  of the contents of the  , or construct a   value = out of whole cloth. It can also be used to catch or throw a    value as  .    ::  a =>    a   ::  a =>    a   NControl.Exception provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred+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).    ::       ::       6678679:;<:;=>?@>?@>?ABCDBCEBCF6GHIGHJGHKGLMGLNGLOGLPQRSQRTUVWUVXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~678                        \jj     g efh`_dc !" UV#$%&S'()*+,-^./]012ba3456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~tuvq     lno !"m#$%&'()R*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmknopqrstuvwxyz{|}~       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!""""""""""###############$ $ % % & &&&&&&&&&&&&&'''''' (!(("(#($(%(&('((())*)+),)-).)/)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){)|)})~))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))*************+++,,,,,,,,,,,,,,,,,,,,,,,,,,,,,------------- - - - . ..U....V....&....S......`..._...d. .!.c.".#..].$.%.&.^.'.(.).b.*.+.,.a.-/././//0/102131415161718191:1;1<2 2 2=2>2?2@2A22B3C4D4E4F4G5H6I7J7K7L7M7N7O7P7Q7R7S7T7U7V7W7X7Y8Z8[8\8]8^8_9Z9[9\9]9^9_:`: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>{?|?}?~???H@@@@@@AAAAAABBBBBBCCDDEEEEEFFFFFFFFGGGGHHHHHHHHIIIIIIIIIIIIIIIIJJJJJJJJJJJJJJJJJJJJJJJJJKK6KKKKKKKKKKLLLL LLLLLLLLLLLLLLLLLLLLLLLL LLLLLLLL=L>L?L@LALLBLLLLLLLLLLLLLLLLMMNNNNPP P P P P PPPPPPP6  !!""##$$%%&&''(())**++,,--..//00112233445566778899::;;<<==>>??@@AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ[[\\]]^^__``aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~           !"#$%&'()*+,<-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-.6/0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C67D6 EFGH I J K L M N O P Q R6STUVWGXYGXZ6/[\]^_`abcdefghijklmnopqrstuvwxyxxxzx{x|x}~6/6/6      6  6 >  >                       ! " # $ % &67 '6/ (6/ )U * + , - .6 / 06/ 1U * 26  36  46 5 6UV 76/ 86 96 5 :6 / ;6 / <6 = >U * ?UV @U * A B C D6 E B F G B F H B F I6/ J6/ K6 L M B C N6/ O6 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 F B C 6 6  6  6 >  >  >YZ> |> s>  > x                  U *   U * 66 6 6 6 / 6 U * 6 6 6 6 6 UV 6 6 66 6 67 6 6 6 6 6 6 6 6 6 6 UV.6 U * 6 6 6 )6 UV 6 6 66 66/6   6 6 (6 6 6 6 6 67 67 6>  6 6 >Y >Y N6 6 x U * 6 :             666 6666p6666         ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J67 K L M N O6 P Q6 6 P R S6 T U  V  W  W X  Y  Z  [  \  ]  ]  ^  _  _ ` a  b  c  d  d e f g h i j k l m n o p q r s t u v6 5 w! x! y! z! {! |! }! ~! ! ! ! !  6  UV UV 6 6        #  #  #  #  #  #  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # $ !$ "$ #$ $$ %$ &$ '$ ($ )$ *$ +$ ,$ -$ .$ /$ 0$ 1$ 2$ 3$ 4$ 5$ 6$ 7$ 8$ 9$ :$ ;$ <% =6 > ? @ A B @ A C6 > D% E% F G6 H I% J% K L% M% N O P Q O P R% S6 T U O V R% W X Y Z O [ R% \ O ] R% ^ _ `% a% b% c% d% e% f  g% h % i% j6 = k6~% l% m% n% o% p% q% r% s6 t& u& v& w& x& y& z& {& |& }& ~& & & & & & & & & & 67 ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ( O ] ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (  ) ) ) ) ) ) ) ) ) ) ) ) ) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +  + + + + + + + + + + + + + +  + + + + + + + + + + + + + + + + + + + + + + , , , , , , !, ", #, $, %, &, , ', (, ), *, +, ,, -, ., /, 0, 1, 2, 3, 46/ 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. {. |. }. ~/ 6   6 6/ 6  6  UV  6/ / / / / / / / / / / 1 1 1 1 1 B  B 212 2 2 2 2 2   @ A @ A @ A 6 6  6 6 6 6 / : : 6~ 6~ 6~ 6~ 6~ 6 = 6~   > >           B B B _ 66 O  R O  6  G G G G G G G G 6 T K K K K K K 6  6  6  6  6  6  6  6  6  6  6/ 6  6  6   6 3  6 6  6 6  6  L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L !L "L #L $L %L &6 ' (M )M *6  +N ,N - .lens-4.5Control.Lens.TraversalControl.Lens.GetterControl.Lens.ReviewControl.Lens.SetterControl.Lens.PrismControl.Lens.Iso Control.Lens.Internal.ReflectionControl.Lens.Internal.THControl.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.ActionControl.Lens.Internal.GetterControl.Lens.Internal.FoldControl.Lens.Internal.ZoomControl.Lens.TypeControl.Lens.LensControl.Lens.LoupeControl.Lens.TupleControl.Lens.Zoom Data.Set.LensData.HashSet.LensControl.Lens.FoldControl.Lens.IndexedControl.Lens.LevelData.Data.LensControl.Lens.PlatedControl.Lens.EqualityControl.Lens.WrappedControl.Lens.EmptyControl.Lens.EachControl.Lens.ConsControl.Lens.Internal.DequeControl.Lens.AtLanguage.Haskell.TH.LensControl.Lens.Internal.FieldTHControl.Lens.Internal.PrismTHControl.Lens.THControl.Lens.ActionControl.Lens.ReifiedControl.Lens.Internal.ExceptionControl.Lens.Extras Control.Lens.Internal.ByteStringControl.Monad.Error.LensControl.Monad.Primitive.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.List.Split.LensData.Sequence.LensData.Text.Strict.LensData.Text.Lazy.LensData.Text.LensData.Tree.LensData.Typeable.LensData.Vector.LensData.Vector.Generic.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.Instances backwardsSetterAccessorPrismIso Data.IntMapIntMapControl.Monad.Trans.State.LazyState indexed64indexed TraversalIndexedTraversalFold IndexedFoldLens IndexedLensGetter IndexedGetterLensLikeOpticalOverActioncloneBazaartakinglastOfpreview maximumOf minimumOfmapM_ traverseOf_Control.Monad.RWSRWSTMagnifyZoomzoomControl.Monad.ErrorErrorTControl.Monad.WriterWriterTControl.Monad.StateStateT _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.TypeablecastControl.Monad.Reader.ClasslocalfoldedPreludeunfoldrfoldMapfoldfoldrfoldltoListandoranyallproductsum_1 traverseOf traverse__LeftforOffor_forM_ sequence_ maximumByfindfoldr1foldl1foldr'foldl' Data.Listfoldl1'foldrMfoldlM Control.MonadMonadControl.TraversableControl.Lens.Isomorphic itraverseOfimapMOfiforMOfifor transposeuniplatebiplate contextsOfControl.Comonad.Store.ClasspospeekReifiedTraversalreflectTraversalControl.Lens.IndexedTraversalmap mapAccumRplate Data.Just isNothingextractIndexed cloneLensalaalafData.MapMapjoinSimpleControl.ExceptionHandler_AssertionFailed _ErrorCallPrism'Lens'_NonTermination_StackOverflowControl.Lens.Internal Control.LensControl.Lens.CombinatorsB BytestringControl.Lens.OperatorscatchesData.ByteStringpackunpackData.ByteString.Char8Data.ByteString.LazyData.ByteString.Lazy.Char8 ByteStringData.Text.LazySystem.FilePath extSeparatorpathSeparators Data.Char intToDigit digitToIntNumeric showSigned readSignederrorControl.Monad.STMSTMControl.Concurrent.MVarMVarFalsetrytryJust catchJustCatchIOthrowControl.Concurrent killThreadbaseControl.ApplicativeConstgetConstbifunctors-4.1.1.1Data.Bifunctorbimap Bifunctortransformers-0.4.1.0Data.Functor.IdentityIdentity runIdentitycontravariant-1.2Data.Functor.Contravariant>$ contramap Contravariantprofunctors-4.2.0.1Data.Profunctorright'left'ChoiceData.Profunctor.Unsafermaplmapdimap Profunctorreflection-1.5.1Data.ReflectionreflectReifiessemigroupoids-4.2Data.Semigroup.Traversable traverse1 Traversable1 tySynInstD'appsTappsE1toTupleTtoTupleEtoTuplePconAppsTbndrNamefromSet mkLensName_tc mkLensName_vtraversalTypeNametraversal'TypeName lensTypeName lens'TypeName isoTypeName iso'TypeNamegetterTypeName foldTypeName prismTypeNameprism'TypeNamereviewTypeNamereview'TypeNamewrappedTypeNameunwrappedTypeNamerewrappedTypeName_wrapped'ValName isoValName prismValName untoValName coerceValNamecomposeValName idValName fmapValName pureValName apValName rightDataName leftDataName reifyTypeableSettable untainted untaintedDot taintedDot ReviewableretaggedMarket'Market Reversing reversingExchangeFlowsrunFlows Deepening runDeepeningLevelZeroOneTwo deepening Indexing64 runIndexing64Indexing runIndexing runIndexed Indexable Conjoineddistrib conjoinedindexing indexing64 PretextT'PretextT runPretextTPretext'Pretext runPretextContext'ContextSellablesellIndexedComonadStoreiposipeekipeeksiseekiseeks iexperimentcontextIndexedComonadiextract iduplicateiextendIndexedFunctorifmap BazaarT1'BazaarT1 runBazaarT1Bazaar1'Bazaar1 runBazaar1Bizarre1bazaar1BazaarT'BazaarT runBazaarTBazaar' runBazaarBizarrebazaar TakingWhileMaficMolten runMoltenMagma MagmaFmap MagmaPureMagmaAprunMagmarunMaficrunTakingWhileEffect getEffect Effective effective ineffectiveAlongsideRightgetAlongsideRight AlongsideLeftgetAlongsideLeftGettablecoercenoEffectM ReifiedMonoidreifiedMappend reifiedMempty RightmostRStepRLeafRPureLeftmostLStepLLeafLPureMaxNoMaxMinNoMin Sequenced getSequenced Traversed getTraversedFolding getFoldinggetMingetMax getLeftmost getRightmost reifyFold EffectRWS getEffectRWS Magnified FocusingErr unfocusingErrErrgetErr FocusingMay unfocusingMayMaygetMay FocusingOn unfocusingOn FocusingPlusunfocusingPlus FocusingWithunfocusingWithFocusing unfocusingZoomedOver'IndexedLensLike'IndexedLensLike LensLike'Optical'Optic'Optic"IndexPreservingRelevantMonadicFoldIndexPreservingMonadicFoldIndexedRelevantMonadicFoldIndexedMonadicFoldRelevantMonadicFold MonadicFoldIndexPreservingAction IndexedActionIndexPreservingFold1 IndexedFold1Fold1IndexPreservingFoldIndexPreservingGetterAs Equality'EqualityIndexPreservingSetter'IndexPreservingSetterIndexedSetter' IndexedSetterIndexPreservingTraversal1'IndexPreservingTraversal1IndexPreservingTraversal'IndexPreservingTraversalIndexedTraversal1'IndexedTraversal1IndexedTraversal' Traversal1' Traversal1IndexPreservingLens'IndexPreservingLens IndexedLens'Setting'SettingAnIndexedSetter'AnIndexedSetterASetter'ASettermappedlifted contramappedargumentsettingsets cloneSettercloneIndexPreservingSettercloneIndexedSetterset'?~??insidechoosingchosen alongsidelocuscloneIndexPreservingLenscloneIndexedLens<%~<+~<-~<*~~<%=<+=<-=<*==<<~<<>~<<>=overA<%@~<<%@~%%@~%%@=<%@=<<%@=^#storing#~#%~#%%~#=#%=<#%~<#%=#%%=<#~<#=devoidunited SimpleLoupeLoupeField9_9Field8_8Field7_7Field6_6Field5_5Field4_4Field3_3Field2Field1 AccessingIndexedGettingtoitoviewsuses listening ilistening listenings ilisteningsiviewiviewsiuseiuses^@.coercedAReview'AReviewReview'Reviewuntoun#reviewsreusereusesAPrism'APrism withPrism clonePrismprism'withoutasidebelowisn'tmatching_Right_Just_Nothing_Voidonlynearly_Showmagnify setmappedsetOffoldingifoldingfolded64repeated 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^@..^@?^@?! ifiltered itakingWhileidroppingWhileheadOffoldByfoldByOf foldMapBy 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 ifailoverfailingdeepOfTraversableWithIndex itraverse itraversedFoldableWithIndexifoldMapifoldedifoldrifoldlifoldr'ifoldl'FunctorWithIndeximapped<..> selfIndex reindexed<.>icomposeasIndexindicesindexianyiallinonenone itraverse_ifor_imapM_iforM_ iconcatMapifindifoldrMifoldlMitoListimapMiforM imapAccumR imapAccumL ifoldMapBy ifoldMapByOflevelsilevels gtraversetinplatetemplateuponupon'onceUpon onceUpon'Plated...deepchildrenrewrite rewriteOf rewriteOn rewriteOnOfrewriteM rewriteMOf rewriteMOn rewriteMOnOfuniverse universeOf universeOn universeOnOf transform transformOn transformOf transformOnOf transformM transformMOn transformMOftransformMOnOfcontexts contextsOn contextsOnOfholesholesOn holesOnOfparaOfpara composOpFoldparts AnEquality' AnEquality IdenticalrunEqsubstEqmapEqfromEqsimplysimpleStrictstrictSwappedswappedAnIso'AnIsoisowithIsocloneIsoauaufunderenummappingnonnon'anoncurried uncurriedflippedlazyreversed involutedmagmaimagma contramapping dimappinglmappingrmapping bimapping Rewrapping RewrappedWrapped Unwrapped _Wrapped' _Unwrapped'_Wrapped _Unwrappedop _Wrapping' _Unwrapping' _Wrapping _UnwrappingAsEmpty_EmptyEacheachSnoc_SnocCons_Cons<|consuncons_head_tail_init_last|>snocunsnocDequeBDnull singletonsizefromListAtIxedixIxValueContainscontainsIndexixAtsans SubstType substType HasTypeVars typeVarsExHasNamenametypeVars 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_NormalC_RecC_InfixC_ForallC _IsStrict _NotStrict _Unpacked_ImportF_ExportF_CCall_StdCall_Unsafe_Safe_Interruptible_InlineP _SpecialiseP_SpecialiseInstP_RuleP _NoInline_Inline _Inlinable_ConLike_FunLike _AllPhases _FromPhase _BeforePhase_RuleVar _TypedRuleVar_FunDep_TypeFam_DataFam_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_EqualPDefName MethodNameTopName LensRules _simpleLenses _generateSigs_generateClasses _allowIsos _fieldToDef _classyLensesmakeFieldOpticsmakeFieldOpticsForDec makePrismsmakeClassyPrisms makeDecPrisms simpleLensesgenerateSignatures createClass lensField lensClass lensRules lensRulesFor classyRules classyRules_ makeLenses makeClassy makeClassy_ makeLensesFor makeClassyFormakeLensesWith declareLensesdeclareLensesFor declareClassydeclareClassyFor declarePrismsdeclareWrapped declareFieldsdeclareLensesWith makeWrappedunderscoreFieldscamelCaseFields makeFieldsmakeFieldsWithdefaultFieldRules IndexedActingActingperformperforms^!^!!^!?actactsliftActiperform iperforms^@!^@!!^@!?iact ReifiedPrism' ReifiedPrismrunPrism ReifiedIso' ReifiedIsorunIsoReifiedIndexedSetter'ReifiedIndexedSetterrunIndexedSetterReifiedSetter' ReifiedSetter runSetterReifiedMonadicFoldrunMonadicFoldReifiedIndexedFoldrunIndexedFold ReifiedFoldrunFoldReifiedIndexedGetterrunIndexedGetter ReifiedGetter runGetterReifiedTraversal' runTraversalReifiedIndexedTraversal'ReifiedIndexedTraversalrunIndexedTraversalReifiedIndexedLens'ReifiedIndexedLensrunIndexedLens ReifiedLens' ReifiedLensrunLensHandlingException Handleablehandlerhandler_istraversedStricttraversedStrict8traversedStrictTreetraversedStrictTree8 unpackLazy traversedLazy unpackLazy8traversedLazy8 unpackStrict unpackStrict8catching catching_handling handling_tryingthrowingprimevalOfparOfafter throughoutseqOfixmapped.|.~.&.~.&.=.|.=<.|.~<.&.~<.&.=<.|.=<<.&.~<<.|.~<<.&.=<<.|.=bitAtbyteAtbitsbytewise packedBytes unpackedBytesbytes packedChars unpackedCharschars IsByteString _realPart_polar _magnitude_phase _conjugatemembersprefixedsuffixed stripSuffixstrippingPrefixstrippingSuffix splitting splittingOnsplittingOneOf splittingWhenendingBy endingByOneOf wordingByliningBychunkingsplittingPlacessplittingPlacesBlanks delimiters delimiting condensingkeepInitialBlankskeepFinalBlanksviewLviewRslicedTo slicedFromslicedpackedunpacked_Textbuildertextutf8IsTextrootbranches_cast_gcast toVectorOfvectorforcedordinalsasStream asStreamRcloned 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 getSysconfDirgetDataFileNametemplate-haskellLanguage.Haskell.TH.Lib tySynInstDLanguage.Haskell.TH.SyntaxName TyVarBndrData.Typeable.InternalTypeableStableWT255T254T253T252T251T250T249T248T247T246T245T244T243T242T241T240T239T238T237T236T235T234T233T232T231T230T229T228T227T226T225T224T223T222T221T220T219T218T217T216T215T214T213T212T211T210T209T208T207T206T205T204T203T202T201T200T199T198T197T196T195T194T193T192T191T190T189T188T187T186T185T184T183T182T181T180T179T178T177T176T175T174T173T172T171T170T169T168T167T166T165T164T163T162T161T160T159T158T157T156T155T154T153T152T151T150T149T148T147T146T145T144T143T142T141T140T139T138T137T136T135T134T133T132T131T130T129T128T127T126T125T124T123T122T121T120T119T118T117T116T115T114T113T112T111T110T109T108T107T106T105T104T103T102T101T100T99T98T97T96T95T94T93T92T91T90T89T88T87T86T85T84T83T82T81T80T79T78T77T76T75T74T73T72T71T70T69T68T67T66T65T64T63T62T61T60T59T58T57T56T55T54T53T52T51T50T49T48T47T46T45T44T43T42T41T40T39T38T37T36T35T34T33T32T31T30T29T28T27T26T25T24T23T22T21T20T19T18T17T16T15T14T13T12T11T10T9T8T7T6T5T4T3T2T1T0 reflectByte impossible reifyBytestablestablePtrToIntPtrintPtrToStablePtrbyte0byte1byte2byte3byte4byte5byte6byte7 reflectBefore$fReifies*Stablea$fBT255$fBT254$fBT253$fBT252$fBT251$fBT250$fBT249$fBT248$fBT247$fBT246$fBT245$fBT244$fBT243$fBT242$fBT241$fBT240$fBT239$fBT238$fBT237$fBT236$fBT235$fBT234$fBT233$fBT232$fBT231$fBT230$fBT229$fBT228$fBT227$fBT226$fBT225$fBT224$fBT223$fBT222$fBT221$fBT220$fBT219$fBT218$fBT217$fBT216$fBT215$fBT214$fBT213$fBT212$fBT211$fBT210$fBT209$fBT208$fBT207$fBT206$fBT205$fBT204$fBT203$fBT202$fBT201$fBT200$fBT199$fBT198$fBT197$fBT196$fBT195$fBT194$fBT193$fBT192$fBT191$fBT190$fBT189$fBT188$fBT187$fBT186$fBT185$fBT184$fBT183$fBT182$fBT181$fBT180$fBT179$fBT178$fBT177$fBT176$fBT175$fBT174$fBT173$fBT172$fBT171$fBT170$fBT169$fBT168$fBT167$fBT166$fBT165$fBT164$fBT163$fBT162$fBT161$fBT160$fBT159$fBT158$fBT157$fBT156$fBT155$fBT154$fBT153$fBT152$fBT151$fBT150$fBT149$fBT148$fBT147$fBT146$fBT145$fBT144$fBT143$fBT142$fBT141$fBT140$fBT139$fBT138$fBT137$fBT136$fBT135$fBT134$fBT133$fBT132$fBT131$fBT130$fBT129$fBT128$fBT127$fBT126$fBT125$fBT124$fBT123$fBT122$fBT121$fBT120$fBT119$fBT118$fBT117$fBT116$fBT115$fBT114$fBT113$fBT112$fBT111$fBT110$fBT109$fBT108$fBT107$fBT106$fBT105$fBT104$fBT103$fBT102$fBT101$fBT100$fBT99$fBT98$fBT97$fBT96$fBT95$fBT94$fBT93$fBT92$fBT91$fBT90$fBT89$fBT88$fBT87$fBT86$fBT85$fBT84$fBT83$fBT82$fBT81$fBT80$fBT79$fBT78$fBT77$fBT76$fBT75$fBT74$fBT73$fBT72$fBT71$fBT70$fBT69$fBT68$fBT67$fBT66$fBT65$fBT64$fBT63$fBT62$fBT61$fBT60$fBT59$fBT58$fBT57$fBT56$fBT55$fBT54$fBT53$fBT52$fBT51$fBT50$fBT49$fBT48$fBT47$fBT46$fBT45$fBT44$fBT43$fBT42$fBT41$fBT40$fBT39$fBT38$fBT37$fBT36$fBT35$fBT34$fBT33$fBT32$fBT31$fBT30$fBT29$fBT28$fBT27$fBT26$fBT25$fBT24$fBT23$fBT22$fBT21$fBT20$fBT19$fBT18$fBT17$fBT16$fBT15$fBT14$fBT13$fBT12$fBT11$fBT10$fBT9$fBT8$fBT7$fBT6$fBT5$fBT4$fBT3$fBT2$fBT1$fBT0GHC.BaseFunctor$fSettableBackwards$fSettableIdentity$fSettableCompose $fReviewablep$fChoiceMarket$fProfunctorMarket$fFunctorMarket$fReversingVector$fReversingVector0$fReversingVector1$fReversingSeq$fReversingVector2$fReversingText$fReversingText0$fReversingByteString$fReversingByteString0 $fReversing[]$fProfunctorExchange$fFunctorExchange Applicativelappendsemigroups-0.15.4Data.Semigroup Semigrouptrimltrimr$fApplicativeFlows$fMonoidDeepening $fApplyFlows$fFunctorFlows$fSemigroupDeepening$fTraversableLevel$fFoldableLevel$fFunctorLevelGHC.IntInt64ghc-prim GHC.TypesIntData.Profunctor.RepCorepresentable Representablefmap$fContravariantIndexing64$fApplicativeIndexing64$fApplyIndexing64$fFunctorIndexing64$fContravariantIndexing$fApplicativeIndexing$fApplyIndexing$fFunctorIndexing$fIndexableiIndexed$fConjoinedIndexed$fArrowLoopIndexed$fArrowApplyIndexed$fArrowChoiceIndexed$fArrowIndexed$fCategoryIndexed$fStrongIndexed$fChoiceIndexed$fRepresentableIndexed$fCorepresentableIndexed$fProfunctorIndexed$fMonadFixIndexed$fMonadIndexed $fBindIndexed$fApplicativeIndexed$fApplyIndexed$fFunctorIndexed$fIndexablei(->)$fConjoined(->) comonad-4.2.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$fApplicativeEffect $fApplyEffect$fMonoidEffect$fSemigroupEffect$fEffectivemrEffect$fContravariantEffect$fFunctorEffect$fEffectiveIdentityrConst$fEffectivemDualBackwardsid$fEffectivemrAlongsideRight$fBitraversableAlongsideRight$fBifoldableAlongsideRight$fBifunctorAlongsideRight$fTraversable1AlongsideRight$fFoldable1AlongsideRight$fTraversableAlongsideRight$fFoldableAlongsideRight$fContravariantAlongsideRight$fFunctorAlongsideRight$fEffectivemrAlongsideLeft$fBitraversableAlongsideLeft$fBifoldableAlongsideLeft$fBifunctorAlongsideLeft$fTraversable1AlongsideLeft$fFoldable1AlongsideLeft$fTraversableAlongsideLeft$fFoldableAlongsideLeft$fContravariantAlongsideLeft$fFunctorAlongsideLeft $fGettablef Data.MaybeJust reflectResultunM $fMonoidM$fMonoidRightmost$fSemigroupRightmost$fMonoidLeftmost$fSemigroupLeftmost $fMonoidMax$fSemigroupMax $fMonoidMin$fSemigroupMin$fMonoidSequenced$fSemigroupSequenced$fMonoidTraversed$fSemigroupTraversed$fMonoidFolding$fSemigroupFolding Data.EitherEitherMaybeControl.Monad.Trans.MaybeMaybeTControl.Monad.Trans.ListListT$fContravariantEffectRWS$fApplicativeEffectRWS$fApplyEffectRWS$fFunctorEffectRWS$fApplicativeFocusingErr$fApplyFocusingErr$fFunctorFocusingErr $fMonoidErr$fSemigroupErr$fApplicativeFocusingMay$fApplyFocusingMay$fFunctorFocusingMay $fMonoidMay$fSemigroupMay$fApplicativeFocusingOn$fApplyFocusingOn$fFunctorFocusingOn$fApplicativeFocusingPlus$fApplyFocusingPlus$fFunctorFocusingPlus$fApplicativeFocusingWith$fApplyFocusingWith$fFunctorFocusingWith$fApplicativeFocusing$fApplyFocusing$fFunctorFocusingpure.asTypeOf GHC.Classes<= integer-gmpGHC.Integer.TypeIntegerGHC.Real toInteger$<LeftRightGHC.Num fromIntegerChar<$liftMNum FractionalIntegral GHC.FloatFloating||Bool&& mtl-2.2.1Control.Monad.State.Class MonadStatemappendControl.Monad.Writer.Classpass MonadWritercensorconstString Control.ArrowArrowstateflip void-0.6.1 Data.VoidVoid$fField2(,)(,)bb'$fField1(,)(,)aa'N8N7N6N5N4N3N2N1N0GTSubtractAddFTSZGIxed'gix'GIxedgixGSizeproxyN0proxyN1proxyN2proxyN3proxyN4proxyN5proxyN6proxyN7proxyN8$fGIxed'Fnss'st'ab$fGIxed'Tnss'ts'ab$fGIxedn:*::*:ab$fGIxednM1M1ab$fGIxedZK1K1ab$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'$fField1(,,,,,,,,)(,,,,,,,,)aa'$fField1(,,,,,,,)(,,,,,,,)aa'$fField1(,,,,,,)(,,,,,,)aa'$fField1(,,,,,)(,,,,,)aa'$fField1(,,,,)(,,,,)aa'$fField1(,,,)(,,,)aa'$fField1(,,)(,,)aa'$fField1:*::*:ff'$fField1IdentityIdentityab MonadReaderlistengetsNothingGHC.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.0.0 Data.Set.BaseSetOrdunordered-containers-0.2.5.1 Data.HashSetHashSethashable-1.2.2.0Data.Hashable.ClassHashableEqGHC.Listrepeat replicateiterateevenGHC.Enumsucc/= takeWhile dropWhilewordslinesEndoTrueProductSum sequenceA_asum Alternativemsum MonadPluselemnotElem concatMapconcatlengthheadFirstLastnotmaximum fromMaybeGHC.ErrminimumOrdering minimumBy listToMaybe Data.Tuplefstfolded'skipControl.Categoryfor sequenceAmapMforMsequence unwrapMonad WrapMonadControl.Applicative.Backwards Backwards mapAccumLswaprunStatescanr1scanl1Control.Comonad==Data.Bitraversable Bitraversableinswinspinsparrouts unsafeOutsunconsWithDefault$fTraverseMaxkMap$fTraverseMaxIntIntMap$fTraverseMinkMap$fTraverseMinIntIntMap Data.Map.Basesnd$fFunctorWithIndexIntSeq Data.SequenceSeq$fFunctorWithIndexInt[]$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 ilevelIns ilevelOuts Data.DatagmapMDatainlinePerformIOGHC.IOunsafePerformIOFollowerOracle fromOracleAnswerMissFollowHitCacheHitMapDataBox dataBoxKey _dataBoxValIsReflFieldExceptionsteplookuponmightBedataBox sybChildren emptyHitMap insertHitMapfixEqcachereadCacheFollowerinsert2hitTest biplateData uniplateDatapartfollower$fExceptionFieldException$fShowFieldExceptionnegate $fPlatedPat $fPlatedStmt $fPlatedType $fPlatedCon $fPlatedDec $fPlatedExp $fPlatedTree$fPlatedCofree $fPlatedF $fPlatedFreeT $fPlatedFree $fPlated[] text-1.2.0.0bytestring-0.10.0.2Data.ByteString.InternalEnumDoubleFloatcurryuncurry$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$fWrappedArrowMonad$fRewrappedArrowMonadt$fWrappedLast0$fRewrappedLastt0$fWrappedFirst0$fRewrappedFirstt0 $fWrappedEndo$fRewrappedEndot $fWrappedDual$fRewrappedDualt$fWrappedConst$fRewrappedConstt$fWrappedZipList$fRewrappedZipListt$fWrappedWrappedArrow$fRewrappedWrappedArrowt$fWrappedWrappedMonad$fRewrappedWrappedMonadt$fWrappedKleisli$fRewrappedKleislit$fWrappedProduct$fRewrappedProductt $fWrappedSum$fRewrappedSumt $fWrappedAny$fRewrappedAnyt $fWrappedAll$fRewrappedAllt$fRewrappingst $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.4.0.1Data.Array.BaseIArrayUArrayArray$fEachArrayArrayab$fEachByteStringByteStringabData.ByteString.Lazy.InternalGHC.WordWord8$fEachByteStringByteStringab0$fEachTextTextabData.Text.Internal.Lazy$fEachTextTextab0$fEachVectorVectorabvector-0.10.12.1Data.Vector.Unboxed.BaseUnboxVector$fEachVectorVectorab0Foreign.StorableStorableData.Vector.Storable$fEachVectorVectorab1primitive-0.5.4.0Data.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 $fSnoc[][]ab$fConsVectorVectorab$fConsVectorVectorab0$fConsVectorVectorab1$fConsVectorVectorab2$fConsTextTextCharChar$fConsTextTextCharChar0$$fConsByteStringByteStringWord8Word8%$fConsByteStringByteStringWord8Word80$fConsSeqSeqab $fCons[][]abemptycheck$fSnocDequeDequeab$fConsDequeDequeab $fMonoidDeque$fSemigroupDeque$fTraversableWithIndexIntDeque$fTraversableDeque$fFoldableWithIndexIntDeque$fFoldableDeque$fMonadPlusDeque $fMonadDeque $fBindDeque$fReversingDeque$fAlternativeDeque $fPlusDeque $fAltDeque$fApplicativeDeque $fApplyDeque$fFunctorWithIndexIntDeque$fFunctorDeque $fOrdDeque $fEqDeque $fIxedUArray!// $fIxedArray$fIxed(,,,,,,,,)$fIxed(,,,,,,,)$fIxed(,,,,,,) $fIxed(,,,,,) $fIxed(,,,,) $fIxed(,,,) $fIxed(,,) $fIxed(,) $fAtHashSet$fAtSet $fAtIntSet $fAtHashMap$fAtMap $fAtIntMap $fAtMaybe$fIxedByteString$fIxedByteString0 $fIxedText $fIxedText0 $fIxedVector $fIxedVector0 $fIxedVector1 $fIxedVector2 $fIxedHashSet $fIxedIntSet $fIxedSet $fIxedHashMap $fIxedMap $fIxedIntMap $fIxedSeq $fIxedTree$fIxedIdentity$fIxedNonEmpty$fIxed[] $fIxedMaybe $fIxed(->)$fContainsHashSet $fContainsSet$fContainsIntSetnewName$fSubstTypePred $fSubstType[]$fSubstTypeType$fHasTypeVarsMaybe$fHasTypeVars[]$fHasTypeVarsCon$fHasTypeVarsPred$fHasTypeVarsType$fHasTypeVarsName$fHasTypeVarsTyVarBndr $fHasNameCon $fHasNameName$fHasNameTyVarBndrmakeFieldOpticsForDec'normalizeConstructor buildScaffold buildStab OpticStabmakeFieldOpticmakePureClausemakeGetterClausemakeFieldOpticClause makeIsoClause unifyTypesunify1 limitedSubstapplyTypeSubst quantifyTypeOpticSa OpticTypeIsoTypeLensType GetterType stabToType stabToOpticstabToSstabToAmakeClassyDrivermakeClassyClassmakeClassyInstancemakeFieldClassmakeFieldInstancemakeFieldClauses inlinePragmaNCon makePrisms'DecmakeConsPrismscomputePrismTypemakeConOpticExp makeConIsomakeConPrismExp makeConIsoExpmakeConReviewExp makeReviewermakeSimpleRemittermakeFullRemittermakeIsoRemittermakeClassyPrismClassmakeClassyPrismInstance normalizeConCon prismNameclose _nconName_nconCxt _nconTypesStab ReviewType PrismType simplifyStab stabSimplestabTypecomputeOpticTypecomputeReviewTypecomputeIsoTypenconNamenconCxt nconTypes$fHasTypeVarsNConDeclareDataDecl dataContext tyConNamedataParametersfullType constructorsclassyRulesFor deNewtypefreshMaptraverseDataAndNewtype mkNameLookupapps makeDataDeclmakeWrappedForDecmakeRewrappedInstancemakeWrappedInstanceoverHeadunderscoreNamercamelCaseNamer declareWith runDeclareemit stripFieldsdeRecord>>=$fPlusReifiedMonadicFold$fAltReifiedMonadicFold$fMonoidReifiedMonadicFold$fSemigroupReifiedMonadicFold$fMonadPlusReifiedMonadicFold $fMonadReadersReifiedMonadicFold$fMonadReifiedMonadicFold$fBindReifiedMonadicFold$fAlternativeReifiedMonadicFold$fApplicativeReifiedMonadicFold$fApplyReifiedMonadicFold$fFunctorReifiedMonadicFold$fArrowApplyReifiedMonadicFold$fArrowChoiceReifiedMonadicFold$fArrowReifiedMonadicFold$fCategoryReifiedMonadicFold$fChoiceReifiedMonadicFold$fStrongReifiedMonadicFold$fProfunctorReifiedMonadicFold$fStrongReifiedIndexedFold!$fRepresentableReifiedIndexedFold$fProfunctorReifiedIndexedFold$fFunctorReifiedIndexedFold$fPlusReifiedIndexedFold$fAltReifiedIndexedFold$fMonoidReifiedIndexedFold$fSemigroupReifiedIndexedFold$fPlusReifiedFold$fAltReifiedFold$fMonoidReifiedFold$fSemigroupReifiedFold$fMonadReadersReifiedFold$fMonadPlusReifiedFold$fMonadReifiedFold$fBindReifiedFold$fAlternativeReifiedFold$fApplicativeReifiedFold$fApplyReifiedFold$fFunctorReifiedFold$fArrowApplyReifiedFold$fArrowChoiceReifiedFold$fArrowReifiedFold$fCategoryReifiedFold$fChoiceReifiedFold$fStrongReifiedFold$fRepresentableReifiedFold$fProfunctorReifiedFold$fApplyReifiedIndexedGetter$fFunctorReifiedIndexedGetter$fStrongReifiedIndexedGetter#$fRepresentableReifiedIndexedGetter $fProfunctorReifiedIndexedGetter$fArrowLoopReifiedGetter$fArrowChoiceReifiedGetter$fArrowApplyReifiedGetter$fArrowReifiedGetter$fCategoryReifiedGetter$fChoiceReifiedGetter$fStrongReifiedGetter$fConjoinedReifiedGetter$fRepresentableReifiedGetter$fCorepresentableReifiedGetter$fProfunctorReifiedGetter$fMonadReadersReifiedGetter$fMonadReifiedGetter$fBindReifiedGetter$fApplicativeReifiedGetter$fApplyReifiedGetter$fComonadApplyReifiedGetter$fComonadReifiedGetter$fExtendReifiedGetter$fFunctorReifiedGetter$fDistributiveReifiedGetterHandling GHC.Exception Exceptionexceptions-0.6.1Control.Monad.Catch System.IOprint++ SomeExceptionIOreturn handlerIOhandlerCatchIO handlingTyCon$fExceptionHandling$fShowHandling$fTypeableHandling$fExceptionHandlingException!$fHandleableSomeExceptionmHandler"$fHandleableSomeExceptionIOHandlerw2cc2w unsafeCreatecreategrainControl.Monad.Error.Class MonadError throwError$fHandleableemHandler$fMonoidHandler $fPlusHandler $fAltHandler$fSemigroupHandler$fFunctorHandlerparallel-3.2.0.4Control.Parallel.StrategiesStrategyevalTraversableEvalparTraversablerdeepseq Control.Seq seqFoldableixmapbounds Data.Bits.|.Bits.&.bitSize undefineddiv$fIsByteStringByteString$fIsByteStringByteString0realPartimagPartpolar magnitudephasepi conjugateIntSet split-0.2.2Data.List.Split.InternalsSplitter dropDelims onSublistoneOfwhenEltdropFinalBlank dropBlanksendkeepsViewLviewlViewRviewr Data.TextData.Text.Internal.BuilderBuilderfromTexttoStrict toLazyText fromLazyText $fIsTextText $fIsTextText0 $fIsText[] subForestgcastData.Vector.Generic.BaseData.Vector.Fusion.StreamStream GHC.GenericsGeneric 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$fAsExitCodepfSomeException$fAsExitCodepfExitCode