-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Lenses, Folds and Traversals
--   
--   This package comes "Batteries Included" with many useful lenses for
--   the types commonly used from the Haskell Platform, and with tools for
--   automatically generating lenses and isomorphisms for user-supplied
--   data types.
--   
--   The combinators in <tt>Control.Lens</tt> provide a highly generic
--   toolbox for composing families of getters, folds, isomorphisms,
--   traversals, setters and lenses and their indexed variants.
--   
--   An overview, with a large number of examples can be found in the
--   <tt>README</tt>:
--   <a>https://github.com/ekmett/lens#lens-lenses-folds-and-traversals</a>
--   
--   A video on how to use lenses and how they are constructed is available
--   from youtube: <a>http://youtu.be/cefnmjtAolY?hd=1</a>
--   
--   Slides can be obtained here:
--   <a>http://comonad.com/haskell/Lenses-Folds-and-Traversals-NYC.pdf</a>
--   
--   More information on the care and feeding of lenses, including a brief
--   tutorial and motivation for their types can be found on the lens wiki:
--   <a>https://github.com/ekmett/lens/wiki</a>
--   
--   A small game of <tt>pong</tt> and other more complex examples that
--   manage their state using lenses can be found in the example folder:
--   <a>https://github.com/ekmett/lens/blob/master/examples/</a>
--   
--   <i>Lenses, Folds and Traversals</i>
--   
--   The core of the hierarchy of lens-like constructions looks like:
--   
--   
--   Local copy (<a>Hierarchy.png</a>)
--   
--   You can compose any two elements of the hierarchy above using
--   <tt>(.)</tt> from the <tt>Prelude</tt>, and you can use any element of
--   the hierarchy as any type it linked to above it.
--   
--   The result is their lowest upper bound in the hierarchy (or an error
--   if that bound doesn't exist).
--   
--   For instance:
--   
--   <ul>
--   <li>You can use any <a>Traversal</a> as a <a>Fold</a> or as a
--   <a>Setter</a>.</li>
--   <li>The composition of a <a>Traversal</a> and a <a>Getter</a> yields a
--   <a>Fold</a>.</li>
--   </ul>
--   
--   <i>Minimizing Dependencies</i>
--   
--   If you want to provide lenses and traversals for your own types in
--   your own libraries, then you can do so without incurring a dependency
--   on this (or any other) lens package at all.
--   
--   <i>e.g.</i> for a data type:
--   
--   <pre>
--   data Foo a = Foo Int Int a
--   </pre>
--   
--   You can define lenses such as
--   
--   <pre>
--   -- bar :: Lens' (Foo a) Int
--   bar :: Functor f =&gt; (Int -&gt; f Int) -&gt; Foo a -&gt; f (Foo a)
--   bar f (Foo a b c) = fmap (\a' -&gt; Foo a' b c) (f a)
--   </pre>
--   
--   <pre>
--   -- baz :: Lens (Foo a) (Foo b) a b
--   quux :: Functor f =&gt; (a -&gt; f b) -&gt; Foo a -&gt; f (Foo b)
--   quux f (Foo a b c) = fmap (Foo a b) (f c)
--   </pre>
--   
--   without the need to use any type that isn't already defined in the
--   <tt>Prelude</tt>.
--   
--   And you can define a traversal of multiple fields with
--   <a>Control.Applicative.Applicative</a>:
--   
--   <pre>
--   -- traverseBarAndBaz :: Traversal' (Foo a) Int
--   traverseBarAndBaz :: Applicative f =&gt; (Int -&gt; f Int) -&gt; Foo a -&gt; f (Foo a)
--   traverseBarAndBaz f (Foo a b c) = Foo &lt;$&gt; f a &lt;*&gt; f b &lt;*&gt; pure c
--   </pre>
--   
--   What is provided in this library is a number of stock lenses and
--   traversals for common haskell types, a wide array of combinators for
--   working them, and more exotic functionality, (<i>e.g.</i> getters,
--   setters, indexed folds, isomorphisms).
@package lens
@version 3.10


-- | This module includes orphan instances for <tt>(,)</tt>, <a>Either</a>
--   and <a>Const</a> that should be supplied by base.
module Control.Lens.Internal.Instances
instance Traversable (Const m)
instance Foldable (Const m)
instance Traversable (Either a)
instance Foldable (Either a)
instance Traversable1 ((,) b)
instance Traversable ((,) b)
instance Foldable1 ((,) b)
instance Foldable ((,) b)


module Control.Lens.Internal.Prism

-- | This type is used internally by the <a>Prism</a> code to provide
--   efficient access to the two parts of a <tt>Prism</tt>.
data Market a b s t
Market :: (b -> t) -> (s -> Either t a) -> Market a b s t

-- | <pre>
--   type <a>Market'</a> a s t = <a>Market</a> a a s t
--   </pre>
type Market' a = Market a a
instance Choice (Market a b)
instance Profunctor (Market a b)
instance Functor (Market a b s)


module Control.Lens.Internal.Iso

-- | This is used internally by the <a>Iso</a> code to provide efficient
--   access to the two functions that make up an isomorphism.
data Exchange a b s t
Exchange :: (s -> a) -> (b -> t) -> Exchange a b s t

-- | This class provides a generalized notion of list reversal extended to
--   other containers.
class Reversing t
reversing :: Reversing t => t -> t
instance Storable a => Reversing (Vector a)
instance Unbox a => Reversing (Vector a)
instance Prim a => Reversing (Vector a)
instance Reversing (Seq a)
instance Reversing (Vector a)
instance Reversing Text
instance Reversing Text
instance Reversing ByteString
instance Reversing ByteString
instance Reversing [a]
instance Profunctor (Exchange a b)
instance Functor (Exchange a b s)


-- | This module provides implementation details of the combinators in
--   <a>Control.Lens.Level</a>, which provides for the breadth-first
--   <a>Traversal</a> of an arbitrary <a>Traversal</a>.
module Control.Lens.Internal.Level

-- | This data type represents a path-compressed copy of one level of a
--   source data structure. We can safely use path-compression because we
--   know the depth of the tree.
--   
--   Path compression is performed by viewing a <a>Level</a> as a PATRICIA
--   trie of the paths into the structure to leaves at a given depth,
--   similar in many ways to a <a>IntMap</a>, but unlike a regular PATRICIA
--   trie we do not need to store the mask bits merely the depth of the
--   fork.
--   
--   One invariant of this structure is that underneath a <a>Two</a> node
--   you will not find any <a>Zero</a> nodes, so <a>Zero</a> can only occur
--   at the root.
data Level i a
Two :: {-# UNPACK #-} !Word -> !(Level i a) -> !(Level i a) -> Level i a
One :: i -> a -> Level i a
Zero :: Level i a

-- | This is an illegal <a>Monoid</a> used to construct a single
--   <a>Level</a>.
newtype Deepening i a
Deepening :: (forall r. Int -> (Level i a -> Bool -> r) -> r) -> Deepening i a
runDeepening :: Deepening i a -> forall r. Int -> (Level i a -> Bool -> r) -> r

-- | Generate the leaf of a given <a>Deepening</a> based on whether or not
--   we're at the correct depth.
deepening :: i -> a -> Deepening i a

-- | This is an illegal <a>Applicative</a> used to replace the contents of
--   a list of consecutive <a>Level</a> values representing each layer of a
--   structure into the original shape that they were derived from.
--   
--   Attempting to <tt>Flow</tt> something back into a shape other than the
--   one it was taken from will fail.
newtype Flows i b a
Flows :: ([Level i b] -> a) -> Flows i b a
runFlows :: Flows i b a -> [Level i b] -> a
instance (Eq i, Eq a) => Eq (Level i a)
instance (Ord i, Ord a) => Ord (Level i a)
instance (Show i, Show a) => Show (Level i a)
instance (Read i, Read a) => Read (Level i a)
instance Applicative (Flows i b)
instance Apply (Flows i b)
instance Functor (Flows i b)
instance Monoid (Deepening i a)
instance Semigroup (Deepening i a)
instance Traversable (Level i)
instance Foldable (Level i)
instance Functor (Level i)


module Control.Lens.Internal.Setter

-- | Anything <a>Settable</a> must be isomorphic to the <a>Identity</a>
--   <a>Functor</a>.
class (Applicative f, Distributive f, Traversable f) => Settable f where untaintedDot g = g `seq` rmap untainted g taintedDot g = g `seq` rmap pure g
untainted :: Settable f => f a -> a
untaintedDot :: (Settable f, Profunctor p) => p a (f b) -> p a b
taintedDot :: (Settable f, Profunctor p) => p a b -> p a (f b)

-- | <a>Mutator</a> is just a renamed <a>Identity</a> <a>Functor</a> to
--   give better error messages when someone attempts to use a
--   <a>Getter</a> as a <a>Setter</a>.
--   
--   Most user code will never need to see this type.
newtype Mutator a
Mutator :: a -> Mutator a
runMutator :: Mutator a -> a
instance Settable Mutator
instance Traversable Mutator
instance Foldable Mutator
instance Distributive Mutator
instance ComonadApply Mutator
instance Comonad Mutator
instance Extend Mutator
instance Monad Mutator
instance Bind Mutator
instance Applicative Mutator
instance Apply Mutator
instance Functor Mutator
instance (Settable f, Settable g) => Settable (Compose f g)
instance Settable f => Settable (Backwards f)
instance Settable Identity


module Control.Lens.Internal.Review

-- | This class is provided mostly for backwards compatibility with lens
--   3.8, but it can also shorten type signatures.
class (Profunctor p, Bifunctor p) => Reviewable p

-- | This is a profunctor used internally to implement <a>Review</a>
--   
--   It plays a role similar to that of <a>Accessor</a> or <a>Const</a> do
--   for <a>Control.Lens.Getter</a>
retagged :: (Profunctor p, Bifunctor p) => p a b -> p s b
newtype Reviewed a b
Reviewed :: b -> Reviewed a b
runReviewed :: Reviewed a b -> b
instance Corepresentable Reviewed
instance Choice Reviewed
instance Profunctor Reviewed
instance Distributive (Reviewed a)
instance Bitraversable Reviewed
instance Bifoldable Reviewed
instance Bifunctor Reviewed
instance Traversable (Reviewed a)
instance Foldable (Reviewed a)
instance MonadFix (Reviewed a)
instance Monad (Reviewed a)
instance Bind (Reviewed a)
instance ComonadApply (Reviewed a)
instance Comonad (Reviewed a)
instance Applicative (Reviewed a)
instance Apply (Reviewed a)
instance Functor (Reviewed a)
instance (Profunctor p, Bifunctor p) => Reviewable p


module Control.Lens.Internal.Getter

-- | This class is provided mostly for backwards compatibility with lens
--   3.8, but it can also shorten type signatures.
class (Contravariant f, Functor f) => Gettable f

-- | This Generalizes <a>Const</a> so we can apply simple
--   <a>Applicative</a> transformations to it and so we can get nicer error
--   messages.
--   
--   A <a>Functor</a> you can <a>coerce</a> ignores its argument, which it
--   carries solely as a phantom type parameter.
--   
--   By the <a>Functor</a> and <a>Contravariant</a> laws, an instance of
--   <a>Gettable</a> will necessarily satisfy:
--   
--   <pre>
--   <a>id</a> = <a>fmap</a> f = <a>coerce</a> = <a>contramap</a> g
--   </pre>
coerce :: (Contravariant f, Functor f) => f a -> f b

-- | The <a>mempty</a> equivalent for a <a>Gettable</a> <a>Applicative</a>
--   <a>Functor</a>.
noEffect :: (Contravariant f, Applicative f) => f a

-- | Used instead of <a>Const</a> to report
--   
--   <pre>
--   No instance for (<a>Settable</a> <a>Accessor</a>)
--   </pre>
--   
--   when the user attempts to misuse a <a>Setter</a> as a <a>Getter</a>,
--   rather than a monolithic unification error.
newtype Accessor r a
Accessor :: r -> Accessor r a
runAccessor :: Accessor r a -> r
instance Monoid r => Applicative (Accessor r)
instance Semigroup r => Apply (Accessor r)
instance Contravariant (Accessor r)
instance Functor (Accessor r)
instance (Contravariant f, Functor f) => Gettable f


-- | Internal implementation details for <a>Indexed</a> lens-likes
module Control.Lens.Internal.Indexed

-- | A function with access to a index. This constructor may be useful when
--   you need to store an <a>Indexable</a> in a container to avoid
--   <tt>ImpredicativeTypes</tt>.
--   
--   <pre>
--   index :: Indexed i a b -&gt; i -&gt; a -&gt; b
--   </pre>
newtype Indexed i a b
Indexed :: (i -> a -> b) -> Indexed i a b
runIndexed :: Indexed i a b -> i -> a -> b

-- | This is a <a>Profunctor</a> that is both <a>Corepresentable</a> by
--   <tt>f</tt> and <a>Representable</a> by <tt>g</tt> such that <tt>f</tt>
--   is left adjoint to <tt>g</tt>. From this you can derive a lot of
--   structure due to the preservation of limits and colimits.
class (Choice p, Corepresentable p, Comonad (Corep p), Traversable (Corep p), Strong p, Representable p, Monad (Rep p), MonadFix (Rep p), Distributive (Rep p), ArrowLoop p, ArrowApply p, ArrowChoice p) => Conjoined p where distrib = tabulate . collect . rep conjoined _ r = r
distrib :: (Conjoined p, Functor f) => p a b -> p (f a) (f b)
conjoined :: Conjoined p => (p ~ (->) => q (a -> b) r) -> q (p a b) r -> q (p a b) r

-- | This class permits overloading of function application for things that
--   also admit a notion of a key or index.
class Conjoined p => Indexable i p
indexed :: Indexable i p => p a b -> i -> a -> b

-- | <a>Applicative</a> composition of <tt><a>State</a> <a>Int</a></tt>
--   with a <a>Functor</a>, used by <a>indexed</a>.
newtype Indexing f a
Indexing :: (Int -> (Int, f a)) -> Indexing f a
runIndexing :: Indexing f a -> Int -> (Int, f a)

-- | Transform a <a>Traversal</a> into an <a>IndexedTraversal</a> or a
--   <a>Fold</a> into an <a>IndexedFold</a>, etc.
--   
--   <pre>
--   <a>indexing</a> :: <a>Traversal</a> s t a b -&gt; <a>IndexedTraversal</a> <a>Int</a> s t a b
--   <a>indexing</a> :: <a>Prism</a> s t a b     -&gt; <a>IndexedTraversal</a> <a>Int</a> s t a b
--   <a>indexing</a> :: <a>Lens</a> s t a b      -&gt; <a>IndexedLens</a> <a>Int</a>  s t a b
--   <a>indexing</a> :: <a>Iso</a> s t a b       -&gt; <a>IndexedLens</a> <a>Int</a> s t a b
--   <a>indexing</a> :: <a>Fold</a> s a          -&gt; <a>IndexedFold</a> <a>Int</a> s a
--   <a>indexing</a> :: <a>Getter</a> s a        -&gt; <a>IndexedGetter</a> <a>Int</a> s a
--   </pre>
--   
--   <pre>
--   <a>indexing</a> :: <a>Indexable</a> <a>Int</a> p =&gt; <a>LensLike</a> (<a>Indexing</a> f) s t a b -&gt; <a>Overloading</a> p (-&gt;) f s t a b
--   </pre>
indexing :: Indexable Int p => ((a -> Indexing f b) -> s -> Indexing f t) -> p a (f b) -> s -> f t

-- | <a>Applicative</a> composition of <tt><a>State</a> <a>Int64</a></tt>
--   with a <a>Functor</a>, used by <a>indexed64</a>.
newtype Indexing64 f a
Indexing64 :: (Int64 -> (Int64, f a)) -> Indexing64 f a
runIndexing64 :: Indexing64 f a -> Int64 -> (Int64, f a)

-- | Transform a <a>Traversal</a> into an <a>IndexedTraversal</a> or a
--   <a>Fold</a> into an <a>IndexedFold</a>, etc.
--   
--   This combinator is like <a>indexing</a> except that it handles large
--   traversals and folds gracefully.
--   
--   <pre>
--   <a>indexing64</a> :: <a>Traversal</a> s t a b -&gt; <a>IndexedTraversal</a> <a>Int64</a> s t a b
--   <a>indexing64</a> :: <a>Prism</a> s t a b     -&gt; <a>IndexedTraversal</a> <a>Int64</a> s t a b
--   <a>indexing64</a> :: <a>Lens</a> s t a b      -&gt; <a>IndexedLens</a> <a>Int64</a> s t a b
--   <a>indexing64</a> :: <a>Iso</a> s t a b       -&gt; <a>IndexedLens</a> <a>Int64</a> s t a b
--   <a>indexing64</a> :: <a>Fold</a> s a          -&gt; <a>IndexedFold</a> <a>Int64</a> s a
--   <a>indexing64</a> :: <a>Getter</a> s a        -&gt; <a>IndexedGetter</a> <a>Int64</a> s a
--   </pre>
--   
--   <pre>
--   <a>indexing64</a> :: <a>Indexable</a> <a>Int64</a> p =&gt; <a>LensLike</a> (<a>Indexing64</a> f) s t a b -&gt; <a>Overloading</a> p (-&gt;) f s t a b
--   </pre>
indexing64 :: Indexable Int64 p => ((a -> Indexing64 f b) -> s -> Indexing64 f t) -> p a (f b) -> s -> f t
instance Contravariant f => Contravariant (Indexing64 f)
instance Applicative f => Applicative (Indexing64 f)
instance Apply f => Apply (Indexing64 f)
instance Functor f => Functor (Indexing64 f)
instance Contravariant f => Contravariant (Indexing f)
instance Applicative f => Applicative (Indexing f)
instance Apply f => Apply (Indexing f)
instance Functor f => Functor (Indexing f)
instance i ~ j => Indexable i (Indexed j)
instance Conjoined (Indexed i)
instance ArrowLoop (Indexed i)
instance ArrowApply (Indexed i)
instance ArrowChoice (Indexed i)
instance Arrow (Indexed i)
instance Category (Indexed i)
instance Strong (Indexed i)
instance Choice (Indexed i)
instance Representable (Indexed i)
instance Corepresentable (Indexed i)
instance Profunctor (Indexed i)
instance MonadFix (Indexed i a)
instance Monad (Indexed i a)
instance Bind (Indexed i a)
instance Applicative (Indexed i a)
instance Apply (Indexed i a)
instance Functor (Indexed i a)
instance Indexable i (->)
instance Conjoined (->)


module Control.Lens.Internal.Context

-- | This is a Bob Atkey -style 2-argument indexed functor.
--   
--   It exists as a superclass for <a>IndexedComonad</a> and expresses the
--   functoriality of an <a>IndexedComonad</a> in its third argument.
class IndexedFunctor w
ifmap :: IndexedFunctor w => (s -> t) -> w a b s -> w a b t

-- | This is a Bob Atkey -style 2-argument indexed comonad.
--   
--   It exists as a superclass for <a>IndexedComonad</a> and expresses the
--   functoriality of an <a>IndexedComonad</a> in its third argument.
--   
--   The notion of indexed monads is covered in more depth in Bob Atkey's
--   <a>Parameterized Notions of Computation</a>
--   <a>http://bentnib.org/paramnotions-jfp.pdf</a> and that construction
--   is dualized here.
class IndexedFunctor w => IndexedComonad w where iduplicate = iextend id iextend f = ifmap f . iduplicate
iextract :: IndexedComonad w => w a a t -> t
iduplicate :: IndexedComonad w => w a c t -> w a b (w b c t)
iextend :: IndexedComonad w => (w b c t -> r) -> w a c t -> w a b r

-- | This is an indexed analogue to <a>ComonadStore</a> for when you are
--   working with an <a>IndexedComonad</a>.
class IndexedComonad w => IndexedComonadStore w where ipeek c = iextract . iseek c ipeeks f = iextract . iseeks f iexperiment bfc wbct = (`ipeek` wbct) <$> bfc (ipos wbct) context wabt = Context (`ipeek` wabt) (ipos wabt)
ipos :: IndexedComonadStore w => w a c t -> a
ipeek :: IndexedComonadStore w => c -> w a c t -> t
ipeeks :: IndexedComonadStore w => (a -> c) -> w a c t -> t
iseek :: IndexedComonadStore w => b -> w a c t -> w b c t
iseeks :: IndexedComonadStore w => (a -> b) -> w a c t -> w b c t
iexperiment :: (IndexedComonadStore w, Functor f) => (b -> f c) -> w b c t -> f t
context :: IndexedComonadStore w => w a b t -> Context a b t

-- | This is used internally to construct a <a>Bazaar</a>, <a>Context</a>
--   or <a>Pretext</a> from a singleton value.
class Corepresentable p => Sellable p w | w -> p
sell :: Sellable p w => p a (w a b b)

-- | The indexed store can be used to characterize a <a>Lens</a> and is
--   used by <a>clone</a>.
--   
--   <tt><a>Context</a> a b t</tt> is isomorphic to <tt>newtype
--   <a>Context</a> a b t = <a>Context</a> { runContext :: forall f.
--   <a>Functor</a> f =&gt; (a -&gt; f b) -&gt; f t }</tt>, and to
--   <tt>exists s. (s, <a>Lens</a> s t a b)</tt>.
--   
--   A <a>Context</a> is like a <a>Lens</a> that has already been applied
--   to a some structure.
data Context a b t
Context :: (b -> t) -> a -> Context a b t

-- | <pre>
--   type <a>Context'</a> a s = <a>Context</a> a a s
--   </pre>
type Context' a = Context a a

-- | This is a generalized form of <a>Context</a> that can be repeatedly
--   cloned with less impact on its performance, and which permits the use
--   of an arbitrary <a>Conjoined</a> <a>Profunctor</a>
newtype Pretext p a b t
Pretext :: (forall f. Functor f => p a (f b) -> f t) -> Pretext p a b t
runPretext :: Pretext p a b t -> forall f. Functor f => p a (f b) -> f t

-- | <pre>
--   type <a>Pretext'</a> p a s = <a>Pretext</a> p a a s
--   </pre>
type Pretext' p a = Pretext p a a

-- | This is a generalized form of <a>Context</a> that can be repeatedly
--   cloned with less impact on its performance, and which permits the use
--   of an arbitrary <a>Conjoined</a> <a>Profunctor</a>.
--   
--   The extra phantom <a>Functor</a> is used to let us lie and claim a
--   <tt>Gettable</tt> instance under limited circumstances. This is used
--   internally to permit a number of combinators to gracefully degrade
--   when applied to a <a>Fold</a>, <a>Getter</a> or <a>Action</a>.
newtype PretextT p (g :: * -> *) a b t
PretextT :: (forall f. Functor f => p a (f b) -> f t) -> PretextT p a b t
runPretextT :: PretextT p a b t -> forall f. Functor f => p a (f b) -> f t

-- | <pre>
--   type <a>PretextT'</a> p g a s = <a>PretextT</a> p g a a s
--   </pre>
type PretextT' p g a = PretextT p g a a
instance (Profunctor p, Contravariant g) => Contravariant (PretextT p g a b)
instance Corepresentable p => Sellable p (PretextT p g)
instance (a ~ b, Conjoined p) => ComonadStore a (PretextT p g a b)
instance Conjoined p => IndexedComonadStore (PretextT p g)
instance (a ~ b, Conjoined p) => Comonad (PretextT p g a b)
instance Conjoined p => IndexedComonad (PretextT p g)
instance Functor (PretextT p g a b)
instance IndexedFunctor (PretextT p g)
instance Corepresentable p => Sellable p (Pretext p)
instance (a ~ b, Conjoined p) => ComonadStore a (Pretext p a b)
instance Conjoined p => IndexedComonadStore (Pretext p)
instance (a ~ b, Conjoined p) => Comonad (Pretext p a b)
instance Conjoined p => IndexedComonad (Pretext p)
instance Functor (Pretext p a b)
instance IndexedFunctor (Pretext p)
instance Sellable (->) Context
instance a ~ b => ComonadStore a (Context a b)
instance a ~ b => Comonad (Context a b)
instance Functor (Context a b)
instance IndexedComonadStore Context
instance IndexedComonad Context
instance IndexedFunctor Context


module Control.Lens.Internal.Bazaar

-- | This class is used to run the various <a>Bazaar</a> variants used in
--   this library.
class Profunctor p => Bizarre p w | w -> p
bazaar :: (Bizarre p w, Applicative f) => p a (f b) -> w a b t -> f t

-- | This is used to characterize a <a>Traversal</a>.
--   
--   a.k.a. indexed Cartesian store comonad, indexed Kleene store comonad,
--   or an indexed <tt>FunList</tt>.
--   
--   <a>http://twanvl.nl/blog/haskell/non-regular1</a>
--   
--   A <a>Bazaar</a> is like a <a>Traversal</a> that has already been
--   applied to some structure.
--   
--   Where a <tt><a>Context</a> a b t</tt> holds an <tt>a</tt> and a
--   function from <tt>b</tt> to <tt>t</tt>, a <tt><a>Bazaar</a> a b t</tt>
--   holds <tt>N</tt> <tt>a</tt>s and a function from <tt>N</tt>
--   <tt>b</tt>s to <tt>t</tt>, (where <tt>N</tt> might be infinite).
--   
--   Mnemonically, a <a>Bazaar</a> holds many stores and you can easily add
--   more.
--   
--   This is a final encoding of <a>Bazaar</a>.
newtype Bazaar p a b t
Bazaar :: (forall f. Applicative f => p a (f b) -> f t) -> Bazaar p a b t
runBazaar :: Bazaar p a b t -> forall f. Applicative f => p a (f b) -> f t

-- | This alias is helpful when it comes to reducing repetition in type
--   signatures.
--   
--   <pre>
--   type <a>Bazaar'</a> p a t = <a>Bazaar</a> p a a t
--   </pre>
type Bazaar' p a = Bazaar p a a

-- | <a>BazaarT</a> is like <a>Bazaar</a>, except that it provides a
--   questionable <a>Contravariant</a> instance To protect this instance it
--   relies on the soundness of another <a>Contravariant</a> type, and
--   usage conventions.
--   
--   For example. This lets us write a suitably polymorphic and lazy
--   <a>taking</a>, but there must be a better way!
newtype BazaarT p (g :: * -> *) a b t
BazaarT :: (forall f. Applicative f => p a (f b) -> f t) -> BazaarT p a b t
runBazaarT :: BazaarT p a b t -> forall f. Applicative f => p a (f b) -> f t

-- | This alias is helpful when it comes to reducing repetition in type
--   signatures.
--   
--   <pre>
--   type <a>BazaarT'</a> p g a t = <a>BazaarT</a> p g a a t
--   </pre>
type BazaarT' p g a = BazaarT p g a a
instance (Profunctor p, Contravariant g) => Contravariant (BazaarT p g a b)
instance (a ~ b, Conjoined p) => ComonadApply (BazaarT p g a b)
instance (a ~ b, Conjoined p) => Comonad (BazaarT p g a b)
instance Applicative (BazaarT p g a b)
instance Apply (BazaarT p g a b)
instance Functor (BazaarT p g a b)
instance Profunctor p => Bizarre p (BazaarT p g)
instance Corepresentable p => Sellable p (BazaarT p g)
instance Conjoined p => IndexedComonad (BazaarT p g)
instance IndexedFunctor (BazaarT p g)
instance (a ~ b, Conjoined p) => ComonadApply (Bazaar p a b)
instance (a ~ b, Conjoined p) => Comonad (Bazaar p a b)
instance Applicative (Bazaar p a b)
instance Apply (Bazaar p a b)
instance Functor (Bazaar p a b)
instance Profunctor p => Bizarre p (Bazaar p)
instance Corepresentable p => Sellable p (Bazaar p)
instance Conjoined p => IndexedComonad (Bazaar p)
instance IndexedFunctor (Bazaar p)


module Control.Lens.Internal.Magma

-- | This provides a way to peek at the internal structure of a
--   <a>Traversal</a> or <a>IndexedTraversal</a>
data Magma i t b a
MagmaAp :: Magma i (x -> y) b a -> Magma i x b a -> Magma i y b a
MagmaPure :: x -> Magma i x b a
MagmaFmap :: (x -> y) -> Magma i x b a -> Magma i y b a
Magma :: i -> a -> Magma i b b a

-- | Run a <a>Magma</a> where all the individual leaves have been converted
--   to the expected type
runMagma :: Magma i t a a -> t

-- | This is a a non-reassociating initially encoded version of
--   <a>Bazaar</a>.
newtype Molten i a b t
Molten :: Magma i t b a -> Molten i a b t
runMolten :: Molten i a b t -> Magma i t b a

-- | This is used to generate an indexed magma from an unindexed source
--   
--   By constructing it this way we avoid infinite reassociations in sums
--   where possible.
data Mafic a b t
Mafic :: Int -> (Int -> Magma Int t b a) -> Mafic a b t

-- | Generate a <a>Magma</a> using from a prefix sum.
runMafic :: Mafic a b t -> Magma Int t b a

-- | This is used to generate an indexed magma from an unindexed source
--   
--   By constructing it this way we avoid infinite reassociations where
--   possible.
data TakingWhile p (g :: * -> *) a b t
TakingWhile :: Bool -> t -> (Bool -> Magma () t b (Corep p a)) -> TakingWhile p a b t

-- | Generate a <a>Magma</a> with leaves only while the predicate holds
--   from left to right.
runTakingWhile :: Corepresentable p => TakingWhile p f a b t -> Magma () t b (Corep p a)
instance IndexedFunctor (TakingWhile p f)
instance Contravariant f => Contravariant (TakingWhile p f a b)
instance Corepresentable p => Bizarre p (TakingWhile p g)
instance Applicative (TakingWhile p f a b)
instance Apply (TakingWhile p f a b)
instance Functor (TakingWhile p f a b)
instance IndexedFunctor Mafic
instance Bizarre (Indexed Int) Mafic
instance Sellable (->) Mafic
instance Applicative (Mafic a b)
instance Apply (Mafic a b)
instance Functor (Mafic a b)
instance a ~ b => Comonad (Molten i a b)
instance IndexedComonad (Molten i)
instance IndexedFunctor (Molten i)
instance Bizarre (Indexed i) (Molten i)
instance Sellable (Indexed i) (Molten i)
instance Applicative (Molten i a b)
instance Apply (Molten i a b)
instance Functor (Molten i a b)
instance (Show i, Show a) => Show (Magma i t b a)
instance Traversable (Magma i t b)
instance Foldable (Magma i t b)
instance Functor (Magma i t b)


module Control.Lens.Internal.Fold

-- | A <a>Monoid</a> for a <a>Contravariant</a> <a>Applicative</a>.
newtype Folding f a
Folding :: f a -> Folding f a
getFolding :: Folding f a -> f a

-- | Used internally by <a>traverseOf_</a> and the like.
--   
--   The argument <tt>a</tt> of the result should not be used!
newtype Traversed a f
Traversed :: f a -> Traversed a f
getTraversed :: Traversed a f -> f a

-- | Used internally by <a>mapM_</a> and the like.
--   
--   The argument <tt>a</tt> of the result should not be used!
newtype Sequenced a m
Sequenced :: m a -> Sequenced a m
getSequenced :: Sequenced a m -> m a

-- | Used for <a>maximumOf</a>.
data Max a
NoMax :: Max a
Max :: a -> Max a

-- | Obtain the maximum.
getMax :: Max a -> Maybe a

-- | Used for <a>minimumOf</a>.
data Min a
NoMin :: Min a
Min :: a -> Min a

-- | Obtain the minimum.
getMin :: Min a -> Maybe a

-- | Used for <a>preview</a>.
data Leftmost a
LPure :: Leftmost a
LLeaf :: a -> Leftmost a
LStep :: (Leftmost a) -> Leftmost a

-- | Extract the <a>Leftmost</a> element. This will fairly eagerly
--   determine that it can return <a>Just</a> the moment it sees any
--   element at all.
getLeftmost :: Leftmost a -> Maybe a

-- | Used for <a>lastOf</a>.
data Rightmost a
RPure :: Rightmost a
RLeaf :: a -> Rightmost a
RStep :: (Rightmost a) -> Rightmost a

-- | Extract the <a>Rightmost</a> element. This will fairly eagerly
--   determine that it can return <a>Just</a> the moment it sees any
--   element at all.
getRightmost :: Rightmost a -> Maybe a
instance Monoid (Rightmost a)
instance Semigroup (Rightmost a)
instance Monoid (Leftmost a)
instance Semigroup (Leftmost a)
instance Ord a => Monoid (Max a)
instance Ord a => Semigroup (Max a)
instance Ord a => Monoid (Min a)
instance Ord a => Semigroup (Min a)
instance Monad m => Monoid (Sequenced a m)
instance Apply m => Semigroup (Sequenced a m)
instance Applicative f => Monoid (Traversed a f)
instance Apply f => Semigroup (Traversed a f)
instance (Contravariant f, Applicative f) => Monoid (Folding f a)
instance (Contravariant f, Apply f) => Semigroup (Folding f a)


module Control.Lens.Internal.Action

-- | An <a>Effective</a> <a>Functor</a> ignores its argument and is
--   isomorphic to a <a>Monad</a> wrapped around a value.
--   
--   That said, the <a>Monad</a> is possibly rather unrelated to any
--   <a>Applicative</a> structure.
class (Monad m, Functor f, Contravariant f) => Effective m r f | f -> m r
effective :: Effective m r f => m r -> f a
ineffective :: Effective m r f => f a -> m r

-- | Wrap a monadic effect with a phantom type argument.
newtype Effect m r a
Effect :: m r -> Effect m r a
getEffect :: Effect m r a -> m r
instance (Monad m, Monoid r) => Applicative (Effect m r)
instance (Apply m, Semigroup r) => Apply (Effect m r)
instance (Monad m, Monoid r) => Monoid (Effect m r a)
instance (Apply m, Semigroup r) => Semigroup (Effect m r a)
instance Monad m => Effective m r (Effect m r)
instance Contravariant (Effect m r)
instance Functor (Effect m r)
instance Effective Identity r (Accessor r)
instance Effective m r f => Effective m (Dual r) (Backwards f)


module Control.Lens.Internal.Zoom

-- | This type family is used by <a>Zoom</a> to describe the common effect
--   type.

-- | Used by <a>Zoom</a> to <a>zoom</a> into <a>StateT</a>.
newtype Focusing m s a
Focusing :: m (s, a) -> Focusing m s a
unfocusing :: Focusing m s a -> m (s, a)

-- | Used by <a>Zoom</a> to <a>zoom</a> into <a>RWST</a>.
newtype FocusingWith w m s a
FocusingWith :: m (s, a, w) -> FocusingWith w m s a
unfocusingWith :: FocusingWith w m s a -> m (s, a, w)

-- | Used by <a>Zoom</a> to <a>zoom</a> into <a>WriterT</a>.
newtype FocusingPlus w k s a
FocusingPlus :: k (s, w) a -> FocusingPlus w k s a
unfocusingPlus :: FocusingPlus w k s a -> k (s, w) a

-- | Used by <a>Zoom</a> to <a>zoom</a> into <a>MaybeT</a> or <a>ListT</a>.
newtype FocusingOn f k s a
FocusingOn :: k (f s) a -> FocusingOn f k s a
unfocusingOn :: FocusingOn f k s a -> k (f s) a

-- | Used by <a>Zoom</a> to <a>zoom</a> into <a>ErrorT</a>.
newtype FocusingMay k s a
FocusingMay :: k (May s) a -> FocusingMay k s a
unfocusingMay :: FocusingMay k s a -> k (May s) a

-- | Make a <a>Monoid</a> out of <a>Maybe</a> for error handling.
newtype May a
May :: Maybe a -> May a
getMay :: May a -> Maybe a

-- | Used by <a>Zoom</a> to <a>zoom</a> into <a>ErrorT</a>.
newtype FocusingErr e k s a
FocusingErr :: k (Err e s) a -> FocusingErr e k s a
unfocusingErr :: FocusingErr e k s a -> k (Err e s) a

-- | Make a <a>Monoid</a> out of <a>Either</a> for error handling.
newtype Err e a
Err :: Either e a -> Err e a
getErr :: Err e a -> Either e a

-- | This type family is used by <a>Magnify</a> to describe the common
--   effect type.

-- | Wrap a monadic effect with a phantom type argument. Used when
--   magnifying <a>RWST</a>.
newtype EffectRWS w st m s a
EffectRWS :: (st -> m (s, st, w)) -> EffectRWS w st m s a
getEffectRWS :: EffectRWS w st m s a -> st -> m (s, st, w)
instance Contravariant (EffectRWS w st m s)
instance (Monoid s, Monoid w, Monad m) => Applicative (EffectRWS w st m s)
instance (Semigroup s, Semigroup w, Bind m) => Apply (EffectRWS w st m s)
instance Functor (EffectRWS w st m s)
instance Applicative (k (Err e s)) => Applicative (FocusingErr e k s)
instance Apply (k (Err e s)) => Apply (FocusingErr e k s)
instance Functor (k (Err e s)) => Functor (FocusingErr e k s)
instance Monoid a => Monoid (Err e a)
instance Semigroup a => Semigroup (Err e a)
instance Applicative (k (May s)) => Applicative (FocusingMay k s)
instance Apply (k (May s)) => Apply (FocusingMay k s)
instance Functor (k (May s)) => Functor (FocusingMay k s)
instance Monoid a => Monoid (May a)
instance Semigroup a => Semigroup (May a)
instance Applicative (k (f s)) => Applicative (FocusingOn f k s)
instance Apply (k (f s)) => Apply (FocusingOn f k s)
instance Functor (k (f s)) => Functor (FocusingOn f k s)
instance Applicative (k (s, w)) => Applicative (FocusingPlus w k s)
instance Apply (k (s, w)) => Apply (FocusingPlus w k s)
instance Functor (k (s, w)) => Functor (FocusingPlus w k s)
instance (Monad m, Monoid s, Monoid w) => Applicative (FocusingWith w m s)
instance (Monad m, Semigroup s, Semigroup w) => Apply (FocusingWith w m s)
instance Monad m => Functor (FocusingWith w m s)
instance (Monad m, Monoid s) => Applicative (Focusing m s)
instance (Monad m, Semigroup s) => Apply (Focusing m s)
instance Monad m => Functor (Focusing m s)


-- | This module exports the majority of the types that need to appear in
--   user signatures or in documentation when talking about lenses. The
--   remaining types for consuming lenses are distributed across various
--   modules in the hierarchy.
module Control.Lens.Type

-- | A witness that <tt>(a ~ s, b ~ t)</tt>.
--   
--   Note: Composition with an <a>Equality</a> is index-preserving.
type Equality s t a b = forall p (f :: * -> *). p a (f b) -> p s (f t)

-- | A <a>Simple</a> <a>Equality</a>.
type Equality' s a = Equality s s a a

-- | Isomorphism families can be composed with another <a>Lens</a> using
--   (<a>.</a>) and <a>id</a>.
--   
--   Note: Composition with an <a>Iso</a> is index- and measure-
--   preserving.
type Iso s t a b = forall p f. (Profunctor p, Functor f) => p a (f b) -> p s (f t)

-- | <pre>
--   type <a>Iso'</a> = <a>Simple</a> <a>Iso</a>
--   </pre>
type Iso' s a = Iso s s a a

-- | A <a>Prism</a> <tt>l</tt> is a 0-or-1 target <a>Traversal</a> that can
--   also be turned around with <a>re</a> to obtain a <a>Getter</a> in the
--   opposite direction.
--   
--   There are two laws that a <a>Prism</a> should satisfy:
--   
--   First, if I <a>re</a> or <a>review</a> a value with a <a>Prism</a> and
--   then <a>preview</a> or use (<a>^?</a>), I will get it back:
--   
--   <pre>
--   <a>preview</a> l (<a>review</a> l b) ≡ <a>Just</a> b
--   </pre>
--   
--   Second, if you can extract a value <tt>a</tt> using a <a>Prism</a>
--   <tt>l</tt> from a value <tt>s</tt>, then the value <tt>s</tt> is
--   completely described my <tt>l</tt> and <tt>a</tt>:
--   
--   If <tt><a>preview</a> l s ≡ <a>Just</a> a</tt> then <tt><a>review</a>
--   l a ≡ s</tt>
--   
--   These two laws imply that the <a>Traversal</a> laws hold for every
--   <a>Prism</a> and that we <a>traverse</a> at most 1 element:
--   
--   <pre>
--   <a>lengthOf</a> l x <a>&lt;=</a> 1
--   </pre>
--   
--   It may help to think of this as a <a>Iso</a> that can be partial in
--   one direction.
--   
--   Every <a>Prism</a> is a valid <a>Traversal</a>.
--   
--   Every <a>Iso</a> is a valid <a>Prism</a>.
--   
--   For example, you might have a <tt><a>Prism'</a> <a>Integer</a>
--   <a>Natural</a></tt> allows you to always go from a <a>Natural</a> to
--   an <a>Integer</a>, and provide you with tools to check if an
--   <a>Integer</a> is a <a>Natural</a> and/or to edit one if it is.
--   
--   <pre>
--   <tt>nat</tt> :: <a>Prism'</a> <a>Integer</a> <a>Natural</a>
--   <tt>nat</tt> = <a>prism</a> <a>toInteger</a> <a>$</a> \ i -&gt;
--      if i <a>&lt;</a> 0
--      then <a>Left</a> i
--      else <a>Right</a> (<a>fromInteger</a> i)
--   </pre>
--   
--   Now we can ask if an <a>Integer</a> is a <a>Natural</a>.
--   
--   <pre>
--   &gt;&gt;&gt; 5^?nat
--   Just 5
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (-5)^?nat
--   Nothing
--   </pre>
--   
--   We can update the ones that are:
--   
--   <pre>
--   &gt;&gt;&gt; (-3,4) &amp; both.nat *~ 2
--   (-3,8)
--   </pre>
--   
--   And we can then convert from a <a>Natural</a> to an <a>Integer</a>.
--   
--   <pre>
--   &gt;&gt;&gt; 5 ^. re nat -- :: Natural
--   5
--   </pre>
--   
--   Similarly we can use a <a>Prism</a> to <a>traverse</a> the <a>Left</a>
--   half of an <a>Either</a>:
--   
--   <pre>
--   &gt;&gt;&gt; Left "hello" &amp; _Left %~ length
--   Left 5
--   </pre>
--   
--   or to construct an <a>Either</a>:
--   
--   <pre>
--   &gt;&gt;&gt; 5^.re _Left
--   Left 5
--   </pre>
--   
--   such that if you query it with the <a>Prism</a>, you will get your
--   original input back.
--   
--   <pre>
--   &gt;&gt;&gt; 5^.re _Left ^? _Left
--   Just 5
--   </pre>
--   
--   Another interesting way to think of a <a>Prism</a> is as the
--   categorical dual of a <a>Lens</a> -- a co-<a>Lens</a>, so to speak.
--   This is what permits the construction of <a>outside</a>.
--   
--   Note: Composition with a <a>Prism</a> is index-preserving.
type Prism s t a b = forall p f. (Choice p, Applicative f) => p a (f b) -> p s (f t)

-- | A <a>Simple</a> <a>Prism</a>.
type Prism' s a = Prism s s a a

-- | A <a>Lens</a> is actually a lens family as described in
--   <a>http://comonad.com/reader/2012/mirrored-lenses/</a>.
--   
--   With great power comes great responsibility and a <a>Lens</a> is
--   subject to the three common sense <a>Lens</a> laws:
--   
--   1) You get back what you put in:
--   
--   <pre>
--   <a>view</a> l (<a>set</a> l b a)  ≡ b
--   </pre>
--   
--   2) Putting back what you got doesn't change anything:
--   
--   <pre>
--   <a>set</a> l (<a>view</a> l a) a  ≡ a
--   </pre>
--   
--   3) Setting twice is the same as setting once:
--   
--   <pre>
--   <a>set</a> l c (<a>set</a> l b a) ≡ <a>set</a> l c a
--   </pre>
--   
--   These laws are strong enough that the 4 type parameters of a
--   <a>Lens</a> cannot vary fully independently. For more on how they
--   interact, read the "Why is it a Lens Family?" section of
--   <a>http://comonad.com/reader/2012/mirrored-lenses/</a>.
--   
--   Every <a>Lens</a> can be used directly as a <a>Setter</a> or
--   <a>Traversal</a>.
--   
--   You can also use a <a>Lens</a> for <a>Getting</a> as if it were a
--   <a>Fold</a> or <a>Getter</a>.
--   
--   Since every <a>Lens</a> is a valid <a>Traversal</a>, the
--   <a>Traversal</a> laws are required of any <a>Lens</a> you create:
--   
--   <pre>
--   l <a>pure</a> ≡ <a>pure</a>
--   <a>fmap</a> (l f) <a>.</a> l g ≡ <a>getCompose</a> <a>.</a> l (<a>Compose</a> <a>.</a> <a>fmap</a> f <a>.</a> g)
--   </pre>
--   
--   <pre>
--   type <a>Lens</a> s t a b = forall f. <a>Functor</a> f =&gt; <a>LensLike</a> f s t a b
--   </pre>
type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t

-- | <pre>
--   type <a>Lens'</a> = <a>Simple</a> <a>Lens</a>
--   </pre>
type Lens' s a = Lens s s a a

-- | A <a>Traversal</a> can be used directly as a <a>Setter</a> or a
--   <a>Fold</a> (but not as a <a>Lens</a>) and provides the ability to
--   both read and update multiple fields, subject to some relatively weak
--   <a>Traversal</a> laws.
--   
--   These have also been known as multilenses, but they have the signature
--   and spirit of
--   
--   <pre>
--   <a>traverse</a> :: <a>Traversable</a> f =&gt; <a>Traversal</a> (f a) (f b) a b
--   </pre>
--   
--   and the more evocative name suggests their application.
--   
--   Most of the time the <a>Traversal</a> you will want to use is just
--   <a>traverse</a>, but you can also pass any <a>Lens</a> or <a>Iso</a>
--   as a <a>Traversal</a>, and composition of a <a>Traversal</a> (or
--   <a>Lens</a> or <a>Iso</a>) with a <a>Traversal</a> (or <a>Lens</a> or
--   <a>Iso</a>) using (<a>.</a>) forms a valid <a>Traversal</a>.
--   
--   The laws for a <a>Traversal</a> <tt>t</tt> follow from the laws for
--   <a>Traversable</a> as stated in "The Essence of the Iterator Pattern".
--   
--   <pre>
--   t <a>pure</a> ≡ <a>pure</a>
--   <a>fmap</a> (t f) <a>.</a> t g ≡ <a>getCompose</a> <a>.</a> t (<a>Compose</a> <a>.</a> <a>fmap</a> f <a>.</a> g)
--   </pre>
--   
--   One consequence of this requirement is that a <a>Traversal</a> needs
--   to leave the same number of elements as a candidate for subsequent
--   <a>Traversal</a> that it started with. Another testament to the
--   strength of these laws is that the caveat expressed in section 5.5 of
--   the "Essence of the Iterator Pattern" about exotic <a>Traversable</a>
--   instances that <a>traverse</a> the same entry multiple times was
--   actually already ruled out by the second law in that same paper!
type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t

-- | <pre>
--   type <a>Traversal'</a> = <a>Simple</a> <a>Traversal</a>
--   </pre>
type Traversal' s a = Traversal s s a a

-- | The only <a>LensLike</a> law that can apply to a <a>Setter</a>
--   <tt>l</tt> is that
--   
--   <pre>
--   <a>set</a> l y (<a>set</a> l x a) ≡ <a>set</a> l y a
--   </pre>
--   
--   You can't <a>view</a> a <a>Setter</a> in general, so the other two
--   laws are irrelevant.
--   
--   However, two <a>Functor</a> laws apply to a <a>Setter</a>:
--   
--   <pre>
--   <a>over</a> l <a>id</a> ≡ <a>id</a>
--   <a>over</a> l f <a>.</a> <a>over</a> l g ≡ <a>over</a> l (f <a>.</a> g)
--   </pre>
--   
--   These can be stated more directly:
--   
--   <pre>
--   l <a>pure</a> ≡ <a>pure</a>
--   l f <a>.</a> <a>untainted</a> <a>.</a> l g ≡ l (f <a>.</a> <a>untainted</a> <a>.</a> g)
--   </pre>
--   
--   You can compose a <a>Setter</a> with a <a>Lens</a> or a
--   <a>Traversal</a> using (<a>.</a>) from the <tt>Prelude</tt> and the
--   result is always only a <a>Setter</a> and nothing more.
--   
--   <pre>
--   &gt;&gt;&gt; over traverse f [a,b,c,d]
--   [f a,f b,f c,f d]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over _1 f (a,b)
--   (f a,b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over (traverse._1) f [(a,b),(c,d)]
--   [(f a,b),(f c,d)]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over both f (a,b)
--   (f a,f b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over (traverse.both) f [(a,b),(c,d)]
--   [(f a,f b),(f c,f d)]
--   </pre>
type Setter s t a b = forall f. Settable f => (a -> f b) -> s -> f t

-- | A <a>Setter'</a> is just a <a>Setter</a> that doesn't change the
--   types.
--   
--   These are particularly common when talking about monomorphic
--   containers. <i>e.g.</i>
--   
--   <pre>
--   <tt>sets</tt> Data.Text.map :: <a>Setter'</a> <a>Text</a> <a>Char</a>
--   </pre>
--   
--   <pre>
--   type <a>Setter'</a> = <a>Setter'</a>
--   </pre>
type Setter' s a = Setter s s a a

-- | A <a>Getter</a> describes how to retrieve a single value in a way that
--   can be composed with other <a>LensLike</a> constructions.
--   
--   Unlike a <a>Lens</a> a <a>Getter</a> is read-only. Since a
--   <a>Getter</a> cannot be used to write back there are no <a>Lens</a>
--   laws that can be applied to it. In fact, it is isomorphic to an
--   arbitrary function from <tt>(a -&gt; s)</tt>.
--   
--   Moreover, a <a>Getter</a> can be used directly as a <a>Fold</a>, since
--   it just ignores the <a>Applicative</a>.
type Getter s a = forall f. (Contravariant f, Functor f) => (a -> f a) -> s -> f s

-- | A <a>Fold</a> describes how to retrieve multiple values in a way that
--   can be composed with other <a>LensLike</a> constructions.
--   
--   A <tt><a>Fold</a> s a</tt> provides a structure with operations very
--   similar to those of the <a>Foldable</a> typeclass, see
--   <a>foldMapOf</a> and the other <a>Fold</a> combinators.
--   
--   By convention, if there exists a <tt>foo</tt> method that expects a
--   <tt><a>Foldable</a> (f a)</tt>, then there should be a <tt>fooOf</tt>
--   method that takes a <tt><a>Fold</a> s a</tt> and a value of type
--   <tt>s</tt>.
--   
--   A <a>Getter</a> is a legal <a>Fold</a> that just ignores the supplied
--   <a>Monoid</a>.
--   
--   Unlike a <a>Traversal</a> a <a>Fold</a> is read-only. Since a
--   <a>Fold</a> cannot be used to write back there are no <a>Lens</a> laws
--   that apply.
type Fold s a = forall f. (Contravariant f, Applicative f) => (a -> f a) -> s -> f s

-- | An <a>Action</a> is a <a>Getter</a> enriched with access to a
--   <a>Monad</a> for side-effects.
--   
--   Every <a>Getter</a> can be used as an <a>Action</a>.
--   
--   You can compose an <a>Action</a> with another <a>Action</a> using
--   (<a>.</a>) from the <tt>Prelude</tt>.
type Action m s a = forall f r. Effective m r f => (a -> f a) -> s -> f s

-- | A <a>MonadicFold</a> is a <a>Fold</a> enriched with access to a
--   <a>Monad</a> for side-effects.
--   
--   Every <a>Fold</a> can be used as a <a>MonadicFold</a>, that simply
--   ignores the access to the <a>Monad</a>.
--   
--   You can compose a <a>MonadicFold</a> with another <a>MonadicFold</a>
--   using (<a>.</a>) from the <tt>Prelude</tt>.
type MonadicFold m s a = forall f r. (Effective m r f, Applicative f) => (a -> f a) -> s -> f s

-- | Every <a>IndexedLens</a> is a valid <a>Lens</a> and a valid
--   <a>IndexedTraversal</a>.
type IndexedLens i s t a b = forall f p. (Indexable i p, Functor f) => p a (f b) -> s -> f t

-- | <pre>
--   type <a>IndexedLens'</a> i = <a>Simple</a> (<a>IndexedLens</a> i)
--   </pre>
type IndexedLens' i s a = IndexedLens i s s a a

-- | Every <a>IndexedTraversal</a> is a valid <a>Traversal</a> or
--   <a>IndexedFold</a>.
--   
--   The <a>Indexed</a> constraint is used to allow an
--   <a>IndexedTraversal</a> to be used directly as a <a>Traversal</a>.
--   
--   The <a>Traversal</a> laws are still required to hold.
type IndexedTraversal i s t a b = forall p f. (Indexable i p, Applicative f) => p a (f b) -> s -> f t

-- | <pre>
--   type <a>IndexedTraversal'</a> i = <a>Simple</a> (<a>IndexedTraversal</a> i)
--   </pre>
type IndexedTraversal' i s a = IndexedTraversal i s s a a

-- | Every <a>IndexedSetter</a> is a valid <a>Setter</a>.
--   
--   The <a>Setter</a> laws are still required to hold.
type IndexedSetter i s t a b = forall f p. (Indexable i p, Settable f) => p a (f b) -> s -> f t

-- | <pre>
--   type <a>IndexedSetter'</a> i = <a>Simple</a> (<a>IndexedSetter</a> i)
--   </pre>
type IndexedSetter' i s a = IndexedSetter i s s a a

-- | Every <a>IndexedGetter</a> is a valid <a>IndexedFold</a> and can be
--   used for <a>Getting</a> like a <a>Getter</a>.
type IndexedGetter i s a = forall p f. (Indexable i p, Contravariant f, Functor f) => p a (f a) -> s -> f s

-- | Every <a>IndexedFold</a> is a valid <a>Fold</a> and can be used for
--   <a>Getting</a>.
type IndexedFold i s a = forall p f. (Indexable i p, Contravariant f, Applicative f) => p a (f a) -> s -> f s

-- | An <a>IndexedAction</a> is an <a>IndexedGetter</a> enriched with
--   access to a <a>Monad</a> for side-effects.
--   
--   Every <a>Getter</a> can be used as an <a>Action</a>.
--   
--   You can compose an <a>Action</a> with another <a>Action</a> using
--   (<a>.</a>) from the <tt>Prelude</tt>.
type IndexedAction i m s a = forall p f r. (Indexable i p, Effective m r f) => p a (f a) -> s -> f s

-- | An <a>IndexedMonadicFold</a> is an <a>IndexedFold</a> enriched with
--   access to a <a>Monad</a> for side-effects.
--   
--   Every <a>IndexedFold</a> can be used as an <a>IndexedMonadicFold</a>,
--   that simply ignores the access to the <a>Monad</a>.
--   
--   You can compose an <a>IndexedMonadicFold</a> with another
--   <a>IndexedMonadicFold</a> using (<a>.</a>) from the <tt>Prelude</tt>.
type IndexedMonadicFold i m s a = forall p f r. (Indexable i p, Effective m r f, Applicative f) => p a (f a) -> s -> f s

-- | An <a>IndexPreservingLens</a> leaves any index it is composed with
--   alone.
type IndexPreservingLens s t a b = forall p f. (Conjoined p, Functor f) => p a (f b) -> p s (f t)

-- | <pre>
--   type <a>IndexPreservingLens'</a> = <a>Simple</a> <a>IndexPreservingLens</a>
--   </pre>
type IndexPreservingLens' s a = IndexPreservingLens s s a a

-- | An <a>IndexPreservingLens</a> leaves any index it is composed with
--   alone.
type IndexPreservingTraversal s t a b = forall p f. (Conjoined p, Applicative f) => p a (f b) -> p s (f t)

-- | <pre>
--   type <a>IndexPreservingTraversal'</a> = <a>Simple</a> <a>IndexPreservingTraversal</a>
--   </pre>
type IndexPreservingTraversal' s a = IndexPreservingTraversal s s a a

-- | An <a>IndexPreservingSetter</a> can be composed with a
--   <a>IndexedSetter</a>, <a>IndexedTraversal</a> or <a>IndexedLens</a>
--   and leaves the index intact, yielding an <a>IndexedSetter</a>.
type IndexPreservingSetter s t a b = forall p f. (Conjoined p, Settable f) => p a (f b) -> p s (f t)

-- | <pre>
--   type <tt>IndexedPreservingSetter'</tt> i = <a>Simple</a> <tt>IndexedPreservingSetter</tt>
--   </pre>
type IndexPreservingSetter' s a = IndexPreservingSetter s s a a

-- | An <a>IndexPreservingGetter</a> can be used as a <a>Getter</a>, but
--   when composed with an <a>IndexedTraversal</a>, <a>IndexedFold</a>, or
--   <a>IndexedLens</a> yields an <a>IndexedFold</a>, <a>IndexedFold</a> or
--   <a>IndexedGetter</a> respectively.
type IndexPreservingGetter s a = forall p f. (Conjoined p, Contravariant f, Functor f) => p a (f a) -> p s (f s)

-- | An <a>IndexPreservingFold</a> can be used as a <a>Fold</a>, but when
--   composed with an <a>IndexedTraversal</a>, <a>IndexedFold</a>, or
--   <a>IndexedLens</a> yields an <a>IndexedFold</a> respectively.
type IndexPreservingFold s a = forall p f. (Conjoined p, Contravariant f, Applicative f) => p a (f a) -> p s (f s)

-- | An <a>IndexPreservingAction</a> can be used as a <a>Action</a>, but
--   when composed with an <a>IndexedTraversal</a>, <a>IndexedFold</a>, or
--   <a>IndexedLens</a> yields an <a>IndexedMonadicFold</a>,
--   <a>IndexedMonadicFold</a> or <a>IndexedAction</a> respectively.
type IndexPreservingAction m s a = forall p f r. (Conjoined p, Effective m r f) => p a (f a) -> p s (f s)

-- | An <a>IndexPreservingFold</a> can be used as a <a>Fold</a>, but when
--   composed with an <a>IndexedTraversal</a>, <a>IndexedFold</a>, or
--   <a>IndexedLens</a> yields an <a>IndexedFold</a> respectively.
type IndexPreservingMonadicFold m s a = forall p f r. (Conjoined p, Effective m r f, Applicative f) => p a (f a) -> p s (f s)

-- | A <a>Simple</a> <a>Lens</a>, <a>Simple</a> <a>Traversal</a>, ... can
--   be used instead of a <a>Lens</a>,<a>Traversal</a>, ... whenever the
--   type variables don't change upon setting a value.
--   
--   <pre>
--   <a>_imagPart</a> :: <a>Simple</a> <a>Lens</a> (<a>Complex</a> a) a
--   <a>traversed</a> :: <a>Simple</a> (<a>IndexedTraversal</a> <a>Int</a>) [a] a
--   </pre>
--   
--   Note: To use this alias in your own code with <tt><a>LensLike</a>
--   f</tt> or <a>Setter</a>, you may have to turn on
--   <tt>LiberalTypeSynonyms</tt>.
--   
--   This is commonly abbreviated as a "prime" marker, <i>e.g.</i>
--   <a>Lens'</a> = <a>Simple</a> <a>Lens</a>.
type Simple f s a = f s s a a

-- | Many combinators that accept a <a>Lens</a> can also accept a
--   <a>Traversal</a> in limited situations.
--   
--   They do so by specializing the type of <a>Functor</a> that they
--   require of the caller.
--   
--   If a function accepts a <tt><a>LensLike</a> f s t a b</tt> for some
--   <a>Functor</a> <tt>f</tt>, then they may be passed a <a>Lens</a>.
--   
--   Further, if <tt>f</tt> is an <a>Applicative</a>, they may also be
--   passed a <a>Traversal</a>.
type LensLike f s t a b = (a -> f b) -> s -> f t

-- | <pre>
--   type <a>LensLike'</a> f = <a>Simple</a> (<a>LensLike</a> f)
--   </pre>
type LensLike' f s a = LensLike f s s a a

-- | This is a convenient alias for use when you need to consume either
--   indexed or non-indexed lens-likes based on context.
type Over p f s t a b = p a (f b) -> s -> f t

-- | This is a convenient alias for use when you need to consume either
--   indexed or non-indexed lens-likes based on context.
--   
--   <pre>
--   type <a>Over'</a> p f = <a>Simple</a> (<a>Over</a> p f)
--   </pre>
type Over' p f s a = Over p f s s a a

-- | Convenient alias for constructing indexed lenses and their ilk.
type IndexedLensLike i f s t a b = forall p. Indexable i p => p a (f b) -> s -> f t

-- | Convenient alias for constructing simple indexed lenses and their ilk.
type IndexedLensLike' i f s a = IndexedLensLike i f s s a a

-- | <pre>
--   type <a>LensLike</a> f s t a b = <a>Overloading</a> (-&gt;) (-&gt;) f s t a b
--   </pre>
type Overloading p q f s t a b = p a (f b) -> q s (f t)

-- | <pre>
--   type <a>Overloading'</a> p q f s a = <a>Simple</a> (<a>Overloading</a> p q f) s a
--   </pre>
type Overloading' p q f s a = Overloading p q f s s a a

-- | <pre>
--   type <a>LensLike</a> f s t a b = <a>Overloaded</a> (-&gt;) f s t a b
--   </pre>
type Overloaded p f s t a b = p a (f b) -> p s (f t)

-- | <pre>
--   type <a>Overloaded'</a> p q f s a = <a>Simple</a> (<a>Overloaded</a> p q f) s a
--   </pre>
type Overloaded' p f s a = Overloaded p f s s a a


module Control.Lens.Reified

-- | Reify a <a>Lens</a> so it can be stored safely in a container.
newtype ReifiedLens s t a b
ReifyLens :: Lens s t a b -> ReifiedLens s t a b
reflectLens :: ReifiedLens s t a b -> Lens s t a b

-- | <pre>
--   type <a>ReifiedLens'</a> = <a>Simple</a> <a>ReifiedLens</a>
--   </pre>
type ReifiedLens' s a = ReifiedLens s s a a

-- | Reify an <a>IndexedLens</a> so it can be stored safely in a container.
newtype ReifiedIndexedLens i s t a b
ReifyIndexedLens :: IndexedLens i s t a b -> ReifiedIndexedLens i s t a b
reflectIndexedLens :: ReifiedIndexedLens i s t a b -> IndexedLens i s t a b

-- | <pre>
--   type <a>ReifiedIndexedLens'</a> i = <a>Simple</a> (<a>ReifiedIndexedLens</a> i)
--   </pre>
type ReifiedIndexedLens' i s a = ReifiedIndexedLens i s s a a

-- | Reify an <a>IndexedTraversal</a> so it can be stored safely in a
--   container.
newtype ReifiedIndexedTraversal i s t a b
ReifyIndexedTraversal :: IndexedTraversal i s t a b -> ReifiedIndexedTraversal i s t a b
reflectIndexedTraversal :: ReifiedIndexedTraversal i s t a b -> IndexedTraversal i s t a b

-- | <pre>
--   type <a>ReifiedIndexedTraversal'</a> i = <a>Simple</a> (<a>ReifiedIndexedTraversal</a> i)
--   </pre>
type ReifiedIndexedTraversal' i s a = ReifiedIndexedTraversal i s s a a

-- | A form of <a>Traversal</a> that can be stored monomorphically in a
--   container.
data ReifiedTraversal s t a b
ReifyTraversal :: Traversal s t a b -> ReifiedTraversal s t a b
reflectTraversal :: ReifiedTraversal s t a b -> Traversal s t a b

-- | <pre>
--   type <a>ReifiedTraversal'</a> = <a>Simple</a> <a>ReifiedTraversal</a>
--   </pre>
type ReifiedTraversal' s a = ReifiedTraversal s s a a

-- | Reify a <a>Getter</a> so it can be stored safely in a container.
newtype ReifiedGetter s a
ReifyGetter :: Getter s a -> ReifiedGetter s a
reflectGetter :: ReifiedGetter s a -> Getter s a

-- | Reify an <a>IndexedGetter</a> so it can be stored safely in a
--   container.
newtype ReifiedIndexedGetter i s a
ReifyIndexedGetter :: IndexedGetter i s a -> ReifiedIndexedGetter i s a
reflectIndexedGetter :: ReifiedIndexedGetter i s a -> IndexedGetter i s a

-- | Reify a <a>Fold</a> so it can be stored safely in a container.
newtype ReifiedFold s a
ReifyFold :: Fold s a -> ReifiedFold s a
reflectFold :: ReifiedFold s a -> Fold s a

-- | Reify a <a>Setter</a> so it can be stored safely in a container.
newtype ReifiedSetter s t a b
ReifySetter :: Setter s t a b -> ReifiedSetter s t a b
reflectSetter :: ReifiedSetter s t a b -> Setter s t a b

-- | <pre>
--   type <a>ReifiedSetter'</a> = <a>Simple</a> <a>ReifiedSetter</a>
--   </pre>
type ReifiedSetter' s a = ReifiedSetter s s a a

-- | Reify an <a>IndexedSetter</a> so it can be stored safely in a
--   container.
newtype ReifiedIndexedSetter i s t a b
ReifyIndexedSetter :: IndexedSetter i s t a b -> ReifiedIndexedSetter i s t a b
reflectIndexedSetter :: ReifiedIndexedSetter i s t a b -> IndexedSetter i s t a b

-- | <pre>
--   type <a>ReifiedIndexedSetter'</a> i = <a>Simple</a> (<a>ReifiedIndexedSetter</a> i)
--   </pre>
type ReifiedIndexedSetter' i s a = ReifiedIndexedSetter i s s a a

-- | Reify an <a>Iso</a> so it can be stored safely in a container.
newtype ReifiedIso s t a b
ReifyIso :: Iso s t a b -> ReifiedIso s t a b
reflectIso :: ReifiedIso s t a b -> Iso s t a b

-- | <pre>
--   type <a>ReifiedIso'</a> = <a>Simple</a> <a>ReifiedIso</a>
--   </pre>
type ReifiedIso' s a = ReifiedIso s s a a

-- | Reify a <a>Prism</a> so it can be stored safely in a container.
newtype ReifiedPrism s t a b
ReifyPrism :: Prism s t a b -> ReifiedPrism s t a b
reflectPrism :: ReifiedPrism s t a b -> Prism s t a b

-- | <pre>
--   type <a>ReifiedPrism'</a> = <a>Simple</a> <a>ReifiedPrism</a>
--   </pre>
type ReifiedPrism' s a = ReifiedPrism s s a a


module Control.Lens.Equality

-- | A witness that <tt>(a ~ s, b ~ t)</tt>.
--   
--   Note: Composition with an <a>Equality</a> is index-preserving.
type Equality s t a b = forall p (f :: * -> *). p a (f b) -> p s (f t)

-- | A <a>Simple</a> <a>Equality</a>.
type Equality' s a = Equality s s a a

-- | When you see this as an argument to a function, it expects an
--   <a>Equality</a>.
type AnEquality s t a b = Identical a (Mutator b) a (Mutator b) -> Identical a (Mutator b) s (Mutator t)

-- | A <a>Simple</a> <a>AnEquality</a>.
type AnEquality' s a = AnEquality s s a a

-- | Extract a witness of type <a>Equality</a>.
runEq :: AnEquality s t a b -> Identical s t a b

-- | Substituting types with <a>Equality</a>.
substEq :: AnEquality s t a b -> ((s ~ a, t ~ b) => r) -> r

-- | We can use <a>Equality</a> to do substitution into anything.
mapEq :: AnEquality s t a b -> f s -> f a

-- | <a>Equality</a> is symmetric.
fromEq :: AnEquality s t a b -> Equality b a t s

-- | This is an adverb that can be used to modify many other <a>Lens</a>
--   combinators to make them require simple lenses, simple traversals,
--   simple prisms or simple isos as input.
simply :: (Overloaded' p f s a -> r) -> Overloaded' p f s a -> r

-- | Provides witness that <tt>(s ~ a, b ~ t)</tt> holds.
data Identical a b s t
Identical :: Identical a b a b


module Control.Lens.Action

-- | An <a>Action</a> is a <a>Getter</a> enriched with access to a
--   <a>Monad</a> for side-effects.
--   
--   Every <a>Getter</a> can be used as an <a>Action</a>.
--   
--   You can compose an <a>Action</a> with another <a>Action</a> using
--   (<a>.</a>) from the <tt>Prelude</tt>.
type Action m s a = forall f r. Effective m r f => (a -> f a) -> s -> f s

-- | Construct an <a>Action</a> from a monadic side-effect.
--   
--   <pre>
--   &gt;&gt;&gt; ["hello","world"]^!folded.act (\x -&gt; [x,x ++ "!"])
--   ["helloworld","helloworld!","hello!world","hello!world!"]
--   </pre>
--   
--   <pre>
--   <a>act</a> :: <a>Monad</a> m =&gt; (s -&gt; m a) -&gt; <a>Action</a> m s a
--   <a>act</a> sma afb a = <a>effective</a> (sma a <a>&gt;&gt;=</a> <a>ineffective</a> <a>.</a> afb)
--   </pre>
act :: Monad m => (s -> m a) -> IndexPreservingAction m s a

-- | A self-running <a>Action</a>, analogous to <a>join</a>.
--   
--   <pre>
--   <a>acts</a> ≡ <a>act</a> <a>id</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (1,"hello")^!_2.acts.to succ
--   "ifmmp"
--   </pre>
acts :: Action m (m a) a

-- | Perform an <a>Action</a>.
--   
--   <pre>
--   <a>perform</a> ≡ <a>flip</a> (<a>^!</a>)
--   </pre>
perform :: Monad m => Acting m a s t a b -> s -> m a

-- | Perform an <a>Action</a> and modify the result.
--   
--   <pre>
--   <a>performs</a> :: <a>Monad</a> m =&gt; <a>Acting</a> m e s t a b -&gt; (a -&gt; e) -&gt; s -&gt; m e
--   </pre>
performs :: (Profunctor p, Monad m) => Over p (Effect m e) s t a b -> p a e -> s -> m e

-- | Apply a <a>Monad</a> transformer to an <a>Action</a>.
liftAct :: (MonadTrans trans, Monad m) => Acting m a s t a b -> Action (trans m) s a

-- | Perform an <a>Action</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ["hello","world"]^!folded.act putStrLn
--   hello
--   world
--   </pre>
(^!) :: Monad m => s -> Acting m a s t a b -> m a

-- | Perform a <a>MonadicFold</a> and collect all of the results in a list.
--   
--   <pre>
--   &gt;&gt;&gt; ["ab","cd","ef"]^!!folded.acts
--   ["ace","acf","ade","adf","bce","bcf","bde","bdf"]
--   </pre>
(^!!) :: Monad m => s -> Acting m [a] s t a b -> m [a]

-- | Perform a <a>MonadicFold</a> and collect the leftmost result.
--   
--   <i>Note:</i> this still causes all effects for all elements.
--   
--   <pre>
--   &gt;&gt;&gt; [Just 1, Just 2, Just 3]^!?folded.acts
--   Just (Just 1)
--   
--   &gt;&gt;&gt; [Just 1, Nothing]^!?folded.acts
--   Nothing
--   </pre>
(^!?) :: Monad m => s -> Acting m (Leftmost a) s t a b -> m (Maybe a)

-- | An <a>IndexedAction</a> is an <a>IndexedGetter</a> enriched with
--   access to a <a>Monad</a> for side-effects.
--   
--   Every <a>Getter</a> can be used as an <a>Action</a>.
--   
--   You can compose an <a>Action</a> with another <a>Action</a> using
--   (<a>.</a>) from the <tt>Prelude</tt>.
type IndexedAction i m s a = forall p f r. (Indexable i p, Effective m r f) => p a (f a) -> s -> f s

-- | Construct an <a>IndexedAction</a> from a monadic side-effect.
iact :: Monad m => (s -> m (i, a)) -> IndexedAction i m s a

-- | Perform an <a>IndexedAction</a>.
--   
--   <pre>
--   <a>iperform</a> ≡ <a>flip</a> (<a>^@!</a>)
--   </pre>
iperform :: Monad m => IndexedActing i m (i, a) s t a b -> s -> m (i, a)

-- | Perform an <a>IndexedAction</a> and modify the result.
iperforms :: Monad m => IndexedActing i m e s t a b -> (i -> a -> e) -> s -> m e

-- | Perform an <a>IndexedAction</a>.
(^@!) :: Monad m => s -> IndexedActing i m (i, a) s t a b -> m (i, a)

-- | Obtain a list of all of the results of an <a>IndexedMonadicFold</a>.
(^@!!) :: Monad m => s -> IndexedActing i m [(i, a)] s t a b -> m [(i, a)]

-- | Perform an <a>IndexedMonadicFold</a> and collect the <a>Leftmost</a>
--   result.
--   
--   <i>Note:</i> this still causes all effects for all elements.
(^@!?) :: Monad m => s -> IndexedActing i m (Leftmost (i, a)) s t a b -> m (Maybe (i, a))

-- | A <a>MonadicFold</a> is a <a>Fold</a> enriched with access to a
--   <a>Monad</a> for side-effects.
--   
--   Every <a>Fold</a> can be used as a <a>MonadicFold</a>, that simply
--   ignores the access to the <a>Monad</a>.
--   
--   You can compose a <a>MonadicFold</a> with another <a>MonadicFold</a>
--   using (<a>.</a>) from the <tt>Prelude</tt>.
type MonadicFold m s a = forall f r. (Effective m r f, Applicative f) => (a -> f a) -> s -> f s

-- | An <a>IndexedMonadicFold</a> is an <a>IndexedFold</a> enriched with
--   access to a <a>Monad</a> for side-effects.
--   
--   Every <a>IndexedFold</a> can be used as an <a>IndexedMonadicFold</a>,
--   that simply ignores the access to the <a>Monad</a>.
--   
--   You can compose an <a>IndexedMonadicFold</a> with another
--   <a>IndexedMonadicFold</a> using (<a>.</a>) from the <tt>Prelude</tt>.
type IndexedMonadicFold i m s a = forall p f r. (Indexable i p, Effective m r f, Applicative f) => p a (f a) -> s -> f s

-- | Used to evaluate an <a>Action</a>.
type Acting m r s t a b = LensLike (Effect m r) s t a b

-- | Used to evaluate an <a>IndexedAction</a>.
type IndexedActing i m r s t a b = Over (Indexed i) (Effect m r) s t a b

-- | An <a>Effective</a> <a>Functor</a> ignores its argument and is
--   isomorphic to a <a>Monad</a> wrapped around a value.
--   
--   That said, the <a>Monad</a> is possibly rather unrelated to any
--   <a>Applicative</a> structure.
class (Monad m, Functor f, Contravariant f) => Effective m r f | f -> m r


-- | These are some of the explicit <a>Functor</a> instances that leak into
--   the type signatures of <tt>Control.Lens</tt>. You shouldn't need to
--   import this module directly for most use-cases.
module Control.Lens.Internal


-- | A <tt><a>Setter</a> s t a b</tt> is a generalization of <a>fmap</a>
--   from <a>Functor</a>. It allows you to map into a structure and change
--   out the contents, but it isn't strong enough to allow you to enumerate
--   those contents. Starting with <tt><a>fmap</a> :: <a>Functor</a> f
--   =&gt; (a -&gt; b) -&gt; f a -&gt; f b</tt> we monomorphize the type to
--   obtain <tt>(a -&gt; b) -&gt; s -&gt; t</tt> and then decorate it with
--   <a>Identity</a> to obtain:
--   
--   <pre>
--   type <a>Setter</a> s t a b = (a -&gt; <a>Identity</a> b) -&gt; s -&gt; <a>Identity</a> t
--   </pre>
--   
--   Every <a>Traversal</a> is a valid <a>Setter</a>, since <a>Identity</a>
--   is <a>Applicative</a>.
--   
--   Everything you can do with a <a>Functor</a>, you can do with a
--   <a>Setter</a>. There are combinators that generalize <a>fmap</a> and
--   (<a>&lt;$</a>).
module Control.Lens.Setter

-- | The only <a>LensLike</a> law that can apply to a <a>Setter</a>
--   <tt>l</tt> is that
--   
--   <pre>
--   <a>set</a> l y (<a>set</a> l x a) ≡ <a>set</a> l y a
--   </pre>
--   
--   You can't <a>view</a> a <a>Setter</a> in general, so the other two
--   laws are irrelevant.
--   
--   However, two <a>Functor</a> laws apply to a <a>Setter</a>:
--   
--   <pre>
--   <a>over</a> l <a>id</a> ≡ <a>id</a>
--   <a>over</a> l f <a>.</a> <a>over</a> l g ≡ <a>over</a> l (f <a>.</a> g)
--   </pre>
--   
--   These can be stated more directly:
--   
--   <pre>
--   l <a>pure</a> ≡ <a>pure</a>
--   l f <a>.</a> <a>untainted</a> <a>.</a> l g ≡ l (f <a>.</a> <a>untainted</a> <a>.</a> g)
--   </pre>
--   
--   You can compose a <a>Setter</a> with a <a>Lens</a> or a
--   <a>Traversal</a> using (<a>.</a>) from the <tt>Prelude</tt> and the
--   result is always only a <a>Setter</a> and nothing more.
--   
--   <pre>
--   &gt;&gt;&gt; over traverse f [a,b,c,d]
--   [f a,f b,f c,f d]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over _1 f (a,b)
--   (f a,b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over (traverse._1) f [(a,b),(c,d)]
--   [(f a,b),(f c,d)]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over both f (a,b)
--   (f a,f b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over (traverse.both) f [(a,b),(c,d)]
--   [(f a,f b),(f c,f d)]
--   </pre>
type Setter s t a b = forall f. Settable f => (a -> f b) -> s -> f t

-- | A <a>Setter'</a> is just a <a>Setter</a> that doesn't change the
--   types.
--   
--   These are particularly common when talking about monomorphic
--   containers. <i>e.g.</i>
--   
--   <pre>
--   <tt>sets</tt> Data.Text.map :: <a>Setter'</a> <a>Text</a> <a>Char</a>
--   </pre>
--   
--   <pre>
--   type <a>Setter'</a> = <a>Setter'</a>
--   </pre>
type Setter' s a = Setter s s a a

-- | Every <a>IndexedSetter</a> is a valid <a>Setter</a>.
--   
--   The <a>Setter</a> laws are still required to hold.
type IndexedSetter i s t a b = forall f p. (Indexable i p, Settable f) => p a (f b) -> s -> f t

-- | <pre>
--   type <a>IndexedSetter'</a> i = <a>Simple</a> (<a>IndexedSetter</a> i)
--   </pre>
type IndexedSetter' i s a = IndexedSetter i s s a a

-- | Running a <a>Setter</a> instantiates it to a concrete type.
--   
--   When consuming a setter directly to perform a mapping, you can use
--   this type, but most user code will not need to use this type.
--   
--   By choosing <a>Mutator</a> rather than <a>Identity</a>, we get nicer
--   error messages.
type ASetter s t a b = (a -> Mutator b) -> s -> Mutator t

-- | This is a useful alias for use when consuming a <a>Setter'</a>.
--   
--   Most user code will never have to use this type.
--   
--   <pre>
--   type <a>ASetter'</a> = <a>Simple</a> <a>ASetter</a>
--   </pre>
type ASetter' s a = ASetter s s a a

-- | Running an <a>IndexedSetter</a> instantiates it to a concrete type.
--   
--   When consuming a setter directly to perform a mapping, you can use
--   this type, but most user code will not need to use this type.
--   
--   By choosing <a>Mutator</a> rather than <a>Identity</a>, we get nicer
--   error messages.
type AnIndexedSetter i s t a b = Indexed i a (Mutator b) -> s -> Mutator t

-- | <pre>
--   type <a>AnIndexedSetter'</a> i = <a>Simple</a> (<a>AnIndexedSetter</a> i)
--   </pre>
type AnIndexedSetter' i s a = AnIndexedSetter i s s a a

-- | This is a convenient alias when defining highly polymorphic code that
--   takes both <a>ASetter</a> and <a>AnIndexedSetter</a> as appropriate.
--   If a function takes this it is expecting one of those two things based
--   on context.
type Setting p s t a b = p a (Mutator b) -> s -> Mutator t

-- | This is a convenient alias when defining highly polymorphic code that
--   takes both <a>ASetter'</a> and <a>AnIndexedSetter'</a> as appropriate.
--   If a function takes this it is expecting one of those two things based
--   on context.
type Setting' p s a = Setting p s s a a

-- | Build a <a>Setter</a>, <a>IndexedSetter</a> or
--   <a>IndexPreservingSetter</a> depending on your choice of
--   <a>Profunctor</a>.
--   
--   <pre>
--   <a>sets</a> :: ((a -&gt; b) -&gt; s -&gt; t) -&gt; <a>Setter</a> s t a b
--   </pre>
sets :: (Profunctor p, Profunctor q, Settable f) => (p a b -> q s t) -> Overloading p q f s t a b

-- | Build an index-preserving <a>Setter</a> from a map-like function.
--   
--   Your supplied function <tt>f</tt> is required to satisfy:
--   
--   <pre>
--   f <a>id</a> ≡ <a>id</a>
--   f g <a>.</a> f h ≡ f (g <a>.</a> h)
--   </pre>
--   
--   Equational reasoning:
--   
--   <pre>
--   <a>setting</a> <a>.</a> <a>over</a> ≡ <a>id</a>
--   <a>over</a> <a>.</a> <a>setting</a> ≡ <a>id</a>
--   </pre>
--   
--   Another way to view <a>sets</a> is that it takes a "semantic editor
--   combinator" and transforms it into a <a>Setter</a>.
--   
--   <pre>
--   <a>setting</a> :: ((a -&gt; b) -&gt; s -&gt; t) -&gt; <a>Setter</a> s t a b
--   </pre>
setting :: ((a -> b) -> s -> t) -> IndexPreservingSetter s t a b

-- | Restore <a>ASetter</a> to a full <a>Setter</a>.
cloneSetter :: ASetter s t a b -> Setter s t a b

-- | Build an <a>IndexPreservingSetter</a> from any <a>Setter</a>.
cloneIndexPreservingSetter :: ASetter s t a b -> IndexPreservingSetter s t a b

-- | Clone an <a>IndexedSetter</a>.
cloneIndexedSetter :: AnIndexedSetter i s t a b -> IndexedSetter i s t a b

-- | This <a>Setter</a> can be used to map over all of the values in a
--   <a>Functor</a>.
--   
--   <pre>
--   <a>fmap</a> ≡ <a>over</a> <a>mapped</a>
--   <a>fmapDefault</a> ≡ <a>over</a> <a>traverse</a>
--   (<a>&lt;$</a>) ≡ <a>set</a> <a>mapped</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over mapped f [a,b,c]
--   [f a,f b,f c]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over mapped (+1) [1,2,3]
--   [2,3,4]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; set mapped x [a,b,c]
--   [x,x,x]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [[a,b],[c]] &amp; mapped.mapped +~ x
--   [[a + x,b + x],[c + x]]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over (mapped._2) length [("hello","world"),("leaders","!!!")]
--   [("hello",5),("leaders",3)]
--   </pre>
--   
--   <pre>
--   <a>mapped</a> :: <a>Functor</a> f =&gt; <a>Setter</a> (f a) (f b) a b
--   </pre>
--   
--   If you want an <a>IndexPreservingSetter</a> use <tt><a>setting</a>
--   <a>fmap</a></tt>.
mapped :: Functor f => Setter (f a) (f b) a b

-- | This <tt>setter</tt> can be used to modify all of the values in a
--   <a>Monad</a>.
--   
--   You sometimes have to use this rather than <a>mapped</a> -- due to
--   temporary insanity <a>Functor</a> is not a superclass of <a>Monad</a>.
--   
--   <pre>
--   <a>liftM</a> ≡ <a>over</a> <a>lifted</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over lifted f [a,b,c]
--   [f a,f b,f c]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; set lifted b (Just a)
--   Just b
--   </pre>
--   
--   If you want an <a>IndexPreservingSetter</a> use <tt><a>setting</a>
--   <a>liftM</a></tt>.
lifted :: Monad m => Setter (m a) (m b) a b

-- | This <a>Setter</a> can be used to map over all of the inputs to a
--   <a>Contravariant</a>.
--   
--   <pre>
--   <a>contramap</a> ≡ <a>over</a> <a>contramapped</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; getPredicate (over contramapped (*2) (Predicate even)) 5
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; getOp (over contramapped (*5) (Op show)) 100
--   "500"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Prelude.map ($ 1) $ over (mapped . wrapping Op . contramapped) (*12) [(*2),(+1),(^3)]
--   [24,13,1728]
--   </pre>
contramapped :: Contravariant f => Setter (f b) (f a) a b

-- | This <a>Setter</a> can be used to map over the input of a
--   <a>Profunctor</a>.
--   
--   The most common <a>Profunctor</a> to use this with is
--   <tt>(-&gt;)</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; (argument %~ f) g x
--   g (f x)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (argument %~ show) length [1,2,3]
--   7
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (argument %~ f) h x y
--   h (f x) y
--   </pre>
--   
--   Map over the argument of the result of a function -- i.e., its second
--   argument:
--   
--   <pre>
--   &gt;&gt;&gt; (mapped.argument %~ f) h x y
--   h x (f y)
--   </pre>
--   
--   <pre>
--   <a>argument</a> :: <a>Setter</a> (b -&gt; r) (a -&gt; r) a b
--   </pre>
argument :: Profunctor p => Setter (p b r) (p a r) a b

-- | Modify the target of a <a>Lens</a> or all the targets of a
--   <a>Setter</a> or <a>Traversal</a> with a function.
--   
--   <pre>
--   <a>fmap</a> ≡ <a>over</a> <a>mapped</a>
--   <a>fmapDefault</a> ≡ <a>over</a> <a>traverse</a>
--   <a>sets</a> <a>.</a> <a>over</a> ≡ <a>id</a>
--   <a>over</a> <a>.</a> <a>sets</a> ≡ <a>id</a>
--   </pre>
--   
--   Given any valid <a>Setter</a> <tt>l</tt>, you can also rely on the
--   law:
--   
--   <pre>
--   <a>over</a> l f <a>.</a> <a>over</a> l g = <a>over</a> l (f <a>.</a> g)
--   </pre>
--   
--   <i>e.g.</i>
--   
--   <pre>
--   &gt;&gt;&gt; over mapped f (over mapped g [a,b,c]) == over mapped (f . g) [a,b,c]
--   True
--   </pre>
--   
--   Another way to view <a>over</a> is to say that it transforms a
--   <a>Setter</a> into a "semantic editor combinator".
--   
--   <pre>
--   &gt;&gt;&gt; over mapped f (Just a)
--   Just (f a)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over mapped (*10) [1,2,3]
--   [10,20,30]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over _1 f (a,b)
--   (f a,b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over _1 show (10,20)
--   ("10",20)
--   </pre>
--   
--   <pre>
--   <a>over</a> :: <a>Setter</a> s t a b -&gt; (a -&gt; b) -&gt; s -&gt; t
--   <a>over</a> :: <a>ASetter</a> s t a b -&gt; (a -&gt; b) -&gt; s -&gt; t
--   </pre>
over :: Profunctor p => Setting p s t a b -> p a b -> s -> t

-- | Replace the target of a <a>Lens</a> or all of the targets of a
--   <a>Setter</a> or <a>Traversal</a> with a constant value.
--   
--   <pre>
--   (<a>&lt;$</a>) ≡ <a>set</a> <a>mapped</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; set _2 "hello" (1,())
--   (1,"hello")
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; set mapped () [1,2,3,4]
--   [(),(),(),()]
--   </pre>
--   
--   Note: Attempting to <a>set</a> a <a>Fold</a> or <a>Getter</a> will
--   fail at compile time with an relatively nice error message.
--   
--   <pre>
--   <a>set</a> :: <a>Setter</a> s t a b    -&gt; b -&gt; s -&gt; t
--   <a>set</a> :: <a>Iso</a> s t a b       -&gt; b -&gt; s -&gt; t
--   <a>set</a> :: <a>Lens</a> s t a b      -&gt; b -&gt; s -&gt; t
--   <a>set</a> :: <a>Traversal</a> s t a b -&gt; b -&gt; s -&gt; t
--   </pre>
set :: ASetter s t a b -> b -> s -> t

-- | Replace the target of a <a>Lens</a> or all of the targets of a
--   <a>Setter</a> or <a>Traversal</a> with a constant value.
--   
--   This is an infix version of <a>set</a>, provided for consistency with
--   (<a>.=</a>).
--   
--   <pre>
--   f <a>&lt;$</a> a ≡ <a>mapped</a> <a>.~</a> f <a>$</a> a
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b,c,d) &amp; _4 .~ e
--   (a,b,c,e)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (42,"world") &amp; _1 .~ "hello"
--   ("hello","world")
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; both .~ c
--   (c,c)
--   </pre>
--   
--   <pre>
--   (<a>.~</a>) :: <a>Setter</a> s t a b    -&gt; b -&gt; s -&gt; t
--   (<a>.~</a>) :: <a>Iso</a> s t a b       -&gt; b -&gt; s -&gt; t
--   (<a>.~</a>) :: <a>Lens</a> s t a b      -&gt; b -&gt; s -&gt; t
--   (<a>.~</a>) :: <a>Traversal</a> s t a b -&gt; b -&gt; s -&gt; t
--   </pre>
(.~) :: ASetter s t a b -> b -> s -> t

-- | Modifies the target of a <a>Lens</a> or all of the targets of a
--   <a>Setter</a> or <a>Traversal</a> with a user supplied function.
--   
--   This is an infix version of <a>over</a>.
--   
--   <pre>
--   <a>fmap</a> f ≡ <a>mapped</a> <a>%~</a> f
--   <a>fmapDefault</a> f ≡ <a>traverse</a> <a>%~</a> f
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b,c) &amp; _3 %~ f
--   (a,b,f c)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; both %~ f
--   (f a,f b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; _2 %~ length $ (1,"hello")
--   (1,5)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; traverse %~ f $ [a,b,c]
--   [f a,f b,f c]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; traverse %~ even $ [1,2,3]
--   [False,True,False]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; traverse.traverse %~ length $ [["hello","world"],["!!!"]]
--   [[5,5],[3]]
--   </pre>
--   
--   <pre>
--   (<a>%~</a>) :: <a>Setter</a> s t a b    -&gt; (a -&gt; b) -&gt; s -&gt; t
--   (<a>%~</a>) :: <a>Iso</a> s t a b       -&gt; (a -&gt; b) -&gt; s -&gt; t
--   (<a>%~</a>) :: <a>Lens</a> s t a b      -&gt; (a -&gt; b) -&gt; s -&gt; t
--   (<a>%~</a>) :: <a>Traversal</a> s t a b -&gt; (a -&gt; b) -&gt; s -&gt; t
--   </pre>
(%~) :: Profunctor p => Setting p s t a b -> p a b -> s -> t

-- | Increment the target(s) of a numerically valued <a>Lens</a>,
--   <a>Setter</a> or <a>Traversal</a>.
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; _1 +~ c
--   (a + c,b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; both +~ c
--   (a + c,b + c)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (1,2) &amp; _2 +~ 1
--   (1,3)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [(a,b),(c,d)] &amp; traverse.both +~ e
--   [(a + e,b + e),(c + e,d + e)]
--   </pre>
--   
--   <pre>
--   (<a>+~</a>) :: <a>Num</a> a =&gt; <a>Setter'</a> s a    -&gt; a -&gt; s -&gt; s
--   (<a>+~</a>) :: <a>Num</a> a =&gt; <a>Iso'</a> s a       -&gt; a -&gt; s -&gt; s
--   (<a>+~</a>) :: <a>Num</a> a =&gt; <a>Lens'</a> s a      -&gt; a -&gt; s -&gt; s
--   (<a>+~</a>) :: <a>Num</a> a =&gt; <a>Traversal'</a> s a -&gt; a -&gt; s -&gt; s
--   </pre>
(+~) :: Num a => ASetter s t a a -> a -> s -> t

-- | Decrement the target(s) of a numerically valued <a>Lens</a>,
--   <a>Iso</a>, <a>Setter</a> or <a>Traversal</a>.
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; _1 -~ c
--   (a - c,b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; both -~ c
--   (a - c,b - c)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; _1 -~ 2 $ (1,2)
--   (-1,2)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; mapped.mapped -~ 1 $ [[4,5],[6,7]]
--   [[3,4],[5,6]]
--   </pre>
--   
--   <pre>
--   (<a>-~</a>) :: <a>Num</a> a =&gt; <a>Setter'</a> s a    -&gt; a -&gt; s -&gt; s
--   (<a>-~</a>) :: <a>Num</a> a =&gt; <a>Iso'</a> s a       -&gt; a -&gt; s -&gt; s
--   (<a>-~</a>) :: <a>Num</a> a =&gt; <a>Lens'</a> s a      -&gt; a -&gt; s -&gt; s
--   (<a>-~</a>) :: <a>Num</a> a =&gt; <a>Traversal'</a> s a -&gt; a -&gt; s -&gt; s
--   </pre>
(-~) :: Num a => ASetter s t a a -> a -> s -> t

-- | Multiply the target(s) of a numerically valued <a>Lens</a>,
--   <a>Iso</a>, <a>Setter</a> or <a>Traversal</a>.
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; _1 *~ c
--   (a * c,b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; both *~ c
--   (a * c,b * c)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (1,2) &amp; _2 *~ 4
--   (1,8)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Just 24 &amp; mapped *~ 2
--   Just 48
--   </pre>
--   
--   <pre>
--   (<a>*~</a>) :: <a>Num</a> a =&gt; <a>Setter'</a> s a    -&gt; a -&gt; s -&gt; s
--   (<a>*~</a>) :: <a>Num</a> a =&gt; <a>Iso'</a> s a       -&gt; a -&gt; s -&gt; s
--   (<a>*~</a>) :: <a>Num</a> a =&gt; <a>Lens'</a> s a      -&gt; a -&gt; s -&gt; s
--   (<a>*~</a>) :: <a>Num</a> a =&gt; <a>Traversal'</a> s a -&gt; a -&gt; s -&gt; s
--   </pre>
(*~) :: Num a => ASetter s t a a -> a -> s -> t

-- | Divide the target(s) of a numerically valued <a>Lens</a>, <a>Iso</a>,
--   <a>Setter</a> or <a>Traversal</a>.
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; _1 //~ c
--   (a / c,b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; both //~ c
--   (a / c,b / c)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ("Hawaii",10) &amp; _2 //~ 2
--   ("Hawaii",5.0)
--   </pre>
--   
--   <pre>
--   (<a>//~</a>) :: <a>Fractional</a> a =&gt; <a>Setter'</a> s a    -&gt; a -&gt; s -&gt; s
--   (<a>//~</a>) :: <a>Fractional</a> a =&gt; <a>Iso'</a> s a       -&gt; a -&gt; s -&gt; s
--   (<a>//~</a>) :: <a>Fractional</a> a =&gt; <a>Lens'</a> s a      -&gt; a -&gt; s -&gt; s
--   (<a>//~</a>) :: <a>Fractional</a> a =&gt; <a>Traversal'</a> s a -&gt; a -&gt; s -&gt; s
--   </pre>
(//~) :: Fractional a => ASetter s t a a -> a -> s -> t

-- | Raise the target(s) of a numerically valued <a>Lens</a>, <a>Setter</a>
--   or <a>Traversal</a> to a non-negative integral power.
--   
--   <pre>
--   &gt;&gt;&gt; (1,3) &amp; _2 ^~ 2
--   (1,9)
--   </pre>
--   
--   <pre>
--   (<a>^~</a>) :: (<a>Num</a> a, <a>Integral</a> e) =&gt; <a>Setter'</a> s a    -&gt; e -&gt; s -&gt; s
--   (<a>^~</a>) :: (<a>Num</a> a, <a>Integral</a> e) =&gt; <a>Iso'</a> s a       -&gt; e -&gt; s -&gt; s
--   (<a>^~</a>) :: (<a>Num</a> a, <a>Integral</a> e) =&gt; <a>Lens'</a> s a      -&gt; e -&gt; s -&gt; s
--   (<a>^~</a>) :: (<a>Num</a> a, <a>Integral</a> e) =&gt; <a>Traversal'</a> s a -&gt; e -&gt; s -&gt; s
--   </pre>
(^~) :: (Num a, Integral e) => ASetter s t a a -> e -> s -> t

-- | Raise the target(s) of a fractionally valued <a>Lens</a>,
--   <a>Setter</a> or <a>Traversal</a> to an integral power.
--   
--   <pre>
--   &gt;&gt;&gt; (1,2) &amp; _2 ^^~ (-1)
--   (1,0.5)
--   </pre>
--   
--   <pre>
--   (<a>^^~</a>) :: (<a>Fractional</a> a, <a>Integral</a> e) =&gt; <a>Setter'</a> s a    -&gt; e -&gt; s -&gt; s
--   (<a>^^~</a>) :: (<a>Fractional</a> a, <a>Integral</a> e) =&gt; <a>Iso'</a> s a       -&gt; e -&gt; s -&gt; s
--   (<a>^^~</a>) :: (<a>Fractional</a> a, <a>Integral</a> e) =&gt; <a>Lens'</a> s a      -&gt; e -&gt; s -&gt; s
--   (<a>^^~</a>) :: (<a>Fractional</a> a, <a>Integral</a> e) =&gt; <a>Traversal'</a> s a -&gt; e -&gt; s -&gt; s
--   </pre>
(^^~) :: (Fractional a, Integral e) => ASetter s t a a -> e -> s -> t

-- | Raise the target(s) of a floating-point valued <a>Lens</a>,
--   <a>Setter</a> or <a>Traversal</a> to an arbitrary power.
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; _1 **~ c
--   (a**c,b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; both **~ c
--   (a**c,b**c)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; _2 **~ 10 $ (3,2)
--   (3,1024.0)
--   </pre>
--   
--   <pre>
--   (<a>**~</a>) :: <a>Floating</a> a =&gt; <a>Setter'</a> s a    -&gt; a -&gt; s -&gt; s
--   (<a>**~</a>) :: <a>Floating</a> a =&gt; <a>Iso'</a> s a       -&gt; a -&gt; s -&gt; s
--   (<a>**~</a>) :: <a>Floating</a> a =&gt; <a>Lens'</a> s a      -&gt; a -&gt; s -&gt; s
--   (<a>**~</a>) :: <a>Floating</a> a =&gt; <a>Traversal'</a> s a -&gt; a -&gt; s -&gt; s
--   </pre>
(**~) :: Floating a => ASetter s t a a -> a -> s -> t

-- | Logically <a>||</a> the target(s) of a <a>Bool</a>-valued <a>Lens</a>
--   or <a>Setter</a>.
--   
--   <pre>
--   &gt;&gt;&gt; both ||~ True $ (False,True)
--   (True,True)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; both ||~ False $ (False,True)
--   (False,True)
--   </pre>
--   
--   <pre>
--   (<a>||~</a>) :: <a>Setter'</a> s <a>Bool</a>    -&gt; <a>Bool</a> -&gt; s -&gt; s
--   (<a>||~</a>) :: <a>Iso'</a> s <a>Bool</a>       -&gt; <a>Bool</a> -&gt; s -&gt; s
--   (<a>||~</a>) :: <a>Lens'</a> s <a>Bool</a>      -&gt; <a>Bool</a> -&gt; s -&gt; s
--   (<a>||~</a>) :: <a>Traversal'</a> s <a>Bool</a> -&gt; <a>Bool</a> -&gt; s -&gt; s
--   </pre>
(||~) :: ASetter s t Bool Bool -> Bool -> s -> t

-- | Modify the target of a monoidally valued by <a>mappend</a>ing another
--   value.
--   
--   <pre>
--   &gt;&gt;&gt; (Sum a,b) &amp; _1 &lt;&gt;~ Sum c
--   (Sum {getSum = a + c},b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (Sum a,Sum b) &amp; both &lt;&gt;~ Sum c
--   (Sum {getSum = a + c},Sum {getSum = b + c})
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; both &lt;&gt;~ "!!!" $ ("hello","world")
--   ("hello!!!","world!!!")
--   </pre>
--   
--   <pre>
--   (<a>&lt;&gt;~</a>) :: <a>Monoid</a> a =&gt; <a>Setter</a> s t a a    -&gt; a -&gt; s -&gt; t
--   (<a>&lt;&gt;~</a>) :: <a>Monoid</a> a =&gt; <a>Iso</a> s t a a       -&gt; a -&gt; s -&gt; t
--   (<a>&lt;&gt;~</a>) :: <a>Monoid</a> a =&gt; <a>Lens</a> s t a a      -&gt; a -&gt; s -&gt; t
--   (<a>&lt;&gt;~</a>) :: <a>Monoid</a> a =&gt; <a>Traversal</a> s t a a -&gt; a -&gt; s -&gt; t
--   </pre>
(<>~) :: Monoid a => ASetter s t a a -> a -> s -> t

-- | Logically <a>&amp;&amp;</a> the target(s) of a <a>Bool</a>-valued
--   <a>Lens</a> or <a>Setter</a>.
--   
--   <pre>
--   &gt;&gt;&gt; both &amp;&amp;~ True $ (False, True)
--   (False,True)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; both &amp;&amp;~ False $ (False, True)
--   (False,False)
--   </pre>
--   
--   <pre>
--   (<a>&amp;&amp;~</a>) :: <a>Setter'</a> s <a>Bool</a>    -&gt; <a>Bool</a> -&gt; s -&gt; s
--   (<a>&amp;&amp;~</a>) :: <a>Iso'</a> s <a>Bool</a>       -&gt; <a>Bool</a> -&gt; s -&gt; s
--   (<a>&amp;&amp;~</a>) :: <a>Lens'</a> s <a>Bool</a>      -&gt; <a>Bool</a> -&gt; s -&gt; s
--   (<a>&amp;&amp;~</a>) :: <a>Traversal'</a> s <a>Bool</a> -&gt; <a>Bool</a> -&gt; s -&gt; s
--   </pre>
(&&~) :: ASetter s t Bool Bool -> Bool -> s -> t

-- | Set with pass-through.
--   
--   This is mostly present for consistency, but may be useful for for
--   chaining assignments.
--   
--   If you do not need a copy of the intermediate result, then using <tt>l
--   <a>.~</a> t</tt> directly is a good idea.
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; _1 &lt;.~ c
--   (c,(c,b))
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ("good","morning","vietnam") &amp; _3 &lt;.~ "world"
--   ("world",("good","morning","world"))
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (42,Map.fromList [("goodnight","gracie")]) &amp; _2.at "hello" &lt;.~ Just "world"
--   (Just "world",(42,fromList [("goodnight","gracie"),("hello","world")]))
--   </pre>
--   
--   <pre>
--   (<a>&lt;.~</a>) :: <a>Setter</a> s t a b    -&gt; b -&gt; s -&gt; (b, t)
--   (<a>&lt;.~</a>) :: <a>Iso</a> s t a b       -&gt; b -&gt; s -&gt; (b, t)
--   (<a>&lt;.~</a>) :: <a>Lens</a> s t a b      -&gt; b -&gt; s -&gt; (b, t)
--   (<a>&lt;.~</a>) :: <a>Traversal</a> s t a b -&gt; b -&gt; s -&gt; (b, t)
--   </pre>
(<.~) :: ASetter s t a b -> b -> s -> (b, t)

-- | Set the target of a <a>Lens</a>, <a>Traversal</a> or <a>Setter</a> to
--   <a>Just</a> a value.
--   
--   <pre>
--   l <a>?~</a> t ≡ <a>set</a> l (<a>Just</a> t)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Nothing &amp; id ?~ a
--   Just a
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Map.empty &amp; at 3 ?~ x
--   fromList [(3,x)]
--   </pre>
--   
--   <pre>
--   (<a>?~</a>) :: <a>Setter</a> s t a (<a>Maybe</a> b)    -&gt; b -&gt; s -&gt; t
--   (<a>?~</a>) :: <a>Iso</a> s t a (<a>Maybe</a> b)       -&gt; b -&gt; s -&gt; t
--   (<a>?~</a>) :: <a>Lens</a> s t a (<a>Maybe</a> b)      -&gt; b -&gt; s -&gt; t
--   (<a>?~</a>) :: <a>Traversal</a> s t a (<a>Maybe</a> b) -&gt; b -&gt; s -&gt; t
--   </pre>
(?~) :: ASetter s t a (Maybe b) -> b -> s -> t

-- | Set to <a>Just</a> a value with pass-through.
--   
--   This is mostly present for consistency, but may be useful for for
--   chaining assignments.
--   
--   If you do not need a copy of the intermediate result, then using <tt>l
--   <a>?~</a> d</tt> directly is a good idea.
--   
--   <pre>
--   &gt;&gt;&gt; import Data.Map as Map
--   
--   &gt;&gt;&gt; _2.at "hello" &lt;?~ "world" $ (42,Map.fromList [("goodnight","gracie")])
--   ("world",(42,fromList [("goodnight","gracie"),("hello","world")]))
--   </pre>
--   
--   <pre>
--   (<a>&lt;?~</a>) :: <a>Setter</a> s t a (<a>Maybe</a> b)    -&gt; b -&gt; s -&gt; (b, t)
--   (<a>&lt;?~</a>) :: <a>Iso</a> s t a (<a>Maybe</a> b)       -&gt; b -&gt; s -&gt; (b, t)
--   (<a>&lt;?~</a>) :: <a>Lens</a> s t a (<a>Maybe</a> b)      -&gt; b -&gt; s -&gt; (b, t)
--   (<a>&lt;?~</a>) :: <a>Traversal</a> s t a (<a>Maybe</a> b) -&gt; b -&gt; s -&gt; (b, t)
--   </pre>
(<?~) :: ASetter s t a (Maybe b) -> b -> s -> (b, t)

-- | Replace the target of a <a>Lens</a> or all of the targets of a
--   <a>Setter</a> or <a>Traversal</a> in our monadic state with a new
--   value, irrespective of the old.
--   
--   This is an alias for (<a>.=</a>).
--   
--   <pre>
--   &gt;&gt;&gt; execState (do assign _1 c; assign _2 d) (a,b)
--   (c,d)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; execState (both .= c) (a,b)
--   (c,c)
--   </pre>
--   
--   <pre>
--   <a>assign</a> :: <a>MonadState</a> s m =&gt; <a>Iso'</a> s a       -&gt; a -&gt; m ()
--   <a>assign</a> :: <a>MonadState</a> s m =&gt; <a>Lens'</a> s a      -&gt; a -&gt; m ()
--   <a>assign</a> :: <a>MonadState</a> s m =&gt; <a>Traversal'</a> s a -&gt; a -&gt; m ()
--   <a>assign</a> :: <a>MonadState</a> s m =&gt; <a>Setter'</a> s a    -&gt; a -&gt; m ()
--   </pre>
assign :: MonadState s m => ASetter s s a b -> b -> m ()

-- | Replace the target of a <a>Lens</a> or all of the targets of a
--   <a>Setter</a> or <a>Traversal</a> in our monadic state with a new
--   value, irrespective of the old.
--   
--   This is an infix version of <a>assign</a>.
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 .= c; _2 .= d) (a,b)
--   (c,d)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; execState (both .= c) (a,b)
--   (c,c)
--   </pre>
--   
--   <pre>
--   (<a>.=</a>) :: <a>MonadState</a> s m =&gt; <a>Iso'</a> s a       -&gt; a -&gt; m ()
--   (<a>.=</a>) :: <a>MonadState</a> s m =&gt; <a>Lens'</a> s a      -&gt; a -&gt; m ()
--   (<a>.=</a>) :: <a>MonadState</a> s m =&gt; <a>Traversal'</a> s a -&gt; a -&gt; m ()
--   (<a>.=</a>) :: <a>MonadState</a> s m =&gt; <a>Setter'</a> s a    -&gt; a -&gt; m ()
--   </pre>
--   
--   <a>It puts the state in the monad or it gets the hose again.</a>
(.=) :: MonadState s m => ASetter s s a b -> b -> m ()

-- | Map over the target of a <a>Lens</a> or all of the targets of a
--   <a>Setter</a> or <a>Traversal</a> in our monadic state.
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 %= f;_2 %= g) (a,b)
--   (f a,g b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; execState (do both %= f) (a,b)
--   (f a,f b)
--   </pre>
--   
--   <pre>
--   (<a>%=</a>) :: <a>MonadState</a> s m =&gt; <a>Iso'</a> s a       -&gt; (a -&gt; a) -&gt; m ()
--   (<a>%=</a>) :: <a>MonadState</a> s m =&gt; <a>Lens'</a> s a      -&gt; (a -&gt; a) -&gt; m ()
--   (<a>%=</a>) :: <a>MonadState</a> s m =&gt; <a>Traversal'</a> s a -&gt; (a -&gt; a) -&gt; m ()
--   (<a>%=</a>) :: <a>MonadState</a> s m =&gt; <a>Setter'</a> s a    -&gt; (a -&gt; a) -&gt; m ()
--   </pre>
--   
--   <pre>
--   (<a>%=</a>) :: <a>MonadState</a> s m =&gt; <a>ASetter</a> s s a b -&gt; (a -&gt; b) -&gt; m ()
--   </pre>
(%=) :: (Profunctor p, MonadState s m) => Setting p s s a b -> p a b -> m ()

-- | Modify the target(s) of a <a>Lens'</a>, <a>Iso</a>, <a>Setter</a> or
--   <a>Traversal</a> by adding a value.
--   
--   Example:
--   
--   <pre>
--   <tt>fresh</tt> :: <a>MonadState</a> <a>Int</a> m =&gt; m <a>Int</a>
--   <tt>fresh</tt> = do
--     <a>id</a> <a>+=</a> 1
--     <a>use</a> <a>id</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 += c; _2 += d) (a,b)
--   (a + c,b + d)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1.at 1.non 0 += 10) (Map.fromList [(2,100)],"hello")
--   (fromList [(1,10),(2,100)],"hello")
--   </pre>
--   
--   <pre>
--   (<a>+=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Setter'</a> s a    -&gt; a -&gt; m ()
--   (<a>+=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Iso'</a> s a       -&gt; a -&gt; m ()
--   (<a>+=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Lens'</a> s a      -&gt; a -&gt; m ()
--   (<a>+=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Traversal'</a> s a -&gt; a -&gt; m ()
--   </pre>
(+=) :: (MonadState s m, Num a) => ASetter' s a -> a -> m ()

-- | Modify the target(s) of a <a>Lens'</a>, <a>Iso</a>, <a>Setter</a> or
--   <a>Traversal</a> by subtracting a value.
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 -= c; _2 -= d) (a,b)
--   (a - c,b - d)
--   </pre>
--   
--   <pre>
--   (<a>-=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Setter'</a> s a    -&gt; a -&gt; m ()
--   (<a>-=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Iso'</a> s a       -&gt; a -&gt; m ()
--   (<a>-=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Lens'</a> s a      -&gt; a -&gt; m ()
--   (<a>-=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Traversal'</a> s a -&gt; a -&gt; m ()
--   </pre>
(-=) :: (MonadState s m, Num a) => ASetter' s a -> a -> m ()

-- | Modify the target(s) of a <a>Lens'</a>, <a>Iso</a>, <a>Setter</a> or
--   <a>Traversal</a> by multiplying by value.
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 *= c; _2 *= d) (a,b)
--   (a * c,b * d)
--   </pre>
--   
--   <pre>
--   (<a>*=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Setter'</a> s a    -&gt; a -&gt; m ()
--   (<a>*=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Iso'</a> s a       -&gt; a -&gt; m ()
--   (<a>*=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Lens'</a> s a      -&gt; a -&gt; m ()
--   (<a>*=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Traversal'</a> s a -&gt; a -&gt; m ()
--   </pre>
(*=) :: (MonadState s m, Num a) => ASetter' s a -> a -> m ()

-- | Modify the target(s) of a <a>Lens'</a>, <a>Iso</a>, <a>Setter</a> or
--   <a>Traversal</a> by dividing by a value.
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 //= c; _2 //= d) (a,b)
--   (a / c,b / d)
--   </pre>
--   
--   <pre>
--   (<a>//=</a>) :: (<a>MonadState</a> s m, <a>Fractional</a> a) =&gt; <a>Setter'</a> s a    -&gt; a -&gt; m ()
--   (<a>//=</a>) :: (<a>MonadState</a> s m, <a>Fractional</a> a) =&gt; <a>Iso'</a> s a       -&gt; a -&gt; m ()
--   (<a>//=</a>) :: (<a>MonadState</a> s m, <a>Fractional</a> a) =&gt; <a>Lens'</a> s a      -&gt; a -&gt; m ()
--   (<a>//=</a>) :: (<a>MonadState</a> s m, <a>Fractional</a> a) =&gt; <a>Traversal'</a> s a -&gt; a -&gt; m ()
--   </pre>
(//=) :: (MonadState s m, Fractional a) => ASetter' s a -> a -> m ()

-- | Raise the target(s) of a numerically valued <a>Lens</a>, <a>Setter</a>
--   or <a>Traversal</a> to a non-negative integral power.
--   
--   <pre>
--   (<a>^=</a>) ::  (<a>MonadState</a> s m, <a>Num</a> a, <a>Integral</a> e) =&gt; <a>Setter'</a> s a    -&gt; e -&gt; m ()
--   (<a>^=</a>) ::  (<a>MonadState</a> s m, <a>Num</a> a, <a>Integral</a> e) =&gt; <a>Iso'</a> s a       -&gt; e -&gt; m ()
--   (<a>^=</a>) ::  (<a>MonadState</a> s m, <a>Num</a> a, <a>Integral</a> e) =&gt; <a>Lens'</a> s a      -&gt; e -&gt; m ()
--   (<a>^=</a>) ::  (<a>MonadState</a> s m, <a>Num</a> a, <a>Integral</a> e) =&gt; <a>Traversal'</a> s a -&gt; e -&gt; m ()
--   </pre>
(^=) :: (MonadState s m, Num a, Integral e) => ASetter' s a -> e -> m ()

-- | Raise the target(s) of a numerically valued <a>Lens</a>, <a>Setter</a>
--   or <a>Traversal</a> to an integral power.
--   
--   <pre>
--   (<a>^^=</a>) ::  (<a>MonadState</a> s m, <a>Fractional</a> a, <a>Integral</a> e) =&gt; <a>Setter'</a> s a    -&gt; e -&gt; m ()
--   (<a>^^=</a>) ::  (<a>MonadState</a> s m, <a>Fractional</a> a, <a>Integral</a> e) =&gt; <a>Iso'</a> s a       -&gt; e -&gt; m ()
--   (<a>^^=</a>) ::  (<a>MonadState</a> s m, <a>Fractional</a> a, <a>Integral</a> e) =&gt; <a>Lens'</a> s a      -&gt; e -&gt; m ()
--   (<a>^^=</a>) ::  (<a>MonadState</a> s m, <a>Fractional</a> a, <a>Integral</a> e) =&gt; <a>Traversal'</a> s a -&gt; e -&gt; m ()
--   </pre>
(^^=) :: (MonadState s m, Fractional a, Integral e) => ASetter' s a -> e -> m ()

-- | Raise the target(s) of a numerically valued <a>Lens</a>, <a>Setter</a>
--   or <a>Traversal</a> to an arbitrary power
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 **= c; _2 **= d) (a,b)
--   (a**c,b**d)
--   </pre>
--   
--   <pre>
--   (<a>**=</a>) ::  (<a>MonadState</a> s m, <a>Floating</a> a) =&gt; <a>Setter'</a> s a    -&gt; a -&gt; m ()
--   (<a>**=</a>) ::  (<a>MonadState</a> s m, <a>Floating</a> a) =&gt; <a>Iso'</a> s a       -&gt; a -&gt; m ()
--   (<a>**=</a>) ::  (<a>MonadState</a> s m, <a>Floating</a> a) =&gt; <a>Lens'</a> s a      -&gt; a -&gt; m ()
--   (<a>**=</a>) ::  (<a>MonadState</a> s m, <a>Floating</a> a) =&gt; <a>Traversal'</a> s a -&gt; a -&gt; m ()
--   </pre>
(**=) :: (MonadState s m, Floating a) => ASetter' s a -> a -> m ()

-- | Modify the target(s) of a <a>Lens'</a>, 'Iso, <a>Setter</a> or
--   <a>Traversal</a> by taking their logical <a>||</a> with a value.
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 ||= True; _2 ||= False; _3 ||= True; _4 ||= False) (True,True,False,False)
--   (True,True,True,False)
--   </pre>
--   
--   <pre>
--   (<a>||=</a>) :: <a>MonadState</a> s m =&gt; <a>Setter'</a> s <a>Bool</a>    -&gt; <a>Bool</a> -&gt; m ()
--   (<a>||=</a>) :: <a>MonadState</a> s m =&gt; <a>Iso'</a> s <a>Bool</a>       -&gt; <a>Bool</a> -&gt; m ()
--   (<a>||=</a>) :: <a>MonadState</a> s m =&gt; <a>Lens'</a> s <a>Bool</a>      -&gt; <a>Bool</a> -&gt; m ()
--   (<a>||=</a>) :: <a>MonadState</a> s m =&gt; <a>Traversal'</a> s <a>Bool</a> -&gt; <a>Bool</a> -&gt; m ()
--   </pre>
(||=) :: MonadState s m => ASetter' s Bool -> Bool -> m ()

-- | Modify the target(s) of a <a>Lens'</a>, <a>Iso</a>, <a>Setter</a> or
--   <a>Traversal</a> by <a>mappend</a>ing a value.
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 &lt;&gt;= Sum c; _2 &lt;&gt;= Product d) (Sum a,Product b)
--   (Sum {getSum = a + c},Product {getProduct = b * d})
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; execState (both &lt;&gt;= "!!!") ("hello","world")
--   ("hello!!!","world!!!")
--   </pre>
--   
--   <pre>
--   (<a>&lt;&gt;=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> a) =&gt; <a>Setter'</a> s a -&gt; a -&gt; m ()
--   (<a>&lt;&gt;=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> a) =&gt; <a>Iso'</a> s a -&gt; a -&gt; m ()
--   (<a>&lt;&gt;=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> a) =&gt; <a>Lens'</a> s a -&gt; a -&gt; m ()
--   (<a>&lt;&gt;=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> a) =&gt; <a>Traversal'</a> s a -&gt; a -&gt; m ()
--   </pre>
(<>=) :: (MonadState s m, Monoid a) => ASetter' s a -> a -> m ()

-- | Modify the target(s) of a <a>Lens'</a>, <a>Iso</a>, <a>Setter</a> or
--   <a>Traversal</a> by taking their logical <a>&amp;&amp;</a> with a
--   value.
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 &amp;&amp;= True; _2 &amp;&amp;= False; _3 &amp;&amp;= True; _4 &amp;&amp;= False) (True,True,False,False)
--   (True,False,False,False)
--   </pre>
--   
--   <pre>
--   (<a>&amp;&amp;=</a>) :: <a>MonadState</a> s m =&gt; <a>Setter'</a> s <a>Bool</a>    -&gt; <a>Bool</a> -&gt; m ()
--   (<a>&amp;&amp;=</a>) :: <a>MonadState</a> s m =&gt; <a>Iso'</a> s <a>Bool</a>       -&gt; <a>Bool</a> -&gt; m ()
--   (<a>&amp;&amp;=</a>) :: <a>MonadState</a> s m =&gt; <a>Lens'</a> s <a>Bool</a>      -&gt; <a>Bool</a> -&gt; m ()
--   (<a>&amp;&amp;=</a>) :: <a>MonadState</a> s m =&gt; <a>Traversal'</a> s <a>Bool</a> -&gt; <a>Bool</a> -&gt; m ()
--   </pre>
(&&=) :: MonadState s m => ASetter' s Bool -> Bool -> m ()

-- | Set with pass-through
--   
--   This is useful for chaining assignment without round-tripping through
--   your <a>Monad</a> stack.
--   
--   <pre>
--   do x &lt;- <a>_2</a> <a>&lt;.=</a> ninety_nine_bottles_of_beer_on_the_wall
--   </pre>
--   
--   If you do not need a copy of the intermediate result, then using <tt>l
--   <a>.=</a> d</tt> will avoid unused binding warnings.
--   
--   <pre>
--   (<a>&lt;.=</a>) :: <a>MonadState</a> s m =&gt; <a>Setter</a> s s a b    -&gt; b -&gt; m b
--   (<a>&lt;.=</a>) :: <a>MonadState</a> s m =&gt; <a>Iso</a> s s a b       -&gt; b -&gt; m b
--   (<a>&lt;.=</a>) :: <a>MonadState</a> s m =&gt; <a>Lens</a> s s a b      -&gt; b -&gt; m b
--   (<a>&lt;.=</a>) :: <a>MonadState</a> s m =&gt; <a>Traversal</a> s s a b -&gt; b -&gt; m b
--   </pre>
(<.=) :: MonadState s m => ASetter s s a b -> b -> m b

-- | Replace the target of a <a>Lens</a> or all of the targets of a
--   <a>Setter</a> or <a>Traversal</a> in our monadic state with
--   <a>Just</a> a new value, irrespective of the old.
--   
--   <pre>
--   &gt;&gt;&gt; execState (do at 1 ?= a; at 2 ?= b) Map.empty
--   fromList [(1,a),(2,b)]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 ?= b; _2 ?= c) (Just a, Nothing)
--   (Just b,Just c)
--   </pre>
--   
--   <pre>
--   (<a>?=</a>) :: <a>MonadState</a> s m =&gt; <a>Iso'</a> s (<a>Maybe</a> a)       -&gt; a -&gt; m ()
--   (<a>?=</a>) :: <a>MonadState</a> s m =&gt; <a>Lens'</a> s (<a>Maybe</a> a)      -&gt; a -&gt; m ()
--   (<a>?=</a>) :: <a>MonadState</a> s m =&gt; <a>Traversal'</a> s (<a>Maybe</a> a) -&gt; a -&gt; m ()
--   (<a>?=</a>) :: <a>MonadState</a> s m =&gt; <a>Setter'</a> s (<a>Maybe</a> a)    -&gt; a -&gt; m ()
--   </pre>
(?=) :: MonadState s m => ASetter s s a (Maybe b) -> b -> m ()

-- | Set <a>Just</a> a value with pass-through
--   
--   This is useful for chaining assignment without round-tripping through
--   your <a>Monad</a> stack.
--   
--   <pre>
--   do x &lt;- <a>at</a> <a>foo</a> <a>&lt;?=</a> ninety_nine_bottles_of_beer_on_the_wall
--   </pre>
--   
--   If you do not need a copy of the intermediate result, then using <tt>l
--   <a>?=</a> d</tt> will avoid unused binding warnings.
--   
--   <pre>
--   (<a>&lt;?=</a>) :: <a>MonadState</a> s m =&gt; <a>Setter</a> s s a (<a>Maybe</a> b)    -&gt; b -&gt; m b
--   (<a>&lt;?=</a>) :: <a>MonadState</a> s m =&gt; <a>Iso</a> s s a (<a>Maybe</a> b)       -&gt; b -&gt; m b
--   (<a>&lt;?=</a>) :: <a>MonadState</a> s m =&gt; <a>Lens</a> s s a (<a>Maybe</a> b)      -&gt; b -&gt; m b
--   (<a>&lt;?=</a>) :: <a>MonadState</a> s m =&gt; <a>Traversal</a> s s a (<a>Maybe</a> b) -&gt; b -&gt; m b
--   </pre>
(<?=) :: MonadState s m => ASetter s s a (Maybe b) -> b -> m b

-- | Run a monadic action, and set all of the targets of a <a>Lens</a>,
--   <a>Setter</a> or <a>Traversal</a> to its result.
--   
--   <pre>
--   (<a>&lt;~</a>) :: <a>MonadState</a> s m =&gt; <a>Iso</a> s s a b       -&gt; m b -&gt; m ()
--   (<a>&lt;~</a>) :: <a>MonadState</a> s m =&gt; <a>Lens</a> s s a b      -&gt; m b -&gt; m ()
--   (<a>&lt;~</a>) :: <a>MonadState</a> s m =&gt; <a>Traversal</a> s s a b -&gt; m b -&gt; m ()
--   (<a>&lt;~</a>) :: <a>MonadState</a> s m =&gt; <a>Setter</a> s s a b    -&gt; m b -&gt; m ()
--   </pre>
--   
--   As a reasonable mnemonic, this lets you store the result of a monadic
--   action in a <a>Lens</a> rather than in a local variable.
--   
--   <pre>
--   do foo &lt;- bar
--      ...
--   </pre>
--   
--   will store the result in a variable, while
--   
--   <pre>
--   do foo <a>&lt;~</a> bar
--      ...
--   </pre>
--   
--   will store the result in a <a>Lens</a>, <a>Setter</a>, or
--   <a>Traversal</a>.
(<~) :: MonadState s m => ASetter s s a b -> m b -> m ()

-- | Write to a fragment of a larger <tt>Writer</tt> format.
scribe :: (MonadWriter t m, Monoid s) => ASetter s t a b -> b -> m ()

-- | This is a generalization of <a>pass</a> that alows you to modify just
--   a portion of the resulting <a>MonadWriter</a>.
passing :: MonadWriter w m => Setter w w u v -> m (a, u -> v) -> m a

-- | This is a generalization of <a>pass</a> that alows you to modify just
--   a portion of the resulting <a>MonadWriter</a> with access to the index
--   of an <a>IndexedSetter</a>.
ipassing :: MonadWriter w m => IndexedSetter i w w u v -> m (a, i -> u -> v) -> m a

-- | This is a generalization of <a>censor</a> that alows you to
--   <a>censor</a> just a portion of the resulting <a>MonadWriter</a>.
censoring :: MonadWriter w m => Setter w w u v -> (u -> v) -> m a -> m a

-- | This is a generalization of <a>censor</a> that alows you to
--   <a>censor</a> just a portion of the resulting <a>MonadWriter</a>, with
--   access to the index of an <a>IndexedSetter</a>.
icensoring :: MonadWriter w m => IndexedSetter i w w u v -> (i -> u -> v) -> m a -> m a

-- | Replace the target of a <a>Lens</a> or all of the targets of a
--   <a>Setter'</a> or <a>Traversal</a> with a constant value, without
--   changing its type.
--   
--   This is a type restricted version of <a>set</a>, which retains the
--   type of the original.
--   
--   <pre>
--   &gt;&gt;&gt; set' mapped x [a,b,c,d]
--   [x,x,x,x]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; set' _2 "hello" (1,"world")
--   (1,"hello")
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; set' mapped 0 [1,2,3,4]
--   [0,0,0,0]
--   </pre>
--   
--   Note: Attempting to adjust <a>set'</a> a <a>Fold</a> or <a>Getter</a>
--   will fail at compile time with an relatively nice error message.
--   
--   <pre>
--   <a>set'</a> :: <a>Setter'</a> s a    -&gt; a -&gt; s -&gt; s
--   <a>set'</a> :: <a>Iso'</a> s a       -&gt; a -&gt; s -&gt; s
--   <a>set'</a> :: <a>Lens'</a> s a      -&gt; a -&gt; s -&gt; s
--   <a>set'</a> :: <a>Traversal'</a> s a -&gt; a -&gt; s -&gt; s
--   </pre>
set' :: ASetter' s a -> a -> s -> s

-- | Map with index. (Deprecated alias for <a>iover</a>).
--   
--   When you do not need access to the index, then <a>mapOf</a> is more
--   liberal in what it can accept.
--   
--   <pre>
--   <a>mapOf</a> l ≡ <a>imapOf</a> l <a>.</a> <a>const</a>
--   </pre>
--   
--   <pre>
--   <a>imapOf</a> :: <a>IndexedSetter</a> i s t a b    -&gt; (i -&gt; a -&gt; b) -&gt; s -&gt; t
--   <a>imapOf</a> :: <a>IndexedLens</a> i s t a b      -&gt; (i -&gt; a -&gt; b) -&gt; s -&gt; t
--   <a>imapOf</a> :: <a>IndexedTraversal</a> i s t a b -&gt; (i -&gt; a -&gt; b) -&gt; s -&gt; t
--   </pre>

-- | <i>Deprecated: Use <a>iover</a> </i>
imapOf :: AnIndexedSetter i s t a b -> (i -> a -> b) -> s -> t

-- | Map with index. This is an alias for <a>imapOf</a>.
--   
--   When you do not need access to the index, then <a>over</a> is more
--   liberal in what it can accept.
--   
--   <pre>
--   <a>over</a> l ≡ <a>iover</a> l <a>.</a> <a>const</a>
--   <a>iover</a> l ≡ <a>over</a> l <a>.</a> <a>Indexed</a>
--   </pre>
--   
--   <pre>
--   <a>iover</a> :: <a>IndexedSetter</a> i s t a b    -&gt; (i -&gt; a -&gt; b) -&gt; s -&gt; t
--   <a>iover</a> :: <a>IndexedLens</a> i s t a b      -&gt; (i -&gt; a -&gt; b) -&gt; s -&gt; t
--   <a>iover</a> :: <a>IndexedTraversal</a> i s t a b -&gt; (i -&gt; a -&gt; b) -&gt; s -&gt; t
--   </pre>
iover :: AnIndexedSetter i s t a b -> (i -> a -> b) -> s -> t

-- | Build an <a>IndexedSetter</a> from an <a>imap</a>-like function.
--   
--   Your supplied function <tt>f</tt> is required to satisfy:
--   
--   <pre>
--   f <a>id</a> ≡ <a>id</a>
--   f g <a>.</a> f h ≡ f (g <a>.</a> h)
--   </pre>
--   
--   Equational reasoning:
--   
--   <pre>
--   <a>isets</a> <a>.</a> <a>iover</a> ≡ <a>id</a>
--   <a>iover</a> <a>.</a> <a>isets</a> ≡ <a>id</a>
--   </pre>
--   
--   Another way to view <a>sets</a> is that it takes a "semantic editor
--   combinator" and transforms it into a <a>Setter</a>.
isets :: ((i -> a -> b) -> s -> t) -> IndexedSetter i s t a b

-- | Adjust every target of an <a>IndexedSetter</a>, <a>IndexedLens</a> or
--   <a>IndexedTraversal</a> with access to the index.
--   
--   <pre>
--   (<a>%@~</a>) ≡ <a>imapOf</a>
--   </pre>
--   
--   When you do not need access to the index then (<a>%@~</a>) is more
--   liberal in what it can accept.
--   
--   <pre>
--   l <a>%~</a> f ≡ l <a>%@~</a> <a>const</a> f
--   </pre>
--   
--   <pre>
--   (<a>%@~</a>) :: <a>IndexedSetter</a> i s t a b    -&gt; (i -&gt; a -&gt; b) -&gt; s -&gt; t
--   (<a>%@~</a>) :: <a>IndexedLens</a> i s t a b      -&gt; (i -&gt; a -&gt; b) -&gt; s -&gt; t
--   (<a>%@~</a>) :: <a>IndexedTraversal</a> i s t a b -&gt; (i -&gt; a -&gt; b) -&gt; s -&gt; t
--   </pre>
(%@~) :: AnIndexedSetter i s t a b -> (i -> a -> b) -> s -> t

-- | Adjust every target in the current state of an <a>IndexedSetter</a>,
--   <a>IndexedLens</a> or <a>IndexedTraversal</a> with access to the
--   index.
--   
--   When you do not need access to the index then (<a>%=</a>) is more
--   liberal in what it can accept.
--   
--   <pre>
--   l <a>%=</a> f ≡ l <a>%@=</a> <a>const</a> f
--   </pre>
--   
--   <pre>
--   (<a>%@=</a>) :: <a>MonadState</a> s m =&gt; <a>IndexedSetter</a> i s s a b    -&gt; (i -&gt; a -&gt; b) -&gt; m ()
--   (<a>%@=</a>) :: <a>MonadState</a> s m =&gt; <a>IndexedLens</a> i s s a b      -&gt; (i -&gt; a -&gt; b) -&gt; m ()
--   (<a>%@=</a>) :: <a>MonadState</a> s m =&gt; <a>IndexedTraversal</a> i s t a b -&gt; (i -&gt; a -&gt; b) -&gt; m ()
--   </pre>
(%@=) :: MonadState s m => AnIndexedSetter i s s a b -> (i -> a -> b) -> m ()

-- | Anything <a>Settable</a> must be isomorphic to the <a>Identity</a>
--   <a>Functor</a>.
class (Applicative f, Distributive f, Traversable f) => Settable f where untaintedDot g = g `seq` rmap untainted g taintedDot g = g `seq` rmap pure g

-- | <a>Mutator</a> is just a renamed <a>Identity</a> <a>Functor</a> to
--   give better error messages when someone attempts to use a
--   <a>Getter</a> as a <a>Setter</a>.
--   
--   Most user code will never need to see this type.
data Mutator a

-- | <a>mapOf</a> is a deprecated alias for <a>over</a>.

-- | <i>Deprecated: Use <a>over</a> </i>
mapOf :: Profunctor p => Setting p s t a b -> p a b -> s -> t


-- | Deprecated names for simple lenses, etc.
module Control.Lens.Simple

-- | Deprecated. Use <a>Lens'</a>.

-- | <i>Deprecated: use Lens' </i>
type SimpleLens s a = Lens s s a a

-- | Deprecated. Use <a>ReifiedLens'</a>.

-- | <i>Deprecated: use Lens' </i>
type SimpleReifiedLens s a = Lens s s a a

-- | Deprecated. Use <a>Traversal'</a>.

-- | <i>Deprecated: use Traversal' </i>
type SimpleTraversal s a = Traversal s s a a

-- | Deprecated. Use <a>ReifiedTraversal'</a>.

-- | <i>Deprecated: use ReifiedTraversal' </i>
type SimpleReifiedTraversal s a = ReifiedTraversal s s a a

-- | Deprecated. Use <a>IndexedTraversal'</a>.

-- | <i>Deprecated: use IndexedTraversal' </i>
type SimpleIndexedTraversal i s a = IndexedTraversal i s s a a

-- | Deprecated. Use <a>ReifiedIndexedTraversal'</a>.

-- | <i>Deprecated: use ReifiedIndexedTraversal' </i>
type SimpleReifiedIndexedTraversal i s a = ReifiedIndexedTraversal i s s a a

-- | Deprecated. Use <a>Setter'</a>.

-- | <i>Deprecated: use Setter' </i>
type SimpleSetter s a = Setter s s a a

-- | Deprecated. Use <a>ReifiedSetter'</a>.

-- | <i>Deprecated: use ReifiedSetter' </i>
type SimpleReifiedSetter s a = ReifiedSetter s s a a

-- | Deprecated. Use <a>IndexedSetter'</a>.

-- | <i>Deprecated: use IndexedSetter' </i>
type SimpleIndexedSetter i s a = IndexedSetter i s s a a

-- | Deprecated. Use <a>ReifiedIndexedSetter'</a>.

-- | <i>Deprecated: use ReifiedIndexedSetter' </i>
type SimpleReifiedIndexedSetter i s a = ReifiedIndexedSetter i s s a a

-- | Deprecated. Use <a>Iso'</a>.

-- | <i>Deprecated: use Iso' </i>
type SimpleIso s a = Iso s s a a

-- | Deprecated. Use <a>Prism'</a>.

-- | <i>Deprecated: use Prism' </i>
type SimplePrism s a = Prism s s a a


module Control.Lens.Iso

-- | Isomorphism families can be composed with another <a>Lens</a> using
--   (<a>.</a>) and <a>id</a>.
--   
--   Note: Composition with an <a>Iso</a> is index- and measure-
--   preserving.
type Iso s t a b = forall p f. (Profunctor p, Functor f) => p a (f b) -> p s (f t)

-- | <pre>
--   type <a>Iso'</a> = <a>Simple</a> <a>Iso</a>
--   </pre>
type Iso' s a = Iso s s a a

-- | When you see this as an argument to a function, it expects an
--   <a>Iso</a>.
type AnIso s t a b = Exchange a b a (Mutator b) -> Exchange a b s (Mutator t)

-- | A <a>Simple</a> <a>AnIso</a>.
type AnIso' s a = AnIso s s a a

-- | Build a simple isomorphism from a pair of inverse functions.
--   
--   <pre>
--   <a>view</a> (<a>iso</a> f g) ≡ f
--   <a>view</a> (<a>from</a> (<a>iso</a> f g)) ≡ g
--   <a>set</a> (<a>iso</a> f g) h ≡ g <a>.</a> h <a>.</a> f
--   <a>set</a> (<a>from</a> (<a>iso</a> f g)) h ≡ f <a>.</a> h <a>.</a> g
--   </pre>
iso :: (s -> a) -> (b -> t) -> Iso s t a b

-- | Invert an isomorphism.
--   
--   <pre>
--   <a>from</a> (<a>from</a> l) ≡ l
--   </pre>
from :: AnIso s t a b -> Iso b a t s

-- | Convert from <a>AnIso</a> back to any <a>Iso</a>.
--   
--   This is useful when you need to store an isomorphism as a data type
--   inside a container and later reconstitute it as an overloaded
--   function.
--   
--   See <a>cloneLens</a> or <a>cloneTraversal</a> for more information on
--   why you might want to do this.
cloneIso :: AnIso s t a b -> Iso s t a b

-- | Extract the two functions, one from <tt>s -&gt; a</tt> and one from
--   <tt>b -&gt; t</tt> that characterize an <a>Iso</a>.
withIso :: AnIso s t a b -> ((s -> a) -> (b -> t) -> r) -> r

-- | Based on <a>ala</a> from Conor McBride's work on Epigram.
--   
--   This version is generalized to accept any <a>Iso</a>, not just a
--   <tt>newtype</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; au (wrapping Sum) foldMap [1,2,3,4]
--   10
--   </pre>
au :: AnIso s t a b -> ((s -> a) -> e -> b) -> e -> t

-- | Based on <tt>ala'</tt> from Conor McBride's work on Epigram.
--   
--   This version is generalized to accept any <a>Iso</a>, not just a
--   <tt>newtype</tt>.
--   
--   For a version you pass the name of the <tt>newtype</tt> constructor
--   to, see <a>alaf</a>.
--   
--   Mnemonically, the German <i>auf</i> plays a similar role to <i>à
--   la</i>, and the combinator is <a>au</a> with an extra function
--   argument.
--   
--   <pre>
--   &gt;&gt;&gt; auf (wrapping Sum) (foldMapOf both) Prelude.length ("hello","world")
--   10
--   </pre>
auf :: AnIso s t a b -> ((r -> a) -> e -> b) -> (r -> s) -> e -> t

-- | The opposite of working <a>over</a> a <a>Setter</a> is working
--   <a>under</a> an isomorphism.
--   
--   <pre>
--   <a>under</a> ≡ <a>over</a> <a>.</a> <a>from</a>
--   </pre>
--   
--   <pre>
--   <a>under</a> :: <a>Iso</a> s t a b -&gt; (t -&gt; s) -&gt; b -&gt; a
--   </pre>
under :: AnIso s t a b -> (t -> s) -> b -> a

-- | This can be used to lift any <a>Iso</a> into an arbitrary
--   <a>Functor</a>.
mapping :: Functor f => AnIso s t a b -> Iso (f s) (f t) (f a) (f b)

-- | Composition with this isomorphism is occasionally useful when your
--   <a>Lens</a>, <a>Traversal</a> or <a>Iso</a> has a constraint on an
--   unused argument to force that argument to agree with the type of a
--   used argument and avoid <tt>ScopedTypeVariables</tt> or other
--   ugliness.
simple :: Iso' a a

-- | If <tt>v</tt> is an element of a type <tt>a</tt>, and <tt>a'</tt> is
--   <tt>a</tt> sans the element <tt>v</tt>, then <tt><a>non</a> v</tt> is
--   an isomorphism from <tt><a>Maybe</a> a'</tt> to <tt>a</tt>.
--   
--   Keep in mind this is only a real isomorphism if you treat the domain
--   as being <tt><a>Maybe</a> (a sans v)</tt>.
--   
--   This is practically quite useful when you want to have a <a>Map</a>
--   where all the entries should have non-zero values.
--   
--   <pre>
--   &gt;&gt;&gt; Map.fromList [("hello",1)] &amp; at "hello" . non 0 +~ 2
--   fromList [("hello",3)]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Map.fromList [("hello",1)] &amp; at "hello" . non 0 -~ 1
--   fromList []
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Map.fromList [("hello",1)] ^. at "hello" . non 0
--   1
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Map.fromList [] ^. at "hello" . non 0
--   0
--   </pre>
--   
--   This combinator is also particularly useful when working with nested
--   maps.
--   
--   <i>e.g.</i> When you want to create the nested <a>Map</a> when it is
--   missing:
--   
--   <pre>
--   &gt;&gt;&gt; Map.empty &amp; at "hello" . non Map.empty . at "world" ?~ "!!!"
--   fromList [("hello",fromList [("world","!!!")])]
--   </pre>
--   
--   and when have deleting the last entry from the nested <a>Map</a> mean
--   that we should delete its entry from the surrounding one:
--   
--   <pre>
--   &gt;&gt;&gt; fromList [("hello",fromList [("world","!!!")])] &amp; at "hello" . non Map.empty . at "world" .~ Nothing
--   fromList []
--   </pre>
non :: Eq a => a -> Iso' (Maybe a) a

-- | <tt><a>anon</a> a p</tt> generalizes <tt><a>non</a> a</tt> to take any
--   value and a predicate.
--   
--   This function assumes that <tt>p a</tt> holds <tt><a>True</a></tt> and
--   generates an isomorphism between <tt><a>Maybe</a> (a | <a>not</a> (p
--   a))</tt> and <tt>a</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; Map.empty &amp; at "hello" . anon Map.empty Map.null . at "world" ?~ "!!!"
--   fromList [("hello",fromList [("world","!!!")])]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; fromList [("hello",fromList [("world","!!!")])] &amp; at "hello" . anon Map.empty Map.null . at "world" .~ Nothing
--   fromList []
--   </pre>
anon :: a -> (a -> Bool) -> Iso' (Maybe a) a

-- | This isomorphism can be used to convert to or from an instance of
--   <a>Enum</a>.
--   
--   <pre>
--   &gt;&gt;&gt; LT^.from enum
--   0
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; 97^.enum :: Char
--   'a'
--   </pre>
--   
--   Note: this is only an isomorphism from the numeric range actually used
--   and it is a bit of a pleasant fiction, since there are questionable
--   <a>Enum</a> instances for <a>Double</a>, and <a>Float</a> that exist
--   solely for <tt>[1.0 .. 4.0]</tt> sugar and the instances for those and
--   <a>Integer</a> don't cover all values in their range.
enum :: Enum a => Iso' Int a

-- | The canonical isomorphism for currying and uncurrying a function.
--   
--   <pre>
--   <a>curried</a> = <a>iso</a> <a>curry</a> <a>uncurry</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (fst^.curried) 3 4
--   3
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; view curried fst 3 4
--   3
--   </pre>
curried :: Iso ((a, b) -> c) ((d, e) -> f) (a -> b -> c) (d -> e -> f)

-- | The canonical isomorphism for uncurrying and currying a function.
--   
--   <pre>
--   <a>uncurried</a> = <a>iso</a> <a>uncurry</a> <a>curry</a>
--   </pre>
--   
--   <pre>
--   <a>uncurried</a> = <a>from</a> <a>curried</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ((+)^.uncurried) (1,2)
--   3
--   </pre>
uncurried :: Iso (a -> b -> c) (d -> e -> f) ((a, b) -> c) ((d, e) -> f)

-- | The isomorphism for flipping a function.
--   
--   <pre>
--   &gt;&gt;&gt; ((,)^.flipped) 1 2
--   (2,1)
--   </pre>
flipped :: Iso (a -> b -> c) (a' -> b' -> c') (b -> a -> c) (b' -> a' -> c')

-- | This class provides for symmetric bifunctors.
class Bifunctor p => Swapped p
swapped :: Swapped p => Iso (p a b) (p c d) (p b a) (p d c)

-- | Ad hoc conversion between "strict" and "lazy" versions of a structure,
--   such as <a>Text</a> or <a>ByteString</a>.
class Strict s a | s -> a, a -> s
strict :: Strict s a => Iso' s a

-- | This class provides a generalized notion of list reversal extended to
--   other containers.
class Reversing t
reversing :: Reversing t => t -> t

-- | An <a>Iso</a> between a list, <a>ByteString</a>, <a>Text</a> fragment,
--   etc. and its reversal.
--   
--   <pre>
--   &gt;&gt;&gt; "live" ^. reversed
--   "evil"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "live" &amp; reversed %~ ('d':)
--   "lived"
--   </pre>
reversed :: Reversing a => Iso' a a

-- | Given a function that is its own inverse, this gives you an <a>Iso</a>
--   using it in both directions.
--   
--   <pre>
--   <a>involuted</a> ≡ <a>join</a> <a>iso</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "live" ^. involuted reverse
--   "evil"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "live" &amp; involuted reverse %~ ('d':)
--   "lived"
--   </pre>
involuted :: (a -> a) -> Iso' a a

-- | This isomorphism can be used to inspect a <a>Traversal</a> to see how
--   it associates the structure and it can also be used to bake the
--   <a>Traversal</a> into a <a>Magma</a> so that you can traverse over it
--   multiple times.
magma :: LensLike (Mafic a b) s t a b -> Iso s u (Magma Int t b a) (Magma j u c c)

-- | This isomorphism can be used to inspect an <a>IndexedTraversal</a> to
--   see how it associates the structure and it can also be used to bake
--   the <a>IndexedTraversal</a> into a <a>Magma</a> so that you can
--   traverse over it multiple times with access to the original indices.
imagma :: Overloading (Indexed i) (->) (Molten i a b) s t a b -> Iso s t' (Magma i t b a) (Magma j t' c c)

-- | This provides a way to peek at the internal structure of a
--   <a>Traversal</a> or <a>IndexedTraversal</a>
data Magma i t b a

-- | Lift an <a>Iso</a> into a <a>Contravariant</a> functor.
--   
--   <pre>
--   contramapping :: <a>Contravariant</a> f =&gt; <a>Iso</a> s t a b -&gt; <a>Iso</a> (f a) (f b) (f s) (f t)
--   contramapping :: <a>Contravariant</a> f =&gt; <a>Iso'</a> s a -&gt; <a>Iso'</a> (f a) (f s)
--   </pre>
contramapping :: Contravariant f => AnIso s t a b -> Iso (f a) (f b) (f s) (f t)

-- | Formally, the class <a>Profunctor</a> represents a profunctor from
--   <tt>Hask</tt> -&gt; <tt>Hask</tt>.
--   
--   Intuitively it is a bifunctor where the first argument is
--   contravariant and the second argument is covariant.
--   
--   You can define a <a>Profunctor</a> by either defining <a>dimap</a> or
--   by defining both <a>lmap</a> and <a>rmap</a>.
--   
--   If you supply <a>dimap</a>, you should ensure that:
--   
--   <pre>
--   <a>dimap</a> <a>id</a> <a>id</a> ≡ <a>id</a>
--   </pre>
--   
--   If you supply <a>lmap</a> and <a>rmap</a>, ensure:
--   
--   <pre>
--   <a>lmap</a> <a>id</a> ≡ <a>id</a>
--   <a>rmap</a> <a>id</a> ≡ <a>id</a>
--   </pre>
--   
--   If you supply both, you should also ensure:
--   
--   <pre>
--   <a>dimap</a> f g ≡ <a>lmap</a> f <a>.</a> <a>rmap</a> g
--   </pre>
--   
--   These ensure by parametricity:
--   
--   <pre>
--   <a>dimap</a> (f <a>.</a> g) (h <a>.</a> i) ≡ <a>dimap</a> g h <a>.</a> <a>dimap</a> f i
--   <a>lmap</a> (f <a>.</a> g) ≡ <a>lmap</a> g <a>.</a> <a>lmap</a> f
--   <a>rmap</a> (f <a>.</a> g) ≡ <a>rmap</a> f <a>.</a> <a>rmap</a> g
--   </pre>
class Profunctor (p :: * -> * -> *)
dimap :: Profunctor p => (a -> b) -> (c -> d) -> p b c -> p a d
lmap :: Profunctor p => (a -> b) -> p b c -> p a c
rmap :: Profunctor p => (b -> c) -> p a b -> p a c

-- | Lift two <a>Iso</a>s into both arguments of a <a>Profunctor</a>
--   simultaneously.
--   
--   <pre>
--   dimapping :: <a>Profunctor</a> p =&gt; <a>Iso</a> s t a b -&gt; <a>Iso</a> s' t' a' b' -&gt; <a>Iso</a> (p a s') (p b t') (p s a') (p t b')
--   dimapping :: <a>Profunctor</a> p =&gt; <a>Iso'</a> s a -&gt; <a>Iso'</a> s' a' -&gt; <a>Iso'</a> (p a s') (p s a')
--   </pre>
dimapping :: Profunctor p => AnIso s t a b -> AnIso s' t' a' b' -> Iso (p a s') (p b t') (p s a') (p t b')

-- | Lift an <a>Iso</a> contravariantly into the left argument of a
--   <a>Profunctor</a>.
--   
--   <pre>
--   lmapping :: <a>Profunctor</a> p =&gt; <a>Iso</a> s t a b -&gt; <a>Iso</a> (p a x) (p b y) (p s x) (p t y)
--   lmapping :: <a>Profunctor</a> p =&gt; <a>Iso'</a> s a -&gt; <a>Iso'</a> (p a x) (p s x)
--   </pre>
lmapping :: Profunctor p => AnIso s t a b -> Iso (p a x) (p b y) (p s x) (p t y)

-- | Lift an <a>Iso</a> covariantly into the right argument of a
--   <a>Profunctor</a>.
--   
--   <pre>
--   rmapping :: <a>Profunctor</a> p =&gt; <a>Iso</a> s t a b -&gt; <a>Iso</a> (p x s) (p y t) (p x a) (p y b)
--   rmapping :: <a>Profunctor</a> p =&gt; <a>Iso'</a> s a -&gt; <a>Iso'</a> (p x s) (p x a)
--   </pre>
rmapping :: Profunctor p => AnIso s t a b -> Iso (p x s) (p y t) (p x a) (p y b)
instance Strict (RWST r w s m a) (RWST r w s m a)
instance Strict (WriterT w m a) (WriterT w m a)
instance Strict (StateT s m a) (StateT s m a)
instance Strict Text Text
instance Strict ByteString ByteString
instance Swapped Either
instance Swapped (,)


-- | A <tt><a>Getter</a> s a</tt> is just any function <tt>(s -&gt;
--   a)</tt>, which we've flipped into continuation passing style, <tt>(a
--   -&gt; r) -&gt; s -&gt; r</tt> and decorated with <a>Accessor</a> to
--   obtain:
--   
--   <pre>
--   type <a>Getting</a> r s t a b = (a -&gt; <a>Accessor</a> r b) -&gt; s -&gt; <a>Accessor</a> r t
--   </pre>
--   
--   If we restrict access to knowledge about the type <tt>r</tt> and can
--   work for any b and t, we could get:
--   
--   <pre>
--   type <a>Getter</a> s a = forall r. <a>Getting</a> r s s a a
--   </pre>
--   
--   But we actually hide the use of <a>Accessor</a> behind a class
--   <a>Gettable</a> to error messages from type class resolution rather
--   than at unification time, where they are much uglier.
--   
--   <pre>
--   type <a>Getter</a> s a = forall f. <a>Gettable</a> f =&gt; (a -&gt; f a) -&gt; s -&gt; f s
--   </pre>
--   
--   Everything you can do with a function, you can do with a
--   <a>Getter</a>, but note that because of the continuation passing style
--   (<a>.</a>) composes them in the opposite order.
--   
--   Since it is only a function, every <a>Getter</a> obviously only
--   retrieves a single value for a given input.
module Control.Lens.Getter

-- | A <a>Getter</a> describes how to retrieve a single value in a way that
--   can be composed with other <a>LensLike</a> constructions.
--   
--   Unlike a <a>Lens</a> a <a>Getter</a> is read-only. Since a
--   <a>Getter</a> cannot be used to write back there are no <a>Lens</a>
--   laws that can be applied to it. In fact, it is isomorphic to an
--   arbitrary function from <tt>(a -&gt; s)</tt>.
--   
--   Moreover, a <a>Getter</a> can be used directly as a <a>Fold</a>, since
--   it just ignores the <a>Applicative</a>.
type Getter s a = forall f. (Contravariant f, Functor f) => (a -> f a) -> s -> f s

-- | Every <a>IndexedGetter</a> is a valid <a>IndexedFold</a> and can be
--   used for <a>Getting</a> like a <a>Getter</a>.
type IndexedGetter i s a = forall p f. (Indexable i p, Contravariant f, Functor f) => p a (f a) -> s -> f s

-- | When you see this in a type signature it indicates that you can pass
--   the function a <a>Lens</a>, <a>Getter</a>, <a>Traversal</a>,
--   <a>Fold</a>, <a>Prism</a>, <a>Iso</a>, or one of the indexed variants,
--   and it will just "do the right thing".
--   
--   Most <a>Getter</a> combinators are able to be used with both a
--   <a>Getter</a> or a <a>Fold</a> in limited situations, to do so, they
--   need to be monomorphic in what we are going to extract with
--   <a>Const</a>. To be compatible with <a>Lens</a>, <a>Traversal</a> and
--   <a>Iso</a> we also restricted choices of the irrelevant <tt>t</tt> and
--   <tt>b</tt> parameters.
--   
--   If a function accepts a <tt><a>Getting</a> r s t a b</tt>, then when
--   <tt>r</tt> is a <a>Monoid</a>, then you can pass a <a>Fold</a> (or
--   <a>Traversal</a>), otherwise you can only pass this a <a>Getter</a> or
--   <a>Lens</a>.
type Getting r s a = (a -> Accessor r a) -> s -> Accessor r s

-- | Used to consume an <a>IndexedFold</a>.
type IndexedGetting i m s a = Indexed i a (Accessor m a) -> s -> Accessor m s

-- | This is a convenient alias used when consuming (indexed) getters and
--   (indexed) folds in a highly general fashion.
type Accessing p m s a = p a (Accessor m a) -> s -> Accessor m s

-- | Build a <a>Getter</a> from an arbitrary Haskell function.
--   
--   <pre>
--   <a>to</a> f <a>.</a> <a>to</a> g ≡ <a>to</a> (g <a>.</a> f)
--   </pre>
--   
--   <pre>
--   a <a>^.</a> <a>to</a> f ≡ f a
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; a ^.to f
--   f a
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world")^.to snd
--   "world"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; 5^.to succ
--   6
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (0, -5)^._2.to abs
--   5
--   </pre>
to :: (s -> a) -> IndexPreservingGetter s a

-- | View the value pointed to by a <a>Getter</a> or <a>Lens</a> or the
--   result of folding over all the results of a <a>Fold</a> or
--   <a>Traversal</a> that points at a monoidal values.
--   
--   This is the same operation as <a>view</a> with the arguments flipped.
--   
--   The fixity and semantics are such that subsequent field accesses can
--   be performed with (<a>.</a>).
--   
--   <pre>
--   &gt;&gt;&gt; (a,b)^._2
--   b
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world")^._2
--   "world"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; import Data.Complex
--   
--   &gt;&gt;&gt; ((0, 1 :+ 2), 3)^._1._2.to magnitude
--   2.23606797749979
--   </pre>
--   
--   <pre>
--   (<a>^.</a>) ::             s -&gt; <a>Getter</a> s a     -&gt; a
--   (<a>^.</a>) :: <a>Monoid</a> m =&gt; s -&gt; <a>Fold</a> s m       -&gt; m
--   (<a>^.</a>) ::             s -&gt; <a>Iso'</a> s a       -&gt; a
--   (<a>^.</a>) ::             s -&gt; <a>Lens'</a> s a      -&gt; a
--   (<a>^.</a>) :: <a>Monoid</a> m =&gt; s -&gt; <a>Traversal'</a> s m -&gt; m
--   </pre>
(^.) :: s -> Getting a s a -> a

-- | View the value pointed to by a <a>Getter</a>, <a>Iso</a> or
--   <a>Lens</a> or the result of folding over all the results of a
--   <a>Fold</a> or <a>Traversal</a> that points at a monoidal value.
--   
--   <pre>
--   <a>view</a> <a>.</a> <a>to</a> ≡ <a>id</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; view (to f) a
--   f a
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; view _2 (1,"hello")
--   "hello"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; view (to succ) 5
--   6
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; view (_2._1) ("hello",("world","!!!"))
--   "world"
--   </pre>
--   
--   As <a>view</a> is commonly used to access the target of a
--   <a>Getter</a> or obtain a monoidal summary of the targets of a
--   <a>Fold</a>, It may be useful to think of it as having one of these
--   more restricted signatures:
--   
--   <pre>
--   <a>view</a> ::             <a>Getter</a> s a     -&gt; s -&gt; a
--   <a>view</a> :: <a>Monoid</a> m =&gt; <a>Fold</a> s m       -&gt; s -&gt; m
--   <a>view</a> ::             <a>Iso'</a> s a       -&gt; s -&gt; a
--   <a>view</a> ::             <a>Lens'</a> s a      -&gt; s -&gt; a
--   <a>view</a> :: <a>Monoid</a> m =&gt; <a>Traversal'</a> s m -&gt; s -&gt; m
--   </pre>
--   
--   In a more general setting, such as when working with a <a>Monad</a>
--   transformer stack you can use:
--   
--   <pre>
--   <a>view</a> :: <a>MonadReader</a> s m             =&gt; <a>Getter</a> s a     -&gt; m a
--   <a>view</a> :: (<a>MonadReader</a> s m, <a>Monoid</a> a) =&gt; <a>Fold</a> s a       -&gt; m a
--   <a>view</a> :: <a>MonadReader</a> s m             =&gt; <a>Iso'</a> s a       -&gt; m a
--   <a>view</a> :: <a>MonadReader</a> s m             =&gt; <a>Lens'</a> s a      -&gt; m a
--   <a>view</a> :: (<a>MonadReader</a> s m, <a>Monoid</a> a) =&gt; <a>Traversal'</a> s a -&gt; m a
--   </pre>
view :: MonadReader s m => Getting a s a -> m a

-- | View a function of the value pointed to by a <a>Getter</a> or
--   <a>Lens</a> or the result of folding over the result of mapping the
--   targets of a <a>Fold</a> or <a>Traversal</a>.
--   
--   <pre>
--   <a>views</a> l f ≡ <a>view</a> (l <a>.</a> <a>to</a> f)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; views (to f) g a
--   g (f a)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; views _2 length (1,"hello")
--   5
--   </pre>
--   
--   As <a>views</a> is commonly used to access the target of a
--   <a>Getter</a> or obtain a monoidal summary of the targets of a
--   <a>Fold</a>, It may be useful to think of it as having one of these
--   more restricted signatures:
--   
--   <pre>
--   <a>views</a> ::             <a>Getter</a> s a     -&gt; (a -&gt; r) -&gt; s -&gt; r
--   <a>views</a> :: <a>Monoid</a> m =&gt; <a>Fold</a> s a       -&gt; (a -&gt; m) -&gt; s -&gt; m
--   <a>views</a> ::             <a>Iso'</a> s a       -&gt; (a -&gt; r) -&gt; s -&gt; r
--   <a>views</a> ::             <a>Lens'</a> s a      -&gt; (a -&gt; r) -&gt; s -&gt; r
--   <a>views</a> :: <a>Monoid</a> m =&gt; <a>Traversal'</a> s a -&gt; (a -&gt; m) -&gt; s -&gt; m
--   </pre>
--   
--   In a more general setting, such as when working with a <a>Monad</a>
--   transformer stack you can use:
--   
--   <pre>
--   <a>view</a> :: <a>MonadReader</a> s m             =&gt; <a>Getter</a> s a     -&gt; m a
--   <a>view</a> :: (<a>MonadReader</a> s m, <a>Monoid</a> a) =&gt; <a>Fold</a> s a       -&gt; m a
--   <a>view</a> :: <a>MonadReader</a> s m             =&gt; <a>Iso'</a> s a       -&gt; m a
--   <a>view</a> :: <a>MonadReader</a> s m             =&gt; <a>Lens'</a> s a      -&gt; m a
--   <a>view</a> :: (<a>MonadReader</a> s m, <a>Monoid</a> a) =&gt; <a>Traversal'</a> s a -&gt; m a
--   </pre>
--   
--   <pre>
--   <a>views</a> :: <a>MonadReader</a> s m =&gt; <a>Getting</a> r s a -&gt; (a -&gt; r) -&gt; m r
--   </pre>
views :: (Profunctor p, MonadReader s m) => Overloading p (->) (Accessor r) s s a a -> p a r -> m r

-- | Use the target of a <a>Lens</a>, <a>Iso</a>, or <a>Getter</a> in the
--   current state, or use a summary of a <a>Fold</a> or <a>Traversal</a>
--   that points to a monoidal value.
--   
--   <pre>
--   &gt;&gt;&gt; evalState (use _1) (a,b)
--   a
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; evalState (use _1) ("hello","world")
--   "hello"
--   </pre>
--   
--   <pre>
--   <a>use</a> :: <a>MonadState</a> s m             =&gt; <a>Getter</a> s a     -&gt; m a
--   <a>use</a> :: (<a>MonadState</a> s m, <a>Monoid</a> r) =&gt; <a>Fold</a> s r       -&gt; m r
--   <a>use</a> :: <a>MonadState</a> s m             =&gt; <a>Iso'</a> s a       -&gt; m a
--   <a>use</a> :: <a>MonadState</a> s m             =&gt; <a>Lens'</a> s a      -&gt; m a
--   <a>use</a> :: (<a>MonadState</a> s m, <a>Monoid</a> r) =&gt; <a>Traversal'</a> s r -&gt; m r
--   </pre>
use :: MonadState s m => Getting a s a -> m a

-- | Use the target of a <a>Lens</a>, <a>Iso</a> or <a>Getter</a> in the
--   current state, or use a summary of a <a>Fold</a> or <a>Traversal</a>
--   that points to a monoidal value.
--   
--   <pre>
--   &gt;&gt;&gt; evalState (uses _1 length) ("hello","world")
--   5
--   </pre>
--   
--   <pre>
--   <a>uses</a> :: <a>MonadState</a> s m             =&gt; <a>Getter</a> s a     -&gt; (a -&gt; r) -&gt; m r
--   <a>uses</a> :: (<a>MonadState</a> s m, <a>Monoid</a> r) =&gt; <a>Fold</a> s a       -&gt; (a -&gt; r) -&gt; m r
--   <a>uses</a> :: <a>MonadState</a> s m             =&gt; <a>Lens'</a> s a      -&gt; (a -&gt; r) -&gt; m r
--   <a>uses</a> :: <a>MonadState</a> s m             =&gt; <a>Iso'</a> s a       -&gt; (a -&gt; r) -&gt; m r
--   <a>uses</a> :: (<a>MonadState</a> s m, <a>Monoid</a> r) =&gt; <a>Traversal'</a> s a -&gt; (a -&gt; r) -&gt; m r
--   </pre>
--   
--   <pre>
--   <a>uses</a> :: <a>MonadState</a> s m =&gt; <a>Getting</a> r s t a b -&gt; (a -&gt; r) -&gt; m r
--   </pre>
uses :: (Profunctor p, MonadState s m) => Overloading p (->) (Accessor r) s s a a -> p a r -> m r

-- | This is a generalized form of <a>listen</a> that only extracts the
--   portion of the log that is focused on by a <a>Getter</a>. If given a
--   <a>Fold</a> or a <a>Traversal</a> then a monoidal summary of the parts
--   of the log that are visited will be returned.
--   
--   <pre>
--   <a>listening</a> :: <a>MonadWriter</a> w m             =&gt; <a>Getter</a> w u     -&gt; m a -&gt; m (a, u)
--   <a>listening</a> :: <a>MonadWriter</a> w m             =&gt; <a>Lens'</a> w u      -&gt; m a -&gt; m (a, u)
--   <a>listening</a> :: <a>MonadWriter</a> w m             =&gt; <a>Iso'</a> w u       -&gt; m a -&gt; m (a, u)
--   <a>listening</a> :: (<a>MonadWriter</a> w m, <a>Monoid</a> u) =&gt; <a>Fold</a> w u       -&gt; m a -&gt; m (a, u)
--   <a>listening</a> :: (<a>MonadWriter</a> w m, <a>Monoid</a> u) =&gt; <a>Traversal'</a> w u -&gt; m a -&gt; m (a, u)
--   <a>listening</a> :: (<a>MonadWriter</a> w m, <a>Monoid</a> u) =&gt; <a>Prism'</a> w u     -&gt; m a -&gt; m (a, u)
--   </pre>
listening :: MonadWriter w m => Getting u w u -> m a -> m (a, u)

-- | This is a generalized form of <a>listen</a> that only extracts the
--   portion of the log that is focused on by a <a>Getter</a>. If given a
--   <a>Fold</a> or a <a>Traversal</a> then a monoidal summary of the parts
--   of the log that are visited will be returned.
--   
--   <pre>
--   <a>listenings</a> :: <a>MonadWriter</a> w m             =&gt; <a>Getter</a> w u     -&gt; (u -&gt; v) -&gt; m a -&gt; m (a, v)
--   <a>listenings</a> :: <a>MonadWriter</a> w m             =&gt; <a>Lens'</a> w u      -&gt; (u -&gt; v) -&gt; m a -&gt; m (a, v)
--   <a>listenings</a> :: <a>MonadWriter</a> w m             =&gt; <a>Iso'</a> w u       -&gt; (u -&gt; v) -&gt; m a -&gt; m (a, v)
--   <a>listenings</a> :: (<a>MonadWriter</a> w m, <a>Monoid</a> v) =&gt; <a>Fold</a> w u       -&gt; (u -&gt; v) -&gt; m a -&gt; m (a, v)
--   <a>listenings</a> :: (<a>MonadWriter</a> w m, <a>Monoid</a> v) =&gt; <a>Traversal'</a> w u -&gt; (u -&gt; v) -&gt; m a -&gt; m (a, v)
--   <a>listenings</a> :: (<a>MonadWriter</a> w m, <a>Monoid</a> v) =&gt; <a>Prism'</a> w u     -&gt; (u -&gt; v) -&gt; m a -&gt; m (a, v)
--   </pre>
listenings :: MonadWriter w m => Getting v w u -> (u -> v) -> m a -> m (a, v)

-- | View the value pointed to by a <a>Getter</a> or <a>Lens</a>.
--   
--   This is the same operation as <a>iview</a> with the arguments flipped.
--   
--   The fixity and semantics are such that subsequent field accesses can
--   be performed with (<a>.</a>).
--   
--   <pre>
--   &gt;&gt;&gt; (a,b,c,d)^@._2
--   (1,b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world","!!!")^@._2
--   (1,"world")
--   </pre>
--   
--   <pre>
--   (<a>^@.</a>) :: s -&gt; <a>IndexedGetter</a> i s a -&gt; (i, a)
--   (<a>^@.</a>) :: s -&gt; <a>IndexedLens'</a> i s a  -&gt; (i, a)
--   </pre>
--   
--   The result probably doesn't have much meaning when applied to an
--   <a>IndexedFold</a>.
(^@.) :: s -> IndexedGetting i (i, a) s a -> (i, a)

-- | View the index and value of an <a>IndexedGetter</a> into the current
--   environment as a pair.
--   
--   When applied to an <a>IndexedFold</a> the result will most likely be a
--   nonsensical monoidal summary of the indices tupled with a monoidal
--   summary of the values and probably not whatever it is you wanted.
iview :: MonadReader s m => IndexedGetting i (i, a) s a -> m (i, a)

-- | View a function of the index and value of an <a>IndexedGetter</a> into
--   the current environment.
--   
--   When applied to an <a>IndexedFold</a> the result will be a monoidal
--   summary instead of a single answer.
--   
--   <pre>
--   <a>iviews</a> ≡ <a>ifoldMapOf</a>
--   </pre>
iviews :: MonadReader s m => IndexedGetting i r s a -> (i -> a -> r) -> m r

-- | Use the index and value of an <a>IndexedGetter</a> into the current
--   state as a pair.
--   
--   When applied to an <a>IndexedFold</a> the result will most likely be a
--   nonsensical monoidal summary of the indices tupled with a monoidal
--   summary of the values and probably not whatever it is you wanted.
iuse :: MonadState s m => IndexedGetting i (i, a) s a -> m (i, a)

-- | Use a function of the index and value of an <a>IndexedGetter</a> into
--   the current state.
--   
--   When applied to an <a>IndexedFold</a> the result will be a monoidal
--   summary instead of a single answer.
iuses :: MonadState s m => IndexedGetting i r s a -> (i -> a -> r) -> m r

-- | This is a generalized form of <a>listen</a> that only extracts the
--   portion of the log that is focused on by a <a>Getter</a>. If given a
--   <a>Fold</a> or a <a>Traversal</a> then a monoidal summary of the parts
--   of the log that are visited will be returned.
--   
--   <pre>
--   <a>ilistening</a> :: <a>MonadWriter</a> w m             =&gt; <a>IndexedGetter</a> i w u     -&gt; m a -&gt; m (a, (i, u))
--   <a>ilistening</a> :: <a>MonadWriter</a> w m             =&gt; <a>IndexedLens'</a> i w u      -&gt; m a -&gt; m (a, (i, u))
--   <a>ilistening</a> :: (<a>MonadWriter</a> w m, <a>Monoid</a> u) =&gt; <a>IndexedFold</a> i w u       -&gt; m a -&gt; m (a, (i, u))
--   <a>ilistening</a> :: (<a>MonadWriter</a> w m, <a>Monoid</a> u) =&gt; <a>IndexedTraversal'</a> i w u -&gt; m a -&gt; m (a, (i, u))
--   </pre>
ilistening :: MonadWriter w m => IndexedGetting i (i, u) w u -> m a -> m (a, (i, u))

-- | This is a generalized form of <a>listen</a> that only extracts the
--   portion of the log that is focused on by a <a>Getter</a>. If given a
--   <a>Fold</a> or a <a>Traversal</a> then a monoidal summary of the parts
--   of the log that are visited will be returned.
--   
--   <pre>
--   <a>ilistenings</a> :: <a>MonadWriter</a> w m             =&gt; <a>IndexedGetter</a> w u     -&gt; (i -&gt; u -&gt; v) -&gt; m a -&gt; m (a, v)
--   <a>ilistenings</a> :: <a>MonadWriter</a> w m             =&gt; <a>IndexedLens'</a> w u      -&gt; (i -&gt; u -&gt; v) -&gt; m a -&gt; m (a, v)
--   <a>ilistenings</a> :: (<a>MonadWriter</a> w m, <a>Monoid</a> v) =&gt; <a>IndexedFold</a> w u       -&gt; (i -&gt; u -&gt; v) -&gt; m a -&gt; m (a, v)
--   <a>ilistenings</a> :: (<a>MonadWriter</a> w m, <a>Monoid</a> v) =&gt; <a>IndexedTraversal'</a> w u -&gt; (i -&gt; u -&gt; v) -&gt; m a -&gt; m (a, v)
--   </pre>
ilistenings :: MonadWriter w m => IndexedGetting i v w u -> (i -> u -> v) -> m a -> m (a, v)

-- | Any instance should be subject to the following laws:
--   
--   <pre>
--   contramap id = id
--   contramap f . contramap g = contramap (g . f)
--   </pre>
--   
--   Note, that the second law follows from the free theorem of the type of
--   <a>contramap</a> and the first law, so you need only check that the
--   former condition holds.
class Contravariant (f :: * -> *)
contramap :: Contravariant f => (a -> b) -> f b -> f a

-- | This Generalizes <a>Const</a> so we can apply simple
--   <a>Applicative</a> transformations to it and so we can get nicer error
--   messages.
--   
--   A <a>Functor</a> you can <a>coerce</a> ignores its argument, which it
--   carries solely as a phantom type parameter.
--   
--   By the <a>Functor</a> and <a>Contravariant</a> laws, an instance of
--   <a>Gettable</a> will necessarily satisfy:
--   
--   <pre>
--   <a>id</a> = <a>fmap</a> f = <a>coerce</a> = <a>contramap</a> g
--   </pre>
coerce :: (Contravariant f, Functor f) => f a -> f b

-- | Coerce a <a>Gettable</a> <a>LensLike</a> to a <a>Simple</a>
--   <a>LensLike</a>. This is useful when using a <a>Traversal</a> that is
--   not simple as a <a>Getter</a> or a <a>Fold</a>.
coerced :: (Functor f, Contravariant f) => LensLike f s t a b -> LensLike' f s a

-- | Used instead of <a>Const</a> to report
--   
--   <pre>
--   No instance for (<a>Settable</a> <a>Accessor</a>)
--   </pre>
--   
--   when the user attempts to misuse a <a>Setter</a> as a <a>Getter</a>,
--   rather than a monolithic unification error.
newtype Accessor r a
Accessor :: r -> Accessor r a
runAccessor :: Accessor r a -> r

-- | This class is provided mostly for backwards compatibility with lens
--   3.8, but it can also shorten type signatures.
class (Contravariant f, Functor f) => Gettable f


module Data.Set.Lens

-- | This <a>Setter</a> can be used to change the type of a <a>Set</a> by
--   mapping the elements to new values.
--   
--   Sadly, you can't create a valid <a>Traversal</a> for a <a>Set</a>, but
--   you can manipulate it by reading using <a>folded</a> and reindexing it
--   via <a>setmapped</a>.
--   
--   <pre>
--   &gt;&gt;&gt; over setmapped (+1) (fromList [1,2,3,4])
--   fromList [2,3,4,5]
--   </pre>
setmapped :: (Ord i, Ord j) => IndexPreservingSetter (Set i) (Set j) i j

-- | Construct a set from a <a>Getter</a>, <a>Fold</a>, <a>Traversal</a>,
--   <a>Lens</a> or <a>Iso</a>.
--   
--   <pre>
--   &gt;&gt;&gt; setOf folded ["hello","world"]
--   fromList ["hello","world"]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; setOf (folded._2) [("hello",1),("world",2),("!!!",3)]
--   fromList [1,2,3]
--   </pre>
--   
--   <pre>
--   <a>setOf</a> ::          <a>Getter</a> s a     -&gt; s -&gt; <a>Set</a> a
--   <a>setOf</a> :: <a>Ord</a> a =&gt; <a>Fold</a> s a       -&gt; s -&gt; <a>Set</a> a
--   <a>setOf</a> ::          <a>Iso'</a> s a       -&gt; s -&gt; <a>Set</a> a
--   <a>setOf</a> ::          <a>Lens'</a> s a      -&gt; s -&gt; <a>Set</a> a
--   <a>setOf</a> :: <a>Ord</a> a =&gt; <a>Traversal'</a> s a -&gt; s -&gt; <a>Set</a> a
--   </pre>
setOf :: Getting (Set a) s a -> s -> Set a


-- | A <a>Review</a> is a type-restricted form of a <a>Prism</a> that can
--   only be used for writing back via <a>re</a>, <a>review</a>,
--   <a>reuse</a>.
module Control.Lens.Review

-- | This is a limited form of a <a>Prism</a> that can only be used for
--   <a>re</a> operations.
--   
--   Like with a <a>Getter</a>, there are no laws to state for a
--   <a>Review</a>.
--   
--   You can generate a <a>Review</a> by using <a>unto</a>. You can also
--   use any <a>Prism</a> or <a>Iso</a> directly as a <a>Review</a>.
type Review s t a b = forall p f. (Profunctor p, Bifunctor p, Settable f) => Overloaded p f s t a b

-- | A <a>Simple</a> <a>Review</a>
type Review' t b = Review t t b b

-- | If you see this in a signature for a function, the function is
--   expecting a <a>Review</a> (in practice, this usually means a
--   <a>Prism</a>).
type AReview s t a b = Overloaded Reviewed Identity s t a b

-- | A <a>Simple</a> <a>AReview</a>
type AReview' t b = AReview t t b b

-- | An analogue of <a>to</a> for <a>review</a>.
--   
--   <pre>
--   <a>unto</a> :: (b -&gt; t) -&gt; <a>Review'</a> t b
--   </pre>
unto :: (Profunctor p, Bifunctor p, Functor f) => (b -> t) -> Overloaded p f s t a b

-- | Turn a <a>Prism</a> or <a>Iso</a> around to build a <a>Getter</a>.
--   
--   If you have an <a>Iso</a>, <a>from</a> is a more powerful version of
--   this function that will return an <a>Iso</a> instead of a mere
--   <a>Getter</a>.
--   
--   <pre>
--   &gt;&gt;&gt; 5 ^.re _Left
--   Left 5
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; 6 ^.re (_Left.unto succ)
--   Left 7
--   </pre>
--   
--   <pre>
--   <a>review</a>  ≡ <a>view</a>  <a>.</a> <a>re</a>
--   <a>reviews</a> ≡ <a>views</a> <a>.</a> <a>re</a>
--   <a>reuse</a>   ≡ <a>use</a>   <a>.</a> <a>re</a>
--   <a>reuses</a>  ≡ <a>uses</a>  <a>.</a> <a>re</a>
--   </pre>
--   
--   <pre>
--   <a>re</a> :: <a>Prism</a> s t a b -&gt; <a>Getter</a> b t
--   <a>re</a> :: <a>Iso</a> s t a b   -&gt; <a>Getter</a> b t
--   </pre>
re :: AReview s t a b -> Getter b t

-- | This can be used to turn an <a>Iso</a> or <a>Prism</a> around and
--   <a>view</a> a value (or the current environment) through it the other
--   way.
--   
--   <pre>
--   <a>review</a> ≡ <a>view</a> <a>.</a> <a>re</a>
--   <a>review</a> . <a>unto</a> ≡ <a>id</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; review _Left "mustard"
--   Left "mustard"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; review (unto succ) 5
--   6
--   </pre>
--   
--   Usually <a>review</a> is used in the <tt>(-&gt;)</tt> <a>Monad</a>
--   with a <a>Prism</a> or <a>Iso</a>, in which case it may be useful to
--   think of it as having one of these more restricted type signatures:
--   
--   <pre>
--   <a>review</a> :: <a>Iso'</a> s a   -&gt; a -&gt; s
--   <a>review</a> :: <a>Prism'</a> s a -&gt; a -&gt; s
--   </pre>
--   
--   However, when working with a <a>Monad</a> transformer stack, it is
--   sometimes useful to be able to <a>review</a> the current environment,
--   in which case one of these more slightly more liberal type signatures
--   may be beneficial to think of it as having:
--   
--   <pre>
--   <a>review</a> :: <a>MonadReader</a> a m =&gt; <a>Iso'</a> s a   -&gt; m s
--   <a>review</a> :: <a>MonadReader</a> a m =&gt; <a>Prism'</a> s a -&gt; m s
--   </pre>
review :: MonadReader b m => AReview s t a b -> m t

-- | This can be used to turn an <a>Iso</a> or <a>Prism</a> around and
--   <a>view</a> a value (or the current environment) through it the other
--   way, applying a function.
--   
--   <pre>
--   <a>reviews</a> ≡ <a>views</a> <a>.</a> <a>re</a>
--   <a>reviews</a> (<a>unto</a> f) g ≡ g <a>.</a> f
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; reviews _Left isRight "mustard"
--   False
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; reviews (unto succ) (*2) 3
--   8
--   </pre>
--   
--   Usually this function is used in the <tt>(-&gt;)</tt> <a>Monad</a>
--   with a <a>Prism</a> or <a>Iso</a>, in which case it may be useful to
--   think of it as having one of these more restricted type signatures:
--   
--   <pre>
--   <a>reviews</a> :: <a>Iso'</a> s a   -&gt; (s -&gt; r) -&gt; a -&gt; r
--   <a>reviews</a> :: <a>Prism'</a> s a -&gt; (s -&gt; r) -&gt; a -&gt; r
--   </pre>
--   
--   However, when working with a <a>Monad</a> transformer stack, it is
--   sometimes useful to be able to <a>review</a> the current environment,
--   in which case one of these more slightly more liberal type signatures
--   may be beneficial to think of it as having:
--   
--   <pre>
--   <a>reviews</a> :: <a>MonadReader</a> a m =&gt; <a>Iso'</a> s a   -&gt; (s -&gt; r) -&gt; m r
--   <a>reviews</a> :: <a>MonadReader</a> a m =&gt; <a>Prism'</a> s a -&gt; (s -&gt; r) -&gt; m r
--   </pre>
reviews :: MonadReader b m => AReview s t a b -> (t -> r) -> m r

-- | This can be used to turn an <a>Iso</a> or <a>Prism</a> around and
--   <a>use</a> a value (or the current environment) through it the other
--   way.
--   
--   <pre>
--   <a>reuse</a> ≡ <a>use</a> <a>.</a> <a>re</a>
--   <a>reuse</a> <a>.</a> <a>unto</a> ≡ <a>gets</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; evalState (reuse _Left) 5
--   Left 5
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; evalState (reuse (unto succ)) 5
--   6
--   </pre>
--   
--   <pre>
--   <a>reuse</a> :: <a>MonadState</a> a m =&gt; <a>Prism'</a> s a -&gt; m s
--   <a>reuse</a> :: <a>MonadState</a> a m =&gt; <a>Iso'</a> s a   -&gt; m s
--   </pre>
reuse :: MonadState b m => AReview s t a b -> m t

-- | This can be used to turn an <a>Iso</a> or <a>Prism</a> around and
--   <a>use</a> the current state through it the other way, applying a
--   function.
--   
--   <pre>
--   <a>reuses</a> ≡ <a>uses</a> <a>.</a> <a>re</a>
--   <a>reuses</a> (<a>unto</a> f) g ≡ <a>gets</a> (g <a>.</a> f)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; evalState (reuses _Left isLeft) (5 :: Int)
--   True
--   </pre>
--   
--   <pre>
--   <a>reuses</a> :: <a>MonadState</a> a m =&gt; <a>Prism'</a> s a -&gt; (s -&gt; r) -&gt; m r
--   <a>reuses</a> :: <a>MonadState</a> a m =&gt; <a>Iso'</a> s a   -&gt; (s -&gt; r) -&gt; m r
--   </pre>
reuses :: MonadState b m => AReview s t a b -> (t -> r) -> m r

-- | An infix alias for <a>review</a>.
--   
--   <pre>
--   <a>unto</a> f # x ≡ f x
--   l # x ≡ x <a>^.</a> <a>re</a> l
--   </pre>
--   
--   This is commonly used when using a <a>Prism</a> as a smart
--   constructor.
--   
--   <pre>
--   &gt;&gt;&gt; _Left # 4
--   Left 4
--   </pre>
--   
--   But it can be used for any <a>Prism</a>
--   
--   <pre>
--   &gt;&gt;&gt; base 16 # 123
--   "7b"
--   </pre>
--   
--   <pre>
--   (#) :: <a>Iso'</a>      s a -&gt; a -&gt; s
--   (#) :: <a>Prism'</a>    s a -&gt; a -&gt; s
--   (#) :: <a>Review'</a>   s a -&gt; a -&gt; s
--   (#) :: <a>Equality'</a> s a -&gt; a -&gt; s
--   </pre>
(#) :: AReview s t a b -> b -> t

-- | Minimal definition either <a>bimap</a> or <a>first</a> and
--   <a>second</a>
--   
--   Formally, the class <a>Bifunctor</a> represents a bifunctor from
--   <tt>Hask</tt> -&gt; <tt>Hask</tt>.
--   
--   Intuitively it is a bifunctor where both the first and second
--   arguments are covariant.
--   
--   You can define a <a>Bifunctor</a> by either defining <a>bimap</a> or
--   by defining both <a>first</a> and <a>second</a>.
--   
--   If you supply <a>bimap</a>, you should ensure that:
--   
--   <pre>
--   <a>bimap</a> <a>id</a> <a>id</a> ≡ <a>id</a>
--   </pre>
--   
--   If you supply <a>first</a> and <a>second</a>, ensure:
--   
--   <pre>
--   <a>first</a> <a>id</a> ≡ <a>id</a>
--   <a>second</a> <a>id</a> ≡ <a>id</a>
--   </pre>
--   
--   If you supply both, you should also ensure:
--   
--   <pre>
--   <a>bimap</a> f g ≡ <a>first</a> f <a>.</a> <a>second</a> g
--   </pre>
--   
--   These ensure by parametricity:
--   
--   <pre>
--   <a>bimap</a>  (f <a>.</a> g) (h <a>.</a> i) ≡ <a>bimap</a> f h <a>.</a> <a>bimap</a> g i
--   <a>first</a>  (f <a>.</a> g) ≡ <a>first</a>  f <a>.</a> <a>first</a>  g
--   <a>second</a> (f <a>.</a> g) ≡ <a>second</a> f <a>.</a> <a>second</a> g
--   </pre>
class Bifunctor (p :: * -> * -> *)
bimap :: Bifunctor p => (a -> b) -> (c -> d) -> p a c -> p b d

-- | This is a profunctor used internally to implement <a>Review</a>
--   
--   It plays a role similar to that of <a>Accessor</a> or <a>Const</a> do
--   for <a>Control.Lens.Getter</a>
retagged :: (Profunctor p, Bifunctor p) => p a b -> p s b

-- | This class is provided mostly for backwards compatibility with lens
--   3.8, but it can also shorten type signatures.
class (Profunctor p, Bifunctor p) => Reviewable p


-- | The <a>Wrapped</a> class provides similar functionality as
--   <tt>Control.Newtype</tt>, from the <tt>newtype</tt> package, but in a
--   more convenient and efficient form.
--   
--   There are a few functions from <tt>newtype</tt> that are not provided
--   here, because they can be done with the <a>Iso</a> directly:
--   
--   <pre>
--   Control.Newtype.over <a>Sum</a> f ≡ <a>wrapping</a> <a>Sum</a> <a>%~</a> f
--   Control.Newtype.under <a>Sum</a> f ≡ <a>unwrapping</a> <a>Sum</a> <a>%~</a> f
--   Control.Newtype.overF <a>Sum</a> f ≡ <a>mapping</a> (<a>wrapping</a> <a>Sum</a>) <a>%~</a> f
--   Control.Newtype.underF <a>Sum</a> f ≡ <a>mapping</a> (<a>unwrapping</a> <a>Sum</a>) <a>%~</a> f
--   </pre>
--   
--   <a>under</a> can also be used with <a>wrapping</a> to provide the
--   equivalent of <tt>Control.Newtype.under</tt>. Also, most use cases
--   don't need full polymorphism, so only the single constructor
--   <a>wrapping</a> functions would be needed.
--   
--   These equivalences aren't 100% honest, because <tt>newtype</tt>'s
--   operators need to rely on two <tt>Newtype</tt> constraints. This means
--   that the wrapper used for the output is not necessarily the same as
--   the input.
module Control.Lens.Wrapped

-- | <a>Wrapped</a> provides isomorphisms to wrap and unwrap newtypes or
--   data types with one constructor.
class Wrapped s t a b | a -> s, b -> t, a t -> s, b s -> t
wrapped :: Wrapped s t a b => Iso s t a b

-- | This is a convenient alias for <tt><a>from</a> <a>wrapped</a></tt>.
--   
--   <pre>
--   &gt;&gt;&gt; Const "hello" &amp; unwrapped %~ length &amp; getConst
--   5
--   </pre>
unwrapped :: Wrapped t s b a => Iso a b s t

-- | A convenient type-restricted version of <a>wrapped</a> for aiding type
--   inference.
wrapped' :: Wrapped s s a a => Iso' s a

-- | A convenient type-restricted version of <a>unwrapped</a> for aiding
--   type inference.
unwrapped' :: Wrapped s s a a => Iso' a s

-- | This is a convenient version of <a>wrapped</a> with an argument that's
--   ignored.
--   
--   The argument is used to specify which newtype the user intends to wrap
--   by using the constructor for that newtype.
--   
--   The user supplied function is <i>ignored</i>, merely its type is used.
wrapping :: Wrapped s s a a => (s -> a) -> Iso s s a a

-- | This is a convenient version of <a>unwrapped</a> with an argument
--   that's ignored.
--   
--   The argument is used to specify which newtype the user intends to
--   <i>remove</i> by using the constructor for that newtype.
--   
--   The user supplied function is <i>ignored</i>, merely its type is used.
unwrapping :: Wrapped s s a a => (s -> a) -> Iso a a s s

-- | This is a convenient version of <a>wrapped</a> with two arguments that
--   are ignored.
--   
--   These arguments are used to which newtype the user intends to wrap and
--   should both be the same constructor. This redundancy is necessary in
--   order to find the full polymorphic isomorphism family.
--   
--   The user supplied functions are <i>ignored</i>, merely their types are
--   used.
wrappings :: Wrapped s t a b => (s -> a) -> (t -> b) -> Iso s t a b

-- | This is a convenient version of <a>unwrapped</a> with two arguments
--   that are ignored.
--   
--   These arguments are used to which newtype the user intends to remove
--   and should both be the same constructor. This redundancy is necessary
--   in order to find the full polymorphic isomorphism family.
--   
--   The user supplied functions are <i>ignored</i>, merely their types are
--   used.
unwrappings :: Wrapped t s b a => (s -> a) -> (t -> b) -> Iso a b s t

-- | Given the constructor for a <a>Wrapped</a> type, return a
--   deconstructor that is its inverse.
--   
--   Assuming the <a>Wrapped</a> instance is legal, these laws hold:
--   
--   <pre>
--   <a>op</a> f <a>.</a> f ≡ <a>id</a>
--   f <a>.</a> <a>op</a> f ≡ <a>id</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; op Identity (Identity 4)
--   4
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; op Const (Const "hello")
--   "hello"
--   </pre>
op :: Wrapped s s a a => (s -> a) -> a -> s

-- | This combinator is based on <tt>ala</tt> from Conor McBride's work on
--   Epigram.
--   
--   As with <a>wrapping</a>, the user supplied function for the newtype is
--   <i>ignored</i>.
--   
--   <pre>
--   &gt;&gt;&gt; ala Sum foldMap [1,2,3,4]
--   10
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ala All foldMap [True,True]
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ala All foldMap [True,False]
--   False
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ala Any foldMap [False,False]
--   False
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ala Any foldMap [True,False]
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ala Sum foldMap [1,2,3,4]
--   10
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ala Product foldMap [1,2,3,4]
--   24
--   </pre>
ala :: Wrapped s s a a => (s -> a) -> ((s -> a) -> e -> a) -> e -> s

-- | This combinator is based on <tt>ala'</tt> from Conor McBride's work on
--   Epigram.
--   
--   As with <a>wrapping</a>, the user supplied function for the newtype is
--   <i>ignored</i>.
--   
--   <pre>
--   &gt;&gt;&gt; alaf Sum foldMap length ["hello","world"]
--   10
--   </pre>
alaf :: Wrapped s s a a => (s -> a) -> ((r -> a) -> e -> a) -> (r -> s) -> e -> s
instance Wrapped String String ErrorCall ErrorCall
instance Wrapped String String RecUpdError RecUpdError
instance Wrapped String String RecSelError RecSelError
instance Wrapped String String RecConError RecConError
instance Wrapped String String PatternMatchFail PatternMatchFail
instance Wrapped String String NoMethodError NoMethodError
instance Wrapped String String AssertionFailed AssertionFailed
instance Wrapped a b (Tagged k s a) (Tagged k1 t b)
instance Wrapped (f (g a)) (f' (g' a')) (ComposeCF f g a) (ComposeFC f' g' a')
instance Wrapped (f (g a)) (f' (g' a')) (ComposeFC f g a) (ComposeFC f' g' a')
instance Wrapped (f (g a)) (f' (g' a')) (Compose f g a) (Compose f' g' a')
instance Wrapped (b -> a) (b' -> a') (Op a b) (Op a' b')
instance Wrapped (a -> a -> Bool) (a' -> a' -> Bool) (Equivalence a) (Equivalence a')
instance Wrapped (a -> a -> Ordering) (a' -> a' -> Ordering) (Comparison a) (Comparison a')
instance Wrapped (a -> Bool) (a' -> Bool) (Predicate a) (Predicate a')
instance Wrapped [a] [b] (Seq a) (Seq b)
instance (Ord a, Ord b) => Wrapped [a] [b] (Set a) (Set b)
instance (Ord k, Ord k') => Wrapped [(k, a)] [(k', b)] (Map k a) (Map k' b)
instance Wrapped [Int] [Int] IntSet IntSet
instance Wrapped [(Int, a)] [(Int, b)] (IntMap a) (IntMap b)
instance (Hashable a, Eq a, Hashable b, Eq b) => Wrapped [a] [b] (HashSet a) (HashSet b)
instance (Hashable k, Eq k, Hashable k', Eq k') => Wrapped [(k, a)] [(k', b)] (HashMap k a) (HashMap k' b)
instance Wrapped (w (m -> a)) (w' (m' -> a')) (TracedT m w a) (TracedT m' w' a')
instance Wrapped (Either (f a) (g a)) (Either (f' a') (g' a')) (Coproduct f g a) (Coproduct f' g' a')
instance Wrapped (m (a, w)) (m' (a', w')) (WriterT w m a) (WriterT w' m' a')
instance Wrapped (m (a, w)) (m' (a', w')) (WriterT w m a) (WriterT w' m' a')
instance Wrapped (s -> m (a, s)) (s' -> m' (a', s')) (StateT s m a) (StateT s' m' a')
instance Wrapped (s -> m (a, s)) (s' -> m' (a', s')) (StateT s m a) (StateT s' m' a')
instance Wrapped (r -> s -> m (a, s, w)) (r' -> s' -> m' (a', s', w')) (RWST r w s m a) (RWST r' w' s' m' a')
instance Wrapped (r -> s -> m (a, s, w)) (r' -> s' -> m' (a', s', w')) (RWST r w s m a) (RWST r' w' s' m' a')
instance Wrapped (f a) (f' a') (Reverse f a) (Reverse f' a')
instance Wrapped (r -> m a) (r' -> m' a') (ReaderT r m a) (ReaderT r' m' a')
instance Wrapped (m (Maybe a)) (m' (Maybe a')) (MaybeT m a) (MaybeT m' a')
instance Wrapped (m [a]) (m' [a']) (ListT m a) (ListT m' a')
instance Wrapped (m a) (m' a') (IdentityT m a) (IdentityT m' a')
instance Wrapped a a' (Identity a) (Identity a')
instance Wrapped (m (Either e a)) (m' (Either e' a')) (ErrorT e m a) (ErrorT e' m' a')
instance Wrapped ((a -> m r) -> m r) ((a' -> m' r') -> m' r') (ContT r m a) (ContT r' m' a')
instance Wrapped a a' (Constant a b) (Constant a' b')
instance Wrapped (f (g a)) (f' (g' a')) (Compose f g a) (Compose f' g' a')
instance Wrapped (f a) (f' a') (Backwards f a) (Backwards f' a')
instance Wrapped a b (Reviewed s a) (Reviewed t b)
instance (ArrowApply m, ArrowApply n) => Wrapped (m () a) (n () b) (ArrowMonad m a) (ArrowMonad n b)
instance Wrapped (Maybe a) (Maybe b) (Last a) (Last b)
instance Wrapped (Maybe a) (Maybe b) (First a) (First b)
instance Wrapped (a -> a) (b -> b) (Endo a) (Endo b)
instance Wrapped a b (Dual a) (Dual b)
instance Wrapped a b (Const a x) (Const b y)
instance Wrapped [a] [b] (ZipList a) (ZipList b)
instance Wrapped (a b c) (u v w) (WrappedArrow a b c) (WrappedArrow u v w)
instance Wrapped (m a) (n b) (WrappedMonad m a) (WrappedMonad n b)
instance Wrapped (a -> m b) (u -> n v) (Kleisli m a b) (Kleisli n u v)
instance Wrapped a b (Product a) (Product b)
instance Wrapped a b (Sum a) (Sum b)
instance Wrapped Bool Bool Any Any
instance Wrapped Bool Bool All All


module Control.Lens.Zoom

-- | This class allows us to use <a>magnify</a> part of the environment,
--   changing the environment supplied by many different <a>Monad</a>
--   transformers. Unlike <a>zoom</a> this can change the environment of a
--   deeply nested <a>Monad</a> transformer.
--   
--   Also, unlike <a>zoom</a>, this can be used with any valid
--   <a>Getter</a>, but cannot be used with a <a>Traversal</a> or
--   <a>Fold</a>.
class (Magnified m ~ Magnified n, MonadReader b m, MonadReader a n) => Magnify m n b a | m -> b, n -> a, m a -> n, n b -> m
magnify :: Magnify m n b a => LensLike' (Magnified m c) a b -> m c -> n c

-- | This class allows us to use <a>zoom</a> in, changing the <a>State</a>
--   supplied by many different <a>Monad</a> transformers, potentially
--   quite deep in a <a>Monad</a> transformer stack.
class (Zoomed m ~ Zoomed n, MonadState s m, MonadState t n) => Zoom m n s t | m -> s, n -> t, m t -> n, n s -> m
zoom :: Zoom m n s t => LensLike' (Zoomed m c) t s -> m c -> n c
instance Magnify m n b a => Magnify (IdentityT m) (IdentityT n) b a
instance (Monad m, Monoid w) => Magnify (RWST b w s m) (RWST a w s m) b a
instance (Monad m, Monoid w) => Magnify (RWST b w s m) (RWST a w s m) b a
instance Magnify ((->) b) ((->) a) b a
instance Monad m => Magnify (ReaderT b m) (ReaderT a m) b a
instance (Error e, Zoom m n s t) => Zoom (ErrorT e m) (ErrorT e n) s t
instance Zoom m n s t => Zoom (MaybeT m) (MaybeT n) s t
instance Zoom m n s t => Zoom (ListT m) (ListT n) s t
instance (Monoid w, Zoom m n s t) => Zoom (WriterT w m) (WriterT w n) s t
instance (Monoid w, Zoom m n s t) => Zoom (WriterT w m) (WriterT w n) s t
instance (Monoid w, Monad z) => Zoom (RWST r w s z) (RWST r w t z) s t
instance (Monoid w, Monad z) => Zoom (RWST r w s z) (RWST r w t z) s t
instance Zoom m n s t => Zoom (IdentityT m) (IdentityT n) s t
instance Zoom m n s t => Zoom (ReaderT e m) (ReaderT e n) s t
instance Monad z => Zoom (StateT s z) (StateT t z) s t
instance Monad z => Zoom (StateT s z) (StateT t z) s t


module Data.HashSet.Lens

-- | This <a>Setter</a> can be used to change the type of a <a>HashSet</a>
--   by mapping the elements to new values.
--   
--   Sadly, you can't create a valid <a>Traversal</a> for a <tt>Set</tt>,
--   but you can manipulate it by reading using <a>folded</a> and
--   reindexing it via <a>setmapped</a>.
setmapped :: (Eq i, Hashable i, Eq j, Hashable j) => IndexPreservingSetter (HashSet i) (HashSet j) i j

-- | Construct a set from a <a>Getter</a>, <a>Fold</a>, <a>Traversal</a>,
--   <a>Lens</a> or <a>Iso</a>.
--   
--   <pre>
--   <a>setOf</a> :: <a>Hashable</a> a         =&gt; <a>Getter</a> s a     -&gt; s -&gt; <a>HashSet</a> a
--   <a>setOf</a> :: (<a>Eq</a> a, <a>Hashable</a> a) =&gt; <a>Fold</a> s a       -&gt; s -&gt; <a>HashSet</a> a
--   <a>setOf</a> :: <a>Hashable</a> a         =&gt; <a>Iso'</a> s a       -&gt; s -&gt; <a>HashSet</a> a
--   <a>setOf</a> :: <a>Hashable</a> a         =&gt; <a>Lens'</a> s a      -&gt; s -&gt; <a>HashSet</a> a
--   <a>setOf</a> :: (<a>Eq</a> a, <a>Hashable</a> a) =&gt; <a>Traversal'</a> s a -&gt; s -&gt; <a>HashSet</a> a
--   </pre>
setOf :: Hashable a => Getting (HashSet a) s a -> s -> HashSet a


-- | A <tt><a>Fold</a> s a</tt> is a generalization of something
--   <a>Foldable</a>. It allows you to extract multiple results from a
--   container. A <a>Foldable</a> container can be characterized by the
--   behavior of <tt><a>foldMap</a> :: (<a>Foldable</a> t, <a>Monoid</a> m)
--   =&gt; (a -&gt; m) -&gt; t a -&gt; m</tt>. Since we want to be able to
--   work with monomorphic containers, we could generalize this signature
--   to <tt>forall m. <a>Monoid</a> m =&gt; (a -&gt; m) -&gt; s -&gt;
--   m</tt>, and then decorate it with <a>Accessor</a> to obtain
--   
--   <pre>
--   type <a>Fold</a> s a = forall m. <a>Monoid</a> m =&gt; <a>Getting</a> m s a
--   </pre>
--   
--   Every <a>Getter</a> is a valid <a>Fold</a> that simply doesn't use the
--   <a>Monoid</a> it is passed.
--   
--   In practice the type we use is slightly more complicated to allow for
--   better error messages and for it to be transformed by certain
--   <a>Applicative</a> transformers.
--   
--   Everything you can do with a <a>Foldable</a> container, you can with
--   with a <a>Fold</a> and there are combinators that generalize the usual
--   <a>Foldable</a> operations here.
module Control.Lens.Fold

-- | A <a>Fold</a> describes how to retrieve multiple values in a way that
--   can be composed with other <a>LensLike</a> constructions.
--   
--   A <tt><a>Fold</a> s a</tt> provides a structure with operations very
--   similar to those of the <a>Foldable</a> typeclass, see
--   <a>foldMapOf</a> and the other <a>Fold</a> combinators.
--   
--   By convention, if there exists a <tt>foo</tt> method that expects a
--   <tt><a>Foldable</a> (f a)</tt>, then there should be a <tt>fooOf</tt>
--   method that takes a <tt><a>Fold</a> s a</tt> and a value of type
--   <tt>s</tt>.
--   
--   A <a>Getter</a> is a legal <a>Fold</a> that just ignores the supplied
--   <a>Monoid</a>.
--   
--   Unlike a <a>Traversal</a> a <a>Fold</a> is read-only. Since a
--   <a>Fold</a> cannot be used to write back there are no <a>Lens</a> laws
--   that apply.
type Fold s a = forall f. (Contravariant f, Applicative f) => (a -> f a) -> s -> f s

-- | Every <a>IndexedFold</a> is a valid <a>Fold</a> and can be used for
--   <a>Getting</a>.
type IndexedFold i s a = forall p f. (Indexable i p, Contravariant f, Applicative f) => p a (f a) -> s -> f s

-- | A convenient infix (flipped) version of <a>toListOf</a>.
--   
--   <pre>
--   &gt;&gt;&gt; [[1,2],[3]]^..traverse.traverse
--   [1,2,3]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (1,2)^..both
--   [1,2]
--   </pre>
--   
--   <pre>
--   <a>toList</a> xs ≡ xs <a>^..</a> <a>folded</a>
--   (<a>^..</a>) ≡ <a>flip</a> <a>toListOf</a>
--   </pre>
--   
--   <pre>
--   (<a>^..</a>) :: s -&gt; <a>Getter</a> s a     -&gt; [a]
--   (<a>^..</a>) :: s -&gt; <a>Fold</a> s a       -&gt; [a]
--   (<a>^..</a>) :: s -&gt; <a>Lens'</a> s a      -&gt; [a]
--   (<a>^..</a>) :: s -&gt; <a>Iso'</a> s a       -&gt; [a]
--   (<a>^..</a>) :: s -&gt; <a>Traversal'</a> s a -&gt; [a]
--   (<a>^..</a>) :: s -&gt; <a>Prism'</a> s a     -&gt; [a]
--   </pre>
(^..) :: s -> Getting (Endo [a]) s a -> [a]

-- | Perform a safe <a>head</a> of a <a>Fold</a> or <a>Traversal</a> or
--   retrieve <a>Just</a> the result from a <a>Getter</a> or <a>Lens</a>.
--   
--   When using a <a>Traversal</a> as a partial <a>Lens</a>, or a
--   <a>Fold</a> as a partial <a>Getter</a> this can be a convenient way to
--   extract the optional value.
--   
--   Note: if you get stack overflows due to this, you may want to use
--   <a>firstOf</a> instead, which can deal more gracefully with heavily
--   left-biased trees.
--   
--   <pre>
--   &gt;&gt;&gt; Left 4 ^?_Left
--   Just 4
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Right 4 ^?_Left
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "world" ^? ix 3
--   Just 'l'
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "world" ^? ix 20
--   Nothing
--   </pre>
--   
--   <pre>
--   (<a>^?</a>) ≡ <a>flip</a> <a>preview</a>
--   </pre>
--   
--   <pre>
--   (<a>^?</a>) :: s -&gt; <a>Getter</a> s a     -&gt; <a>Maybe</a> a
--   (<a>^?</a>) :: s -&gt; <a>Fold</a> s a       -&gt; <a>Maybe</a> a
--   (<a>^?</a>) :: s -&gt; <a>Lens'</a> s a      -&gt; <a>Maybe</a> a
--   (<a>^?</a>) :: s -&gt; <a>Iso'</a> s a       -&gt; <a>Maybe</a> a
--   (<a>^?</a>) :: s -&gt; <a>Traversal'</a> s a -&gt; <a>Maybe</a> a
--   </pre>
(^?) :: s -> Getting (First a) s a -> Maybe a

-- | Perform an *UNSAFE* <a>head</a> of a <a>Fold</a> or <a>Traversal</a>
--   assuming that it is there.
--   
--   <pre>
--   &gt;&gt;&gt; Left 4 ^?! _Left
--   4
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "world" ^?! ix 3
--   'l'
--   </pre>
--   
--   <pre>
--   (<a>^?!</a>) :: s -&gt; <a>Getter</a> s a     -&gt; a
--   (<a>^?!</a>) :: s -&gt; <a>Fold</a> s a       -&gt; a
--   (<a>^?!</a>) :: s -&gt; <a>Lens'</a> s a      -&gt; a
--   (<a>^?!</a>) :: s -&gt; <a>Iso'</a> s a       -&gt; a
--   (<a>^?!</a>) :: s -&gt; <a>Traversal'</a> s a -&gt; a
--   </pre>
(^?!) :: s -> Getting (Endo a) s a -> a

-- | This converts a <a>Fold</a> to a <a>IndexPreservingGetter</a> that
--   returns the first element, if it exists, as a <a>Maybe</a>.
--   
--   <pre>
--   <a>pre</a> :: <a>Getter</a> s a           -&gt; <a>IndexPreservingGetter</a> s (<a>Maybe</a> a)
--   <a>pre</a> :: <a>Fold</a> s a             -&gt; <a>IndexPreservingGetter</a> s (<a>Maybe</a> a)
--   <a>pre</a> :: <a>Simple</a> <a>Traversal</a> s a -&gt; <a>IndexPreservingGetter</a> s (<a>Maybe</a> a)
--   <a>pre</a> :: <a>Simple</a> <a>Lens</a> s a      -&gt; <a>IndexPreservingGetter</a> s (<a>Maybe</a> a)
--   <a>pre</a> :: <a>Simple</a> <a>Iso</a> s a       -&gt; <a>IndexPreservingGetter</a> s (<a>Maybe</a> a)
--   <a>pre</a> :: <a>Simple</a> <a>Prism</a> s a     -&gt; <a>IndexPreservingGetter</a> s (<a>Maybe</a> a)
--   </pre>
pre :: Getting (First a) s a -> IndexPreservingGetter s (Maybe a)

-- | This converts an <a>IndexedFold</a> to an <a>IndexPreservingGetter</a>
--   that returns the first index and element, if they exist, as a
--   <a>Maybe</a>.
--   
--   <pre>
--   <a>ipre</a> :: <a>IndexedGetter</a> i s a             -&gt; <a>IndexPreservingGetter</a> s (<a>Maybe</a> (i, a))
--   <a>ipre</a> :: <a>IndexedFold</a> i s a               -&gt; <a>IndexPreservingGetter</a> s (<a>Maybe</a> (i, a))
--   <a>ipre</a> :: <a>Simple</a> (<a>IndexedTraversal</a> i) s a -&gt; <a>IndexPreservingGetter</a> s (<a>Maybe</a> (i, a))
--   <a>ipre</a> :: <a>Simple</a> (<a>IndexedLens</a> i) s a      -&gt; <a>IndexPreservingGetter</a> s (<a>Maybe</a> (i, a))
--   </pre>
ipre :: IndexedGetting i (First (i, a)) s a -> IndexPreservingGetter s (Maybe (i, a))

-- | Retrieve the first value targeted by a <a>Fold</a> or <a>Traversal</a>
--   (or <a>Just</a> the result from a <a>Getter</a> or <a>Lens</a>). See
--   also (<a>^?</a>).
--   
--   <pre>
--   <a>listToMaybe</a> <a>.</a> <a>toList</a> ≡ <a>preview</a> <a>folded</a>
--   </pre>
--   
--   This is usually applied in the <a>Reader</a> <a>Monad</a> <tt>(-&gt;)
--   s</tt>.
--   
--   <pre>
--   <a>preview</a> = <a>view</a> <a>.</a> <a>pre</a>
--   </pre>
--   
--   <pre>
--   <a>preview</a> :: <a>Getter</a> s a     -&gt; s -&gt; <a>Maybe</a> a
--   <a>preview</a> :: <a>Fold</a> s a       -&gt; s -&gt; <a>Maybe</a> a
--   <a>preview</a> :: <a>Lens'</a> s a      -&gt; s -&gt; <a>Maybe</a> a
--   <a>preview</a> :: <a>Iso'</a> s a       -&gt; s -&gt; <a>Maybe</a> a
--   <a>preview</a> :: <a>Traversal'</a> s a -&gt; s -&gt; <a>Maybe</a> a
--   </pre>
--   
--   However, it may be useful to think of its full generality when working
--   with a <a>Monad</a> transformer stack:
--   
--   <pre>
--   <a>preview</a> :: <a>MonadReader</a> s m =&gt; <a>Getter</a> s a     -&gt; m (<a>Maybe</a> a)
--   <a>preview</a> :: <a>MonadReader</a> s m =&gt; <a>Fold</a> s a       -&gt; m (<a>Maybe</a> a)
--   <a>preview</a> :: <a>MonadReader</a> s m =&gt; <a>Lens'</a> s a      -&gt; m (<a>Maybe</a> a)
--   <a>preview</a> :: <a>MonadReader</a> s m =&gt; <a>Iso'</a> s a       -&gt; m (<a>Maybe</a> a)
--   <a>preview</a> :: <a>MonadReader</a> s m =&gt; <a>Traversal'</a> s a -&gt; m (<a>Maybe</a> a)
--   </pre>
preview :: MonadReader s m => Getting (First a) s a -> m (Maybe a)

-- | Retrieve a function of the first value targeted by a <a>Fold</a> or
--   <a>Traversal</a> (or <a>Just</a> the result from a <a>Getter</a> or
--   <a>Lens</a>).
--   
--   This is usually applied in the <a>Reader</a> <a>Monad</a> <tt>(-&gt;)
--   s</tt>.
previews :: MonadReader s m => Getting (First r) s a -> (a -> r) -> m (Maybe r)

-- | Retrieve the first index and value targeted by a <a>Fold</a> or
--   <a>Traversal</a> (or <a>Just</a> the result from a <a>Getter</a> or
--   <a>Lens</a>). See also (<a>^@?</a>).
--   
--   <pre>
--   <a>ipreview</a> = <a>view</a> <a>.</a> <a>ipre</a>
--   </pre>
--   
--   This is usually applied in the <a>Reader</a> <a>Monad</a> <tt>(-&gt;)
--   s</tt>.
--   
--   <pre>
--   <a>ipreview</a> :: <a>IndexedGetter</a> i s a     -&gt; s -&gt; <a>Maybe</a> (i, a)
--   <a>ipreview</a> :: <a>IndexedFold</a> i s a       -&gt; s -&gt; <a>Maybe</a> (i, a)
--   <a>ipreview</a> :: <a>IndexedLens'</a> i s a      -&gt; s -&gt; <a>Maybe</a> (i, a)
--   <a>ipreview</a> :: <a>IndexedTraversal'</a> i s a -&gt; s -&gt; <a>Maybe</a> (i, a)
--   </pre>
--   
--   However, it may be useful to think of its full generality when working
--   with a <a>Monad</a> transformer stack:
--   
--   <pre>
--   <a>ipreview</a> :: <a>MonadReader</a> s m =&gt; <a>IndexedGetter</a> s a     -&gt; m (<a>Maybe</a> (i, a))
--   <a>ipreview</a> :: <a>MonadReader</a> s m =&gt; <a>IndexedFold</a> s a       -&gt; m (<a>Maybe</a> (i, a))
--   <a>ipreview</a> :: <a>MonadReader</a> s m =&gt; <a>IndexedLens'</a> s a      -&gt; m (<a>Maybe</a> (i, a))
--   <a>ipreview</a> :: <a>MonadReader</a> s m =&gt; <a>IndexedTraversal'</a> s a -&gt; m (<a>Maybe</a> (i, a))
--   </pre>
ipreview :: MonadReader s m => IndexedGetting i (First (i, a)) s a -> m (Maybe (i, a))

-- | Retrieve a function of the first index and value targeted by an
--   <a>IndexedFold</a> or <a>IndexedTraversal</a> (or <a>Just</a> the
--   result from an <a>IndexedGetter</a> or <a>IndexedLens</a>). See also
--   (<a>^@?</a>).
--   
--   <pre>
--   <a>ipreviews</a> = <a>views</a> <a>.</a> <a>ipre</a>
--   </pre>
--   
--   This is usually applied in the <a>Reader</a> <a>Monad</a> <tt>(-&gt;)
--   s</tt>.
--   
--   <pre>
--   <a>ipreviews</a> :: <a>IndexedGetter</a> i s a     -&gt; (i -&gt; a -&gt; r) -&gt; s -&gt; <a>Maybe</a> r
--   <a>ipreviews</a> :: <a>IndexedFold</a> i s a       -&gt; (i -&gt; a -&gt; r) -&gt; s -&gt; <a>Maybe</a> r
--   <a>ipreviews</a> :: <a>IndexedLens'</a> i s a      -&gt; (i -&gt; a -&gt; r) -&gt; s -&gt; <a>Maybe</a> r
--   <a>ipreviews</a> :: <a>IndexedTraversal'</a> i s a -&gt; (i -&gt; a -&gt; r) -&gt; s -&gt; <a>Maybe</a> r
--   </pre>
--   
--   However, it may be useful to think of its full generality when working
--   with a <a>Monad</a> transformer stack:
--   
--   <pre>
--   <a>ipreviews</a> :: <a>MonadReader</a> s m =&gt; <a>IndexedGetter</a> i s a     -&gt; (i -&gt; a -&gt; r) -&gt; m (<a>Maybe</a> r)
--   <a>ipreviews</a> :: <a>MonadReader</a> s m =&gt; <a>IndexedFold</a> i s a       -&gt; (i -&gt; a -&gt; r) -&gt; m (<a>Maybe</a> r)
--   <a>ipreviews</a> :: <a>MonadReader</a> s m =&gt; <a>IndexedLens'</a> i s a      -&gt; (i -&gt; a -&gt; r) -&gt; m (<a>Maybe</a> r)
--   <a>ipreviews</a> :: <a>MonadReader</a> s m =&gt; <a>IndexedTraversal'</a> i s a -&gt; (i -&gt; a -&gt; r) -&gt; m (<a>Maybe</a> r)
--   </pre>
ipreviews :: MonadReader s m => IndexedGetting i (First r) s a -> (i -> a -> r) -> m (Maybe r)

-- | Retrieve the first value targeted by a <a>Fold</a> or <a>Traversal</a>
--   (or <a>Just</a> the result from a <a>Getter</a> or <a>Lens</a>) into
--   the current state.
--   
--   <pre>
--   <a>preuse</a> = <a>use</a> <a>.</a> <a>pre</a>
--   </pre>
--   
--   <pre>
--   <a>preuse</a> :: <a>MonadState</a> s m =&gt; <a>Getter</a> s a     -&gt; m (<a>Maybe</a> a)
--   <a>preuse</a> :: <a>MonadState</a> s m =&gt; <a>Fold</a> s a       -&gt; m (<a>Maybe</a> a)
--   <a>preuse</a> :: <a>MonadState</a> s m =&gt; <a>Lens'</a> s a      -&gt; m (<a>Maybe</a> a)
--   <a>preuse</a> :: <a>MonadState</a> s m =&gt; <a>Iso'</a> s a       -&gt; m (<a>Maybe</a> a)
--   <a>preuse</a> :: <a>MonadState</a> s m =&gt; <a>Traversal'</a> s a -&gt; m (<a>Maybe</a> a)
--   </pre>
preuse :: MonadState s m => Getting (First a) s a -> m (Maybe a)

-- | Retrieve a function of the first value targeted by a <a>Fold</a> or
--   <a>Traversal</a> (or <a>Just</a> the result from a <a>Getter</a> or
--   <a>Lens</a>) into the current state.
--   
--   <pre>
--   <a>preuses</a> = <a>uses</a> <a>.</a> <a>pre</a>
--   </pre>
--   
--   <pre>
--   <a>preuses</a> :: <a>MonadState</a> s m =&gt; <a>Getter</a> s a     -&gt; (a -&gt; r) -&gt; m (<a>Maybe</a> r)
--   <a>preuses</a> :: <a>MonadState</a> s m =&gt; <a>Fold</a> s a       -&gt; (a -&gt; r) -&gt; m (<a>Maybe</a> r)
--   <a>preuses</a> :: <a>MonadState</a> s m =&gt; <a>Lens'</a> s a      -&gt; (a -&gt; r) -&gt; m (<a>Maybe</a> r)
--   <a>preuses</a> :: <a>MonadState</a> s m =&gt; <a>Iso'</a> s a       -&gt; (a -&gt; r) -&gt; m (<a>Maybe</a> r)
--   <a>preuses</a> :: <a>MonadState</a> s m =&gt; <a>Traversal'</a> s a -&gt; (a -&gt; r) -&gt; m (<a>Maybe</a> r)
--   </pre>
preuses :: MonadState s m => Getting (First r) s a -> (a -> r) -> m (Maybe r)

-- | Retrieve the first index and value targeted by an <a>IndexedFold</a>
--   or <a>IndexedTraversal</a> (or <a>Just</a> the index and result from
--   an <a>IndexedGetter</a> or <a>IndexedLens</a>) into the current state.
--   
--   <pre>
--   <a>ipreuse</a> = <a>use</a> <a>.</a> <a>ipre</a>
--   </pre>
--   
--   <pre>
--   <a>ipreuse</a> :: <a>MonadState</a> s m =&gt; <a>IndexedGetter</a> i s a     -&gt; m (<a>Maybe</a> (i, a))
--   <a>ipreuse</a> :: <a>MonadState</a> s m =&gt; <a>IndexedFold</a> i s a       -&gt; m (<a>Maybe</a> (i, a))
--   <a>ipreuse</a> :: <a>MonadState</a> s m =&gt; <a>IndexedLens'</a> i s a      -&gt; m (<a>Maybe</a> (i, a))
--   <a>ipreuse</a> :: <a>MonadState</a> s m =&gt; <a>IndexedTraversal'</a> i s a -&gt; m (<a>Maybe</a> (i, a))
--   </pre>
ipreuse :: MonadState s m => IndexedGetting i (First (i, a)) s a -> m (Maybe (i, a))

-- | Retrieve a function of the first index and value targeted by an
--   <a>IndexedFold</a> or <a>IndexedTraversal</a> (or a function of
--   <a>Just</a> the index and result from an <a>IndexedGetter</a> or
--   <a>IndexedLens</a>) into the current state.
--   
--   <pre>
--   <a>ipreuses</a> = <a>uses</a> <a>.</a> <a>ipre</a>
--   </pre>
--   
--   <pre>
--   <a>ipreuses</a> :: <a>MonadState</a> s m =&gt; <a>IndexedGetter</a> i s a     -&gt; (i -&gt; a -&gt; r) -&gt; m (<a>Maybe</a> r)
--   <a>ipreuses</a> :: <a>MonadState</a> s m =&gt; <a>IndexedFold</a> i s a       -&gt; (i -&gt; a -&gt; r) -&gt; m (<a>Maybe</a> r)
--   <a>ipreuses</a> :: <a>MonadState</a> s m =&gt; <a>IndexedLens'</a> i s a      -&gt; (i -&gt; a -&gt; r) -&gt; m (<a>Maybe</a> r)
--   <a>ipreuses</a> :: <a>MonadState</a> s m =&gt; <a>IndexedTraversal'</a> i s a -&gt; (i -&gt; a -&gt; r) -&gt; m (<a>Maybe</a> r)
--   </pre>
ipreuses :: MonadState s m => IndexedGetting i (First r) s a -> (i -> a -> r) -> m (Maybe r)

-- | Check to see if this <a>Fold</a> or <a>Traversal</a> matches 1 or more
--   entries.
--   
--   <pre>
--   &gt;&gt;&gt; has (element 0) []
--   False
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; has _Left (Left 12)
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; has _Right (Left 12)
--   False
--   </pre>
--   
--   This will always return <a>True</a> for a <a>Lens</a> or
--   <a>Getter</a>.
--   
--   <pre>
--   &gt;&gt;&gt; has _1 ("hello","world")
--   True
--   </pre>
--   
--   <pre>
--   <a>has</a> :: <a>Getter</a> s a     -&gt; s -&gt; <a>Bool</a>
--   <a>has</a> :: <a>Fold</a> s a       -&gt; s -&gt; <a>Bool</a>
--   <a>has</a> :: <a>Iso'</a> s a       -&gt; s -&gt; <a>Bool</a>
--   <a>has</a> :: <a>Lens'</a> s a      -&gt; s -&gt; <a>Bool</a>
--   <a>has</a> :: <a>Traversal'</a> s a -&gt; s -&gt; <a>Bool</a>
--   </pre>
has :: Getting Any s a -> s -> Bool

-- | Check to see if this <a>Fold</a> or <a>Traversal</a> has no matches.
--   
--   <pre>
--   &gt;&gt;&gt; hasn't _Left (Right 12)
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; hasn't _Left (Left 12)
--   False
--   </pre>
hasn't :: Getting All s a -> s -> Bool

-- | Obtain a <a>Fold</a> by lifting an operation that returns a
--   <a>Foldable</a> result.
--   
--   This can be useful to lift operations from <tt>Data.List</tt> and
--   elsewhere into a <a>Fold</a>.
--   
--   <pre>
--   &gt;&gt;&gt; [1,2,3,4]^..folding tail
--   [2,3,4]
--   </pre>
folding :: (Foldable f, Contravariant g, Applicative g) => (s -> f a) -> LensLike g s t a b

-- | Obtain a <a>Fold</a> from any <a>Foldable</a>.
--   
--   <pre>
--   &gt;&gt;&gt; Just 3^..folded
--   [3]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Nothing^..folded
--   []
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [(1,2),(3,4)]^..folded.both
--   [1,2,3,4]
--   </pre>
folded :: Foldable f => Fold (f a) a

-- | Build a <a>Fold</a> that unfolds its values from a seed.
--   
--   <pre>
--   <a>unfoldr</a> ≡ <a>toListOf</a> <a>.</a> <a>unfolded</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; 10^..unfolded (\b -&gt; if b == 0 then Nothing else Just (b, b-1))
--   [10,9,8,7,6,5,4,3,2,1]
--   </pre>
unfolded :: (b -> Maybe (a, b)) -> Fold b a

-- | <tt>x <a>^.</a> <a>iterated</a> f</tt> returns an infinite <a>Fold</a>
--   of repeated applications of <tt>f</tt> to <tt>x</tt>.
--   
--   <pre>
--   <a>toListOf</a> (<a>iterated</a> f) a ≡ <a>iterate</a> f a
--   </pre>
iterated :: (a -> a) -> Fold a a

-- | Obtain a <a>Fold</a> that can be composed with to filter another
--   <a>Lens</a>, <a>Iso</a>, <a>Getter</a>, <a>Fold</a> (or
--   <a>Traversal</a>).
--   
--   Note: This is <i>not</i> a legal <a>Traversal</a>, unless you are very
--   careful not to invalidate the predicate on the target.
--   
--   Note: This is also <i>not</i> a legal <a>Prism</a>, unless you are
--   very careful not to inject a value that matches the predicate.
--   
--   As a counter example, consider that given <tt>evens = <a>filtered</a>
--   <a>even</a></tt> the second <a>Traversal</a> law is violated:
--   
--   <pre>
--   <a>over</a> evens <a>succ</a> <a>.</a> <a>over</a> evens <a>succ</a> <a>/=</a> <a>over</a> evens (<a>succ</a> <a>.</a> <a>succ</a>)
--   </pre>
--   
--   So, in order for this to qualify as a legal <a>Traversal</a> you can
--   only use it for actions that preserve the result of the predicate!
--   
--   <pre>
--   &gt;&gt;&gt; [1..10]^..folded.filtered even
--   [2,4,6,8,10]
--   </pre>
--   
--   This will preserve an index if it is present.
filtered :: (Choice p, Applicative f) => (a -> Bool) -> Overloaded' p f a a

-- | This allows you to <a>traverse</a> the elements of a pretty much any
--   <a>LensLike</a> construction in the opposite order.
--   
--   This will preserve indexes on <a>Indexed</a> types and will give you
--   the elements of a (finite) <a>Fold</a> or <a>Traversal</a> in the
--   opposite order.
--   
--   This has no practical impact on a <a>Getter</a>, <a>Setter</a>,
--   <a>Lens</a> or <a>Iso</a>.
--   
--   <i>NB:</i> To write back through an <a>Iso</a>, you want to use
--   <a>from</a>. Similarly, to write back through an <a>Prism</a>, you
--   want to use <a>re</a>.
backwards :: (Profunctor p, Profunctor q) => Overloading p q (Backwards f) s t a b -> Overloading p q f s t a b

-- | <a>Fold</a> by repeating the input forever.
--   
--   <pre>
--   <a>repeat</a> ≡ <a>toListOf</a> <a>repeated</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; 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]
--   </pre>
repeated :: Fold a a

-- | A <a>Fold</a> that replicates its input <tt>n</tt> times.
--   
--   <pre>
--   <a>replicate</a> n ≡ <a>toListOf</a> (<a>replicated</a> n)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; 5^..replicated 20
--   [5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5]
--   </pre>
replicated :: Int -> Fold a a

-- | Transform a <a>Fold</a> into a <a>Fold</a> that loops over its
--   elements over and over.
--   
--   <pre>
--   &gt;&gt;&gt; timingOut $ [1,2,3]^..taking 7 (cycled traverse)
--   [1,2,3,1,2,3,1]
--   </pre>
cycled :: (Contravariant f, Applicative f) => LensLike f s t a b -> LensLike f s t a b

-- | Obtain a <a>Fold</a> by taking elements from another <a>Fold</a>,
--   <a>Lens</a>, <a>Iso</a>, <a>Getter</a> or <a>Traversal</a> while a
--   predicate holds.
--   
--   <pre>
--   <a>takeWhile</a> p ≡ <a>toListOf</a> (<a>takingWhile</a> p <a>folded</a>)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; timingOut $ toListOf (takingWhile (&lt;=3) folded) [1..]
--   [1,2,3]
--   </pre>
--   
--   <pre>
--   <a>takingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>Fold</a> s a                         -&gt; <a>Fold</a> s a
--   <a>takingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>Getter</a> s a                       -&gt; <a>Fold</a> s a
--   <a>takingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>Traversal'</a> s a                   -&gt; <a>Fold</a> s a -- * See note below
--   <a>takingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>Lens'</a> s a                        -&gt; <a>Fold</a> s a -- * See note below
--   <a>takingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>Prism'</a> s a                       -&gt; <a>Fold</a> s a -- * See note below
--   <a>takingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>Iso'</a> s a                         -&gt; <a>Fold</a> s a -- * See note below
--   <a>takingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>Action</a> m s a                     -&gt; <a>MonadicFold</a> m s a
--   <a>takingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>MonadicFold</a> m s a                -&gt; <a>MonadicFold</a> m s a
--   <a>takingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>IndexedTraversal'</a> i s a          -&gt; <a>IndexedFold</a> i s a -- * See note below
--   <a>takingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>IndexedLens'</a> i s a               -&gt; <a>IndexedFold</a> i s a -- * See note below
--   <a>takingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>IndexedFold</a> i s a                -&gt; <a>IndexedFold</a> i s a
--   <a>takingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>IndexedGetter</a> i s a              -&gt; <a>IndexedFold</a> i s a
--   <a>takingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>IndexedAction</a> i m s a            -&gt; <a>IndexedMonadicFold</a> i m s a
--   <a>takingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>IndexedMonadicFold</a> i m s a       -&gt; <a>IndexedMonadicFold</a> i m s a
--   </pre>
--   
--   <i>Note:</i> When applied to a <a>Traversal</a>, <a>takingWhile</a>
--   yields something that can be used as if it were a <a>Traversal</a>,
--   but which is not a <a>Traversal</a> per the laws, unless you are
--   careful to ensure that you do not invalidate the predicate when
--   writing back through it.
takingWhile :: (Conjoined p, Applicative f) => (a -> Bool) -> Over p (TakingWhile p f a a) s t a a -> Over p f s t a a

-- | Obtain a <a>Fold</a> by dropping elements from another <a>Fold</a>,
--   <a>Lens</a>, <a>Iso</a>, <a>Getter</a> or <a>Traversal</a> while a
--   predicate holds.
--   
--   <pre>
--   <a>dropWhile</a> p ≡ <a>toListOf</a> (<a>droppingWhile</a> p <a>folded</a>)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; toListOf (droppingWhile (&lt;=3) folded) [1..6]
--   [4,5,6]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; toListOf (droppingWhile (&lt;=3) folded) [1,6,1]
--   [6,1]
--   </pre>
--   
--   <pre>
--   <a>droppingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>Fold</a> s a                         -&gt; <a>Fold</a> s a
--   <a>droppingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>Getter</a> s a                       -&gt; <a>Fold</a> s a
--   <a>droppingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>Traversal'</a> s a                   -&gt; <a>Fold</a> s a                -- see notes
--   <a>droppingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>Lens'</a> s a                        -&gt; <a>Fold</a> s a                -- see notes
--   <a>droppingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>Prism'</a> s a                       -&gt; <a>Fold</a> s a                -- see notes
--   <a>droppingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>Iso'</a> s a                         -&gt; <a>Fold</a> s a                -- see notes
--   </pre>
--   
--   <pre>
--   <a>droppingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>IndexPreservingTraversal'</a> s a    -&gt; <a>IndexPreservingFold</a> s a -- see notes
--   <a>droppingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>IndexPreservingLens'</a> s a         -&gt; <a>IndexPreservingFold</a> s a -- see notes
--   <a>droppingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>IndexPreservingGetter</a> s a        -&gt; <a>IndexPreservingFold</a> s a
--   <a>droppingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>IndexPreservingFold</a> s a          -&gt; <a>IndexPreservingFold</a> s a
--   <a>droppingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>IndexPreservingAction</a> m s a      -&gt; <a>IndexPreservingFold</a> s a
--   </pre>
--   
--   <pre>
--   <a>droppingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>IndexPreservingMonadicFold</a> m s a -&gt; <a>IndexPreservingMonadicFold</a> m s a
--   </pre>
--   
--   <pre>
--   <a>droppingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>IndexedTraversal'</a> i s a          -&gt; <a>IndexedFold</a> i s a       -- see notes
--   <a>droppingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>IndexedLens'</a> i s a               -&gt; <a>IndexedFold</a> i s a       -- see notes
--   <a>droppingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>IndexedGetter</a> i s a              -&gt; <a>IndexedFold</a> i s a
--   <a>droppingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>IndexedFold</a> i s a                -&gt; <a>IndexedFold</a> i s a
--   <a>droppingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>IndexedAction</a> i m s a            -&gt; <a>IndexedFold</a> i s a
--   </pre>
--   
--   <pre>
--   <a>droppingWhile</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>IndexedMonadicFold</a> i m s a       -&gt; <a>IndexedMonadicFold</a> i m s a
--   </pre>
--   
--   Note: Many uses of this combinator will yield something that meets the
--   types, but not the laws of a valid <a>Traversal</a> or
--   <a>IndexedTraversal</a>. The <a>Traversal</a> and
--   <a>IndexedTraversal</a> laws are only satisfied if the new values you
--   assign also pass the predicate! Otherwise subsequent traversals will
--   visit fewer elements and <a>Traversal</a> fusion is not sound.
droppingWhile :: (Conjoined p, Profunctor q, Applicative f) => (a -> Bool) -> Overloading p q (Compose (State Bool) f) s t a a -> Overloading p q f s t a a

-- | <pre>
--   <a>foldMap</a> = <a>foldMapOf</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>foldMapOf</a> ≡ <a>views</a>
--   <a>ifoldMapOf</a> l = <a>foldMapOf</a> l <a>.</a> <a>Indexed</a>
--   </pre>
--   
--   <pre>
--   <a>foldMapOf</a> ::             <a>Getter</a> s a     -&gt; (a -&gt; r) -&gt; s -&gt; r
--   <a>foldMapOf</a> :: <a>Monoid</a> r =&gt; <a>Fold</a> s a       -&gt; (a -&gt; r) -&gt; s -&gt; r
--   <a>foldMapOf</a> ::             <a>Lens'</a> s a      -&gt; (a -&gt; r) -&gt; s -&gt; r
--   <a>foldMapOf</a> ::             <a>Iso'</a> s a       -&gt; (a -&gt; r) -&gt; s -&gt; r
--   <a>foldMapOf</a> :: <a>Monoid</a> r =&gt; <a>Traversal'</a> s a -&gt; (a -&gt; r) -&gt; s -&gt; r
--   <a>foldMapOf</a> :: <a>Monoid</a> r =&gt; <a>Prism'</a> s a     -&gt; (a -&gt; r) -&gt; s -&gt; r
--   </pre>
--   
--   <pre>
--   <a>foldMapOf</a> :: <a>Getting</a> r s a -&gt; (a -&gt; r) -&gt; s -&gt; r
--   </pre>
foldMapOf :: Profunctor p => Accessing p r s a -> p a r -> s -> r

-- | <pre>
--   <a>fold</a> = <a>foldOf</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>foldOf</a> ≡ <a>view</a>
--   </pre>
--   
--   <pre>
--   <a>foldOf</a> ::             <a>Getter</a> s m     -&gt; s -&gt; m
--   <a>foldOf</a> :: <a>Monoid</a> m =&gt; <a>Fold</a> s m       -&gt; s -&gt; m
--   <a>foldOf</a> ::             <a>Lens'</a> s m      -&gt; s -&gt; m
--   <a>foldOf</a> ::             <a>Iso'</a> s m       -&gt; s -&gt; m
--   <a>foldOf</a> :: <a>Monoid</a> m =&gt; <a>Traversal'</a> s m -&gt; s -&gt; m
--   <a>foldOf</a> :: <a>Monoid</a> m =&gt; <a>Prism'</a> s m     -&gt; s -&gt; m
--   </pre>
foldOf :: Getting a s a -> s -> a

-- | Right-associative fold of parts of a structure that are viewed through
--   a <a>Lens</a>, <a>Getter</a>, <a>Fold</a> or <a>Traversal</a>.
--   
--   <pre>
--   <a>foldr</a> ≡ <a>foldrOf</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>foldrOf</a> :: <a>Getter</a> s a     -&gt; (a -&gt; r -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>foldrOf</a> :: <a>Fold</a> s a       -&gt; (a -&gt; r -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>foldrOf</a> :: <a>Lens'</a> s a      -&gt; (a -&gt; r -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>foldrOf</a> :: <a>Iso'</a> s a       -&gt; (a -&gt; r -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>foldrOf</a> :: <a>Traversal'</a> s a -&gt; (a -&gt; r -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>foldrOf</a> :: <a>Prism'</a> s a     -&gt; (a -&gt; r -&gt; r) -&gt; r -&gt; s -&gt; r
--   </pre>
--   
--   <pre>
--   <a>ifoldrOf</a> l ≡ <a>foldrOf</a> l <a>.</a> <a>Indexed</a>
--   </pre>
--   
--   <pre>
--   <a>foldrOf</a> :: <a>Getting</a> (<a>Endo</a> r) s a -&gt; (a -&gt; r -&gt; r) -&gt; r -&gt; s -&gt; r
--   </pre>
foldrOf :: Profunctor p => Accessing p (Endo r) s a -> p a (r -> r) -> r -> s -> r

-- | Left-associative fold of the parts of a structure that are viewed
--   through a <a>Lens</a>, <a>Getter</a>, <a>Fold</a> or <a>Traversal</a>.
--   
--   <pre>
--   <a>foldl</a> ≡ <a>foldlOf</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>foldlOf</a> :: <a>Getter</a> s a     -&gt; (r -&gt; a -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>foldlOf</a> :: <a>Fold</a> s a       -&gt; (r -&gt; a -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>foldlOf</a> :: <a>Lens'</a> s a      -&gt; (r -&gt; a -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>foldlOf</a> :: <a>Iso'</a> s a       -&gt; (r -&gt; a -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>foldlOf</a> :: <a>Traversal'</a> s a -&gt; (r -&gt; a -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>foldlOf</a> :: <a>Prism'</a> s a     -&gt; (r -&gt; a -&gt; r) -&gt; r -&gt; s -&gt; r
--   </pre>
foldlOf :: Getting (Dual (Endo r)) s a -> (r -> a -> r) -> r -> s -> r

-- | Extract a list of the targets of a <a>Fold</a>. See also (<a>^..</a>).
--   
--   <pre>
--   <a>toList</a> ≡ <a>toListOf</a> <a>folded</a>
--   (<a>^..</a>) ≡ <a>flip</a> <a>toListOf</a>
--   </pre>
toListOf :: Getting (Endo [a]) s a -> s -> [a]

-- | Returns <a>True</a> if any target of a <a>Fold</a> satisfies a
--   predicate.
--   
--   <pre>
--   &gt;&gt;&gt; anyOf both (=='x') ('x','y')
--   True
--   
--   &gt;&gt;&gt; import Data.Data.Lens
--   
--   &gt;&gt;&gt; anyOf biplate (== "world") (((),2::Int),"hello",("world",11))
--   True
--   </pre>
--   
--   <pre>
--   <a>any</a> ≡ <a>anyOf</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>ianyOf</a> l ≡ <a>allOf</a> l <a>.</a> <a>Indexed</a>
--   </pre>
--   
--   <pre>
--   <a>anyOf</a> :: <a>Getter</a> s a     -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>anyOf</a> :: <a>Fold</a> s a       -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>anyOf</a> :: <a>Lens'</a> s a      -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>anyOf</a> :: <a>Iso'</a> s a       -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>anyOf</a> :: <a>Traversal'</a> s a -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>anyOf</a> :: <a>Prism'</a> s a     -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   </pre>
anyOf :: Profunctor p => Accessing p Any s a -> p a Bool -> s -> Bool

-- | Returns <a>True</a> if every target of a <a>Fold</a> satisfies a
--   predicate.
--   
--   <pre>
--   &gt;&gt;&gt; allOf both (&gt;=3) (4,5)
--   True
--   
--   &gt;&gt;&gt; allOf folded (&gt;=2) [1..10]
--   False
--   </pre>
--   
--   <pre>
--   <a>all</a> ≡ <a>allOf</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>iallOf</a> l = <a>allOf</a> l <a>.</a> <a>Indexed</a>
--   </pre>
--   
--   <pre>
--   <a>allOf</a> :: <a>Getter</a> s a     -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>allOf</a> :: <a>Fold</a> s a       -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>allOf</a> :: <a>Lens'</a> s a      -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>allOf</a> :: <a>Iso'</a> s a       -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>allOf</a> :: <a>Traversal'</a> s a -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>allOf</a> :: <a>Prism'</a> s a     -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   </pre>
allOf :: Profunctor p => Accessing p All s a -> p a Bool -> s -> Bool

-- | Returns <a>True</a> if every target of a <a>Fold</a> is <a>True</a>.
--   
--   <pre>
--   &gt;&gt;&gt; andOf both (True,False)
--   False
--   
--   &gt;&gt;&gt; andOf both (True,True)
--   True
--   </pre>
--   
--   <pre>
--   <a>and</a> ≡ <a>andOf</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>andOf</a> :: <a>Getter</a> s <a>Bool</a>     -&gt; s -&gt; <a>Bool</a>
--   <a>andOf</a> :: <a>Fold</a> s <a>Bool</a>       -&gt; s -&gt; <a>Bool</a>
--   <a>andOf</a> :: <a>Lens'</a> s <a>Bool</a>      -&gt; s -&gt; <a>Bool</a>
--   <a>andOf</a> :: <a>Iso'</a> s <a>Bool</a>       -&gt; s -&gt; <a>Bool</a>
--   <a>andOf</a> :: <a>Traversal'</a> s <a>Bool</a> -&gt; s -&gt; <a>Bool</a>
--   <a>andOf</a> :: <a>Prism'</a> s <a>Bool</a>     -&gt; s -&gt; <a>Bool</a>
--   </pre>
andOf :: Getting All s Bool -> s -> Bool

-- | Returns <a>True</a> if any target of a <a>Fold</a> is <a>True</a>.
--   
--   <pre>
--   &gt;&gt;&gt; orOf both (True,False)
--   True
--   
--   &gt;&gt;&gt; orOf both (False,False)
--   False
--   </pre>
--   
--   <pre>
--   <a>or</a> ≡ <a>orOf</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>orOf</a> :: <a>Getter</a> s <a>Bool</a>     -&gt; s -&gt; <a>Bool</a>
--   <a>orOf</a> :: <a>Fold</a> s <a>Bool</a>       -&gt; s -&gt; <a>Bool</a>
--   <a>orOf</a> :: <a>Lens'</a> s <a>Bool</a>      -&gt; s -&gt; <a>Bool</a>
--   <a>orOf</a> :: <a>Iso'</a> s <a>Bool</a>       -&gt; s -&gt; <a>Bool</a>
--   <a>orOf</a> :: <a>Traversal'</a> s <a>Bool</a> -&gt; s -&gt; <a>Bool</a>
--   <a>orOf</a> :: <a>Prism'</a> s <a>Bool</a>     -&gt; s -&gt; <a>Bool</a>
--   </pre>
orOf :: Getting Any s Bool -> s -> Bool

-- | Calculate the <a>Product</a> of every number targeted by a
--   <a>Fold</a>.
--   
--   <pre>
--   &gt;&gt;&gt; productOf both (4,5)
--   20
--   
--   &gt;&gt;&gt; productOf folded [1,2,3,4,5]
--   120
--   </pre>
--   
--   <pre>
--   <a>product</a> ≡ <a>productOf</a> <a>folded</a>
--   </pre>
productOf :: Num a => Getting (Endo (Endo a)) s a -> s -> a

-- | Calculate the <a>Sum</a> of every number targeted by a <a>Fold</a>.
--   
--   <pre>
--   &gt;&gt;&gt; sumOf both (5,6)
--   11
--   
--   &gt;&gt;&gt; sumOf folded [1,2,3,4]
--   10
--   
--   &gt;&gt;&gt; sumOf (folded.both) [(1,2),(3,4)]
--   10
--   
--   &gt;&gt;&gt; import Data.Data.Lens
--   
--   &gt;&gt;&gt; sumOf biplate [(1::Int,[]),(2,[(3::Int,4::Int)])] :: Int
--   10
--   </pre>
--   
--   <pre>
--   <a>sum</a> ≡ <a>sumOf</a> <a>folded</a>
--   </pre>
--   
--   This operation may be more strict than you would expect. If you want a
--   lazier version use <tt><tt>ala</tt> <a>Sum</a> <a>.</a>
--   <a>foldMapOf</a></tt>
--   
--   <pre>
--   <a>sumOf</a> <tt>_1</tt> :: <a>Num</a> a =&gt; (a, b) -&gt; a
--   <a>sumOf</a> (<a>folded</a> <a>.</a> <a>_1</a>) :: (<a>Foldable</a> f, <a>Num</a> a) =&gt; f (a, b) -&gt; a
--   </pre>
--   
--   <pre>
--   <a>sumOf</a> :: <a>Num</a> a =&gt; <a>Getter</a> s a     -&gt; s -&gt; a
--   <a>sumOf</a> :: <a>Num</a> a =&gt; <a>Fold</a> s a       -&gt; s -&gt; a
--   <a>sumOf</a> :: <a>Num</a> a =&gt; <a>Lens'</a> s a      -&gt; s -&gt; a
--   <a>sumOf</a> :: <a>Num</a> a =&gt; <a>Iso'</a> s a       -&gt; s -&gt; a
--   <a>sumOf</a> :: <a>Num</a> a =&gt; <a>Traversal'</a> s a -&gt; s -&gt; a
--   <a>sumOf</a> :: <a>Num</a> a =&gt; <a>Prism'</a> s a     -&gt; s -&gt; a
--   </pre>
sumOf :: Num a => Getting (Endo (Endo a)) s a -> s -> a

-- | Traverse over all of the targets of a <a>Fold</a> (or <a>Getter</a>),
--   computing an <a>Applicative</a> (or <a>Functor</a>)-based answer, but
--   unlike <a>traverseOf</a> do not construct a new structure.
--   <a>traverseOf_</a> generalizes <a>traverse_</a> to work over any
--   <a>Fold</a>.
--   
--   When passed a <a>Getter</a>, <a>traverseOf_</a> can work over any
--   <a>Functor</a>, but when passed a <a>Fold</a>, <a>traverseOf_</a>
--   requires an <a>Applicative</a>.
--   
--   <pre>
--   &gt;&gt;&gt; traverseOf_ both putStrLn ("hello","world")
--   hello
--   world
--   </pre>
--   
--   <pre>
--   <a>traverse_</a> ≡ <a>traverseOf_</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>traverseOf_</a> <tt>_2</tt> :: <a>Functor</a> f =&gt; (c -&gt; f r) -&gt; (d, c) -&gt; f ()
--   <a>traverseOf_</a> <a>_Left</a> :: <a>Applicative</a> f =&gt; (a -&gt; f b) -&gt; <a>Either</a> a c -&gt; f ()
--   </pre>
--   
--   <pre>
--   <a>itraverseOf_</a> l ≡ <a>traverseOf_</a> l <a>.</a> <a>Indexed</a>
--   </pre>
--   
--   The rather specific signature of <a>traverseOf_</a> allows it to be
--   used as if the signature was any of:
--   
--   <pre>
--   <a>traverseOf_</a> :: <a>Functor</a> f     =&gt; <a>Getter</a> s a     -&gt; (a -&gt; f r) -&gt; s -&gt; f ()
--   <a>traverseOf_</a> :: <a>Applicative</a> f =&gt; <a>Fold</a> s a       -&gt; (a -&gt; f r) -&gt; s -&gt; f ()
--   <a>traverseOf_</a> :: <a>Functor</a> f     =&gt; <a>Lens'</a> s a      -&gt; (a -&gt; f r) -&gt; s -&gt; f ()
--   <a>traverseOf_</a> :: <a>Functor</a> f     =&gt; <a>Iso'</a> s a       -&gt; (a -&gt; f r) -&gt; s -&gt; f ()
--   <a>traverseOf_</a> :: <a>Applicative</a> f =&gt; <a>Traversal'</a> s a -&gt; (a -&gt; f r) -&gt; s -&gt; f ()
--   <a>traverseOf_</a> :: <a>Applicative</a> f =&gt; <a>Prism'</a> s a     -&gt; (a -&gt; f r) -&gt; s -&gt; f ()
--   </pre>
traverseOf_ :: (Profunctor p, Functor f) => Accessing p (Traversed r f) s a -> p a (f r) -> s -> f ()

-- | Traverse over all of the targets of a <a>Fold</a> (or <a>Getter</a>),
--   computing an <a>Applicative</a> (or <a>Functor</a>)-based answer, but
--   unlike <a>forOf</a> do not construct a new structure. <a>forOf_</a>
--   generalizes <a>for_</a> to work over any <a>Fold</a>.
--   
--   When passed a <a>Getter</a>, <a>forOf_</a> can work over any
--   <a>Functor</a>, but when passed a <a>Fold</a>, <a>forOf_</a> requires
--   an <a>Applicative</a>.
--   
--   <pre>
--   <a>for_</a> ≡ <a>forOf_</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; forOf_ both ("hello","world") putStrLn
--   hello
--   world
--   </pre>
--   
--   The rather specific signature of <a>forOf_</a> allows it to be used as
--   if the signature was any of:
--   
--   <pre>
--   <a>iforOf_</a> l s ≡ <a>forOf_</a> l s <a>.</a> <a>Indexed</a>
--   </pre>
--   
--   <pre>
--   <a>forOf_</a> :: <a>Functor</a> f     =&gt; <a>Getter</a> s a     -&gt; s -&gt; (a -&gt; f r) -&gt; f ()
--   <a>forOf_</a> :: <a>Applicative</a> f =&gt; <a>Fold</a> s a       -&gt; s -&gt; (a -&gt; f r) -&gt; f ()
--   <a>forOf_</a> :: <a>Functor</a> f     =&gt; <a>Lens'</a> s a      -&gt; s -&gt; (a -&gt; f r) -&gt; f ()
--   <a>forOf_</a> :: <a>Functor</a> f     =&gt; <a>Iso'</a> s a       -&gt; s -&gt; (a -&gt; f r) -&gt; f ()
--   <a>forOf_</a> :: <a>Applicative</a> f =&gt; <a>Traversal'</a> s a -&gt; s -&gt; (a -&gt; f r) -&gt; f ()
--   <a>forOf_</a> :: <a>Applicative</a> f =&gt; <a>Prism'</a> s a     -&gt; s -&gt; (a -&gt; f r) -&gt; f ()
--   </pre>
forOf_ :: (Profunctor p, Functor f) => Accessing p (Traversed r f) s a -> s -> p a (f r) -> f ()

-- | Evaluate each action in observed by a <a>Fold</a> on a structure from
--   left to right, ignoring the results.
--   
--   <pre>
--   <a>sequenceA_</a> ≡ <a>sequenceAOf_</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; sequenceAOf_ both (putStrLn "hello",putStrLn "world")
--   hello
--   world
--   </pre>
--   
--   <pre>
--   <a>sequenceAOf_</a> :: <a>Functor</a> f     =&gt; <a>Getter</a> s (f a)     -&gt; s -&gt; f ()
--   <a>sequenceAOf_</a> :: <a>Applicative</a> f =&gt; <a>Fold</a> s (f a)       -&gt; s -&gt; f ()
--   <a>sequenceAOf_</a> :: <a>Functor</a> f     =&gt; <a>Lens'</a> s (f a)      -&gt; s -&gt; f ()
--   <a>sequenceAOf_</a> :: <a>Functor</a> f     =&gt; <a>Iso'</a> s (f a)       -&gt; s -&gt; f ()
--   <a>sequenceAOf_</a> :: <a>Applicative</a> f =&gt; <a>Traversal'</a> s (f a) -&gt; s -&gt; f ()
--   <a>sequenceAOf_</a> :: <a>Applicative</a> f =&gt; <a>Prism'</a> s (f a)     -&gt; s -&gt; f ()
--   </pre>
sequenceAOf_ :: Functor f => Getting (Traversed a f) s (f a) -> s -> f ()

-- | Map each target of a <a>Fold</a> on a structure to a monadic action,
--   evaluate these actions from left to right, and ignore the results.
--   
--   <pre>
--   &gt;&gt;&gt; mapMOf_ both putStrLn ("hello","world")
--   hello
--   world
--   </pre>
--   
--   <pre>
--   <a>mapM_</a> ≡ <a>mapMOf_</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>mapMOf_</a> :: <a>Monad</a> m =&gt; <a>Getter</a> s a     -&gt; (a -&gt; m r) -&gt; s -&gt; m ()
--   <a>mapMOf_</a> :: <a>Monad</a> m =&gt; <a>Fold</a> s a       -&gt; (a -&gt; m r) -&gt; s -&gt; m ()
--   <a>mapMOf_</a> :: <a>Monad</a> m =&gt; <a>Lens'</a> s a      -&gt; (a -&gt; m r) -&gt; s -&gt; m ()
--   <a>mapMOf_</a> :: <a>Monad</a> m =&gt; <a>Iso'</a> s a       -&gt; (a -&gt; m r) -&gt; s -&gt; m ()
--   <a>mapMOf_</a> :: <a>Monad</a> m =&gt; <a>Traversal'</a> s a -&gt; (a -&gt; m r) -&gt; s -&gt; m ()
--   <a>mapMOf_</a> :: <a>Monad</a> m =&gt; <a>Prism'</a> s a     -&gt; (a -&gt; m r) -&gt; s -&gt; m ()
--   </pre>
mapMOf_ :: (Profunctor p, Monad m) => Accessing p (Sequenced r m) s a -> p a (m r) -> s -> m ()

-- | <a>forMOf_</a> is <a>mapMOf_</a> with two of its arguments flipped.
--   
--   <pre>
--   &gt;&gt;&gt; forMOf_ both ("hello","world") putStrLn
--   hello
--   world
--   </pre>
--   
--   <pre>
--   <a>forM_</a> ≡ <a>forMOf_</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>forMOf_</a> :: <a>Monad</a> m =&gt; <a>Getter</a> s a     -&gt; s -&gt; (a -&gt; m r) -&gt; m ()
--   <a>forMOf_</a> :: <a>Monad</a> m =&gt; <a>Fold</a> s a       -&gt; s -&gt; (a -&gt; m r) -&gt; m ()
--   <a>forMOf_</a> :: <a>Monad</a> m =&gt; <a>Lens'</a> s a      -&gt; s -&gt; (a -&gt; m r) -&gt; m ()
--   <a>forMOf_</a> :: <a>Monad</a> m =&gt; <a>Iso'</a> s a       -&gt; s -&gt; (a -&gt; m r) -&gt; m ()
--   <a>forMOf_</a> :: <a>Monad</a> m =&gt; <a>Traversal'</a> s a -&gt; s -&gt; (a -&gt; m r) -&gt; m ()
--   <a>forMOf_</a> :: <a>Monad</a> m =&gt; <a>Prism'</a> s a     -&gt; s -&gt; (a -&gt; m r) -&gt; m ()
--   </pre>
forMOf_ :: (Profunctor p, Monad m) => Accessing p (Sequenced r m) s a -> s -> p a (m r) -> m ()

-- | Evaluate each monadic action referenced by a <a>Fold</a> on the
--   structure from left to right, and ignore the results.
--   
--   <pre>
--   &gt;&gt;&gt; sequenceOf_ both (putStrLn "hello",putStrLn "world")
--   hello
--   world
--   </pre>
--   
--   <pre>
--   <a>sequence_</a> ≡ <a>sequenceOf_</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>sequenceOf_</a> :: <a>Monad</a> m =&gt; <a>Getter</a> s (m a)     -&gt; s -&gt; m ()
--   <a>sequenceOf_</a> :: <a>Monad</a> m =&gt; <a>Fold</a> s (m a)       -&gt; s -&gt; m ()
--   <a>sequenceOf_</a> :: <a>Monad</a> m =&gt; <a>Lens'</a> s (m a)      -&gt; s -&gt; m ()
--   <a>sequenceOf_</a> :: <a>Monad</a> m =&gt; <a>Iso'</a> s (m a)       -&gt; s -&gt; m ()
--   <a>sequenceOf_</a> :: <a>Monad</a> m =&gt; <a>Traversal'</a> s (m a) -&gt; s -&gt; m ()
--   <a>sequenceOf_</a> :: <a>Monad</a> m =&gt; <a>Prism'</a> s (m a)     -&gt; s -&gt; m ()
--   </pre>
sequenceOf_ :: Monad m => Getting (Sequenced a m) s (m a) -> s -> m ()

-- | The sum of a collection of actions, generalizing <a>concatOf</a>.
--   
--   <pre>
--   &gt;&gt;&gt; asumOf both ("hello","world")
--   "helloworld"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; asumOf each (Nothing, Just "hello", Nothing)
--   Just "hello"
--   </pre>
--   
--   <pre>
--   <a>asum</a> ≡ <a>asumOf</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>asumOf</a> :: <a>Alternative</a> f =&gt; <a>Getter</a> s (f a)     -&gt; s -&gt; f a
--   <a>asumOf</a> :: <a>Alternative</a> f =&gt; <a>Fold</a> s (f a)       -&gt; s -&gt; f a
--   <a>asumOf</a> :: <a>Alternative</a> f =&gt; <a>Lens'</a> s (f a)      -&gt; s -&gt; f a
--   <a>asumOf</a> :: <a>Alternative</a> f =&gt; <a>Iso'</a> s (f a)       -&gt; s -&gt; f a
--   <a>asumOf</a> :: <a>Alternative</a> f =&gt; <a>Traversal'</a> s (f a) -&gt; s -&gt; f a
--   <a>asumOf</a> :: <a>Alternative</a> f =&gt; <a>Prism'</a> s (f a)     -&gt; s -&gt; f a
--   </pre>
asumOf :: Alternative f => Getting (Endo (f a)) s (f a) -> s -> f a

-- | The sum of a collection of actions, generalizing <a>concatOf</a>.
--   
--   <pre>
--   &gt;&gt;&gt; msumOf both ("hello","world")
--   "helloworld"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; msumOf each (Nothing, Just "hello", Nothing)
--   Just "hello"
--   </pre>
--   
--   <pre>
--   <a>msum</a> ≡ <a>msumOf</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>msumOf</a> :: <a>MonadPlus</a> m =&gt; <a>Getter</a> s (m a)     -&gt; s -&gt; m a
--   <a>msumOf</a> :: <a>MonadPlus</a> m =&gt; <a>Fold</a> s (m a)       -&gt; s -&gt; m a
--   <a>msumOf</a> :: <a>MonadPlus</a> m =&gt; <a>Lens'</a> s (m a)      -&gt; s -&gt; m a
--   <a>msumOf</a> :: <a>MonadPlus</a> m =&gt; <a>Iso'</a> s (m a)       -&gt; s -&gt; m a
--   <a>msumOf</a> :: <a>MonadPlus</a> m =&gt; <a>Traversal'</a> s (m a) -&gt; s -&gt; m a
--   <a>msumOf</a> :: <a>MonadPlus</a> m =&gt; <a>Prism'</a> s (m a)     -&gt; s -&gt; m a
--   </pre>
msumOf :: MonadPlus m => Getting (Endo (m a)) s (m a) -> s -> m a

-- | Map a function over all the targets of a <a>Fold</a> of a container
--   and concatenate the resulting lists.
--   
--   <pre>
--   &gt;&gt;&gt; concatMapOf both (\x -&gt; [x, x + 1]) (1,3)
--   [1,2,3,4]
--   </pre>
--   
--   <pre>
--   <a>concatMap</a> ≡ <a>concatMapOf</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>concatMapOf</a> :: <a>Getter</a> s a     -&gt; (a -&gt; [r]) -&gt; s -&gt; [r]
--   <a>concatMapOf</a> :: <a>Fold</a> s a       -&gt; (a -&gt; [r]) -&gt; s -&gt; [r]
--   <a>concatMapOf</a> :: <a>Lens'</a> s a      -&gt; (a -&gt; [r]) -&gt; s -&gt; [r]
--   <a>concatMapOf</a> :: <a>Iso'</a> s a       -&gt; (a -&gt; [r]) -&gt; s -&gt; [r]
--   <a>concatMapOf</a> :: <a>Traversal'</a> s a -&gt; (a -&gt; [r]) -&gt; s -&gt; [r]
--   </pre>
concatMapOf :: Profunctor p => Accessing p [r] s a -> p a [r] -> s -> [r]

-- | Concatenate all of the lists targeted by a <a>Fold</a> into a longer
--   list.
--   
--   <pre>
--   &gt;&gt;&gt; concatOf both ("pan","ama")
--   "panama"
--   </pre>
--   
--   <pre>
--   <a>concat</a> ≡ <a>concatOf</a> <a>folded</a>
--   <a>concatOf</a> ≡ <a>view</a>
--   </pre>
--   
--   <pre>
--   <a>concatOf</a> :: <a>Getter</a> s [r]     -&gt; s -&gt; [r]
--   <a>concatOf</a> :: <a>Fold</a> s [r]       -&gt; s -&gt; [r]
--   <a>concatOf</a> :: <a>Iso'</a> s [r]       -&gt; s -&gt; [r]
--   <a>concatOf</a> :: <a>Lens'</a> s [r]      -&gt; s -&gt; [r]
--   <a>concatOf</a> :: <a>Traversal'</a> s [r] -&gt; s -&gt; [r]
--   </pre>
concatOf :: Getting [r] s [r] -> s -> [r]

-- | Does the element occur anywhere within a given <a>Fold</a> of the
--   structure?
--   
--   <pre>
--   &gt;&gt;&gt; elemOf both "hello" ("hello","world")
--   True
--   </pre>
--   
--   <pre>
--   <a>elem</a> ≡ <a>elemOf</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>elemOf</a> :: <a>Eq</a> a =&gt; <a>Getter</a> s a     -&gt; a -&gt; s -&gt; <a>Bool</a>
--   <a>elemOf</a> :: <a>Eq</a> a =&gt; <a>Fold</a> s a       -&gt; a -&gt; s -&gt; <a>Bool</a>
--   <a>elemOf</a> :: <a>Eq</a> a =&gt; <a>Lens'</a> s a      -&gt; a -&gt; s -&gt; <a>Bool</a>
--   <a>elemOf</a> :: <a>Eq</a> a =&gt; <a>Iso'</a> s a       -&gt; a -&gt; s -&gt; <a>Bool</a>
--   <a>elemOf</a> :: <a>Eq</a> a =&gt; <a>Traversal'</a> s a -&gt; a -&gt; s -&gt; <a>Bool</a>
--   <a>elemOf</a> :: <a>Eq</a> a =&gt; <a>Prism'</a> s a     -&gt; a -&gt; s -&gt; <a>Bool</a>
--   </pre>
elemOf :: Eq a => Getting Any s a -> a -> s -> Bool

-- | Does the element not occur anywhere within a given <a>Fold</a> of the
--   structure?
--   
--   <pre>
--   &gt;&gt;&gt; notElemOf each 'd' ('a','b','c')
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; notElemOf each 'a' ('a','b','c')
--   False
--   </pre>
--   
--   <pre>
--   <a>notElem</a> ≡ <a>notElemOf</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>notElemOf</a> :: <a>Eq</a> a =&gt; <a>Getter</a> s a     -&gt; a -&gt; s -&gt; <a>Bool</a>
--   <a>notElemOf</a> :: <a>Eq</a> a =&gt; <a>Fold</a> s a       -&gt; a -&gt; s -&gt; <a>Bool</a>
--   <a>notElemOf</a> :: <a>Eq</a> a =&gt; <a>Iso'</a> s a       -&gt; a -&gt; s -&gt; <a>Bool</a>
--   <a>notElemOf</a> :: <a>Eq</a> a =&gt; <a>Lens'</a> s a      -&gt; a -&gt; s -&gt; <a>Bool</a>
--   <a>notElemOf</a> :: <a>Eq</a> a =&gt; <a>Traversal'</a> s a -&gt; a -&gt; s -&gt; <a>Bool</a>
--   <a>notElemOf</a> :: <a>Eq</a> a =&gt; <a>Prism'</a> s a     -&gt; a -&gt; s -&gt; <a>Bool</a>
--   </pre>
notElemOf :: Eq a => Getting All s a -> a -> s -> Bool

-- | Calculate the number of targets there are for a <a>Fold</a> in a given
--   container.
--   
--   <i>Note:</i> This can be rather inefficient for large containers and
--   just like <a>length</a>, this will not terminate for infinite folds.
--   
--   <pre>
--   <a>length</a> ≡ <a>lengthOf</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; lengthOf _1 ("hello",())
--   1
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; lengthOf traverse [1..10]
--   10
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; lengthOf (traverse.traverse) [[1,2],[3,4],[5,6]]
--   6
--   </pre>
--   
--   <pre>
--   <a>lengthOf</a> (<a>folded</a> <a>.</a> <a>folded</a>) :: (<a>Foldable</a> f, <a>Foldable</a> g) =&gt; f (g a) -&gt; <a>Int</a>
--   </pre>
--   
--   <pre>
--   <a>lengthOf</a> :: <a>Getter</a> s a     -&gt; s -&gt; <a>Int</a>
--   <a>lengthOf</a> :: <a>Fold</a> s a       -&gt; s -&gt; <a>Int</a>
--   <a>lengthOf</a> :: <a>Lens'</a> s a      -&gt; s -&gt; <a>Int</a>
--   <a>lengthOf</a> :: <a>Iso'</a> s a       -&gt; s -&gt; <a>Int</a>
--   <a>lengthOf</a> :: <a>Traversal'</a> s a -&gt; s -&gt; <a>Int</a>
--   </pre>
lengthOf :: Getting (Endo (Endo Int)) s a -> s -> Int

-- | Returns <a>True</a> if this <a>Fold</a> or <a>Traversal</a> has no
--   targets in the given container.
--   
--   Note: <a>nullOf</a> on a valid <a>Iso</a>, <a>Lens</a> or
--   <a>Getter</a> should always return <a>False</a>.
--   
--   <pre>
--   <a>null</a> ≡ <a>nullOf</a> <a>folded</a>
--   </pre>
--   
--   This may be rather inefficient compared to the <a>null</a> check of
--   many containers.
--   
--   <pre>
--   &gt;&gt;&gt; nullOf _1 (1,2)
--   False
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; nullOf ignored ()
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; nullOf traverse []
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; nullOf (element 20) [1..10]
--   True
--   </pre>
--   
--   <pre>
--   <a>nullOf</a> (<a>folded</a> <a>.</a> <tt>_1</tt> <a>.</a> <a>folded</a>) :: (<a>Foldable</a> f, <a>Foldable</a> g) =&gt; f (g a, b) -&gt; <a>Bool</a>
--   </pre>
--   
--   <pre>
--   <a>nullOf</a> :: <a>Getter</a> s a     -&gt; s -&gt; <a>Bool</a>
--   <a>nullOf</a> :: <a>Fold</a> s a       -&gt; s -&gt; <a>Bool</a>
--   <a>nullOf</a> :: <a>Iso'</a> s a       -&gt; s -&gt; <a>Bool</a>
--   <a>nullOf</a> :: <a>Lens'</a> s a      -&gt; s -&gt; <a>Bool</a>
--   <a>nullOf</a> :: <a>Traversal'</a> s a -&gt; s -&gt; <a>Bool</a>
--   </pre>
nullOf :: Getting All s a -> s -> Bool

-- | Returns <a>True</a> if this <a>Fold</a> or <a>Traversal</a> has any
--   targets in the given container.
--   
--   A more "conversational" alias for this combinator is <a>has</a>.
--   
--   Note: <a>notNullOf</a> on a valid <a>Iso</a>, <a>Lens</a> or
--   <a>Getter</a> should always return <a>True</a>.
--   
--   <pre>
--   <a>null</a> ≡ <a>notNullOf</a> <a>folded</a>
--   </pre>
--   
--   This may be rather inefficient compared to the <tt><a>not</a> <a>.</a>
--   <a>null</a></tt> check of many containers.
--   
--   <pre>
--   &gt;&gt;&gt; notNullOf _1 (1,2)
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; notNullOf traverse [1..10]
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; notNullOf folded []
--   False
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; notNullOf (element 20) [1..10]
--   False
--   </pre>
--   
--   <pre>
--   <a>notNullOf</a> (<a>folded</a> <a>.</a> <tt>_1</tt> <a>.</a> <a>folded</a>) :: (<a>Foldable</a> f, <a>Foldable</a> g) =&gt; f (g a, b) -&gt; <a>Bool</a>
--   </pre>
--   
--   <pre>
--   <a>notNullOf</a> :: <a>Getter</a> s a     -&gt; s -&gt; <a>Bool</a>
--   <a>notNullOf</a> :: <a>Fold</a> s a       -&gt; s -&gt; <a>Bool</a>
--   <a>notNullOf</a> :: <a>Iso'</a> s a       -&gt; s -&gt; <a>Bool</a>
--   <a>notNullOf</a> :: <a>Lens'</a> s a      -&gt; s -&gt; <a>Bool</a>
--   <a>notNullOf</a> :: <a>Traversal'</a> s a -&gt; s -&gt; <a>Bool</a>
--   </pre>
notNullOf :: Getting Any s a -> s -> Bool

-- | Retrieve the <a>First</a> entry of a <a>Fold</a> or <a>Traversal</a>
--   or retrieve <a>Just</a> the result from a <a>Getter</a> or
--   <a>Lens</a>.
--   
--   The answer is computed in a manner that leaks space less than
--   <tt><tt>ala</tt> <a>First</a> <a>.</a> <a>foldMapOf</a></tt> and gives
--   you back access to the outermost <a>Just</a> constructor more quickly,
--   but may have worse constant factors.
--   
--   <pre>
--   &gt;&gt;&gt; firstOf traverse [1..10]
--   Just 1
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; firstOf both (1,2)
--   Just 1
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; firstOf ignored ()
--   Nothing
--   </pre>
--   
--   <pre>
--   <a>firstOf</a> :: <a>Getter</a> s a     -&gt; s -&gt; <a>Maybe</a> a
--   <a>firstOf</a> :: <a>Fold</a> s a       -&gt; s -&gt; <a>Maybe</a> a
--   <a>firstOf</a> :: <a>Lens'</a> s a      -&gt; s -&gt; <a>Maybe</a> a
--   <a>firstOf</a> :: <a>Iso'</a> s a       -&gt; s -&gt; <a>Maybe</a> a
--   <a>firstOf</a> :: <a>Traversal'</a> s a -&gt; s -&gt; <a>Maybe</a> a
--   </pre>
firstOf :: Getting (Leftmost a) s a -> s -> Maybe a

-- | Retrieve the <a>Last</a> entry of a <a>Fold</a> or <a>Traversal</a> or
--   retrieve <a>Just</a> the result from a <a>Getter</a> or <a>Lens</a>.
--   
--   The answer is computed in a manner that leaks space less than
--   <tt><tt>ala</tt> <a>Last</a> <a>.</a> <a>foldMapOf</a></tt> and gives
--   you back access to the outermost <a>Just</a> constructor more quickly,
--   but may have worse constant factors.
--   
--   <pre>
--   &gt;&gt;&gt; lastOf traverse [1..10]
--   Just 10
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; lastOf both (1,2)
--   Just 2
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; lastOf ignored ()
--   Nothing
--   </pre>
--   
--   <pre>
--   <a>lastOf</a> :: <a>Getter</a> s a     -&gt; s -&gt; <a>Maybe</a> a
--   <a>lastOf</a> :: <a>Fold</a> s a       -&gt; s -&gt; <a>Maybe</a> a
--   <a>lastOf</a> :: <a>Lens'</a> s a      -&gt; s -&gt; <a>Maybe</a> a
--   <a>lastOf</a> :: <a>Iso'</a> s a       -&gt; s -&gt; <a>Maybe</a> a
--   <a>lastOf</a> :: <a>Traversal'</a> s a -&gt; s -&gt; <a>Maybe</a> a
--   </pre>
lastOf :: Getting (Rightmost a) s a -> s -> Maybe a

-- | Obtain the maximum element (if any) targeted by a <a>Fold</a> or
--   <a>Traversal</a> safely.
--   
--   Note: <a>maximumOf</a> on a valid <a>Iso</a>, <a>Lens</a> or
--   <a>Getter</a> will always return <a>Just</a> a value.
--   
--   <pre>
--   &gt;&gt;&gt; maximumOf traverse [1..10]
--   Just 10
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; maximumOf traverse []
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; maximumOf (folded.filtered even) [1,4,3,6,7,9,2]
--   Just 6
--   </pre>
--   
--   <pre>
--   <a>maximum</a> ≡ <a>fromMaybe</a> (<a>error</a> "empty") <a>.</a> <a>maximumOf</a> <a>folded</a>
--   </pre>
--   
--   In the interest of efficiency, This operation has semantics more
--   strict than strictly necessary. <tt><a>rmap</a> <a>getMax</a>
--   (<a>foldMapOf</a> l <a>Max</a>)</tt> has lazier semantics but could
--   leak memory.
--   
--   <pre>
--   <a>maximumOf</a> :: <a>Ord</a> a =&gt; <a>Getter</a> s a     -&gt; s -&gt; <a>Maybe</a> a
--   <a>maximumOf</a> :: <a>Ord</a> a =&gt; <a>Fold</a> s a       -&gt; s -&gt; <a>Maybe</a> a
--   <a>maximumOf</a> :: <a>Ord</a> a =&gt; <a>Iso'</a> s a       -&gt; s -&gt; <a>Maybe</a> a
--   <a>maximumOf</a> :: <a>Ord</a> a =&gt; <a>Lens'</a> s a      -&gt; s -&gt; <a>Maybe</a> a
--   <a>maximumOf</a> :: <a>Ord</a> a =&gt; <a>Traversal'</a> s a -&gt; s -&gt; <a>Maybe</a> a
--   </pre>
maximumOf :: Ord a => Getting (Endo (Endo (Maybe a))) s a -> s -> Maybe a

-- | Obtain the minimum element (if any) targeted by a <a>Fold</a> or
--   <a>Traversal</a> safely.
--   
--   Note: <a>minimumOf</a> on a valid <a>Iso</a>, <a>Lens</a> or
--   <a>Getter</a> will always return <a>Just</a> a value.
--   
--   <pre>
--   &gt;&gt;&gt; minimumOf traverse [1..10]
--   Just 1
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; minimumOf traverse []
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; minimumOf (folded.filtered even) [1,4,3,6,7,9,2]
--   Just 2
--   </pre>
--   
--   <pre>
--   <a>minimum</a> ≡ <a>fromMaybe</a> (<a>error</a> "empty") <a>.</a> <a>minimumOf</a> <a>folded</a>
--   </pre>
--   
--   In the interest of efficiency, This operation has semantics more
--   strict than strictly necessary. <tt><a>rmap</a> <a>getMin</a>
--   (<a>foldMapOf</a> l <a>Min</a>)</tt> has lazier semantics but could
--   leak memory.
--   
--   <pre>
--   <a>minimumOf</a> :: <a>Ord</a> a =&gt; <a>Getter</a> s a     -&gt; s -&gt; <a>Maybe</a> a
--   <a>minimumOf</a> :: <a>Ord</a> a =&gt; <a>Fold</a> s a       -&gt; s -&gt; <a>Maybe</a> a
--   <a>minimumOf</a> :: <a>Ord</a> a =&gt; <a>Iso'</a> s a       -&gt; s -&gt; <a>Maybe</a> a
--   <a>minimumOf</a> :: <a>Ord</a> a =&gt; <a>Lens'</a> s a      -&gt; s -&gt; <a>Maybe</a> a
--   <a>minimumOf</a> :: <a>Ord</a> a =&gt; <a>Traversal'</a> s a -&gt; s -&gt; <a>Maybe</a> a
--   </pre>
minimumOf :: Ord a => Getting (Endo (Endo (Maybe a))) s a -> s -> Maybe a

-- | Obtain the maximum element (if any) targeted by a <a>Fold</a>,
--   <a>Traversal</a>, <a>Lens</a>, <a>Iso</a>, or <a>Getter</a> according
--   to a user supplied <a>Ordering</a>.
--   
--   <pre>
--   &gt;&gt;&gt; maximumByOf traverse (compare `on` length) ["mustard","relish","ham"]
--   Just "mustard"
--   </pre>
--   
--   In the interest of efficiency, This operation has semantics more
--   strict than strictly necessary.
--   
--   <pre>
--   <a>maximumBy</a> cmp ≡ <a>fromMaybe</a> (<a>error</a> "empty") <a>.</a> <a>maximumByOf</a> <a>folded</a> cmp
--   </pre>
--   
--   <pre>
--   <a>maximumByOf</a> :: <a>Getter</a> s a     -&gt; (a -&gt; a -&gt; <a>Ordering</a>) -&gt; s -&gt; <a>Maybe</a> a
--   <a>maximumByOf</a> :: <a>Fold</a> s a       -&gt; (a -&gt; a -&gt; <a>Ordering</a>) -&gt; s -&gt; <a>Maybe</a> a
--   <a>maximumByOf</a> :: <a>Iso'</a> s a       -&gt; (a -&gt; a -&gt; <a>Ordering</a>) -&gt; s -&gt; <a>Maybe</a> a
--   <a>maximumByOf</a> :: <a>Lens'</a> s a      -&gt; (a -&gt; a -&gt; <a>Ordering</a>) -&gt; s -&gt; <a>Maybe</a> a
--   <a>maximumByOf</a> :: <a>Traversal'</a> s a -&gt; (a -&gt; a -&gt; <a>Ordering</a>) -&gt; s -&gt; <a>Maybe</a> a
--   </pre>
maximumByOf :: Getting (Endo (Endo (Maybe a))) s a -> (a -> a -> Ordering) -> s -> Maybe a

-- | Obtain the minimum element (if any) targeted by a <a>Fold</a>,
--   <a>Traversal</a>, <a>Lens</a>, <a>Iso</a> or <a>Getter</a> according
--   to a user supplied <a>Ordering</a>.
--   
--   In the interest of efficiency, This operation has semantics more
--   strict than strictly necessary.
--   
--   <pre>
--   &gt;&gt;&gt; minimumByOf traverse (compare `on` length) ["mustard","relish","ham"]
--   Just "ham"
--   </pre>
--   
--   <pre>
--   <a>minimumBy</a> cmp ≡ <a>fromMaybe</a> (<a>error</a> "empty") <a>.</a> <a>minimumByOf</a> <a>folded</a> cmp
--   </pre>
--   
--   <pre>
--   <a>minimumByOf</a> :: <a>Getter</a> s a     -&gt; (a -&gt; a -&gt; <a>Ordering</a>) -&gt; s -&gt; <a>Maybe</a> a
--   <a>minimumByOf</a> :: <a>Fold</a> s a       -&gt; (a -&gt; a -&gt; <a>Ordering</a>) -&gt; s -&gt; <a>Maybe</a> a
--   <a>minimumByOf</a> :: <a>Iso'</a> s a       -&gt; (a -&gt; a -&gt; <a>Ordering</a>) -&gt; s -&gt; <a>Maybe</a> a
--   <a>minimumByOf</a> :: <a>Lens'</a> s a      -&gt; (a -&gt; a -&gt; <a>Ordering</a>) -&gt; s -&gt; <a>Maybe</a> a
--   <a>minimumByOf</a> :: <a>Traversal'</a> s a -&gt; (a -&gt; a -&gt; <a>Ordering</a>) -&gt; s -&gt; <a>Maybe</a> a
--   </pre>
minimumByOf :: Getting (Endo (Endo (Maybe a))) s a -> (a -> a -> Ordering) -> s -> Maybe a

-- | The <a>findOf</a> function takes a <a>Lens</a> (or <a>Getter</a>,
--   <a>Iso</a>, <a>Fold</a>, or <a>Traversal</a>), a predicate and a
--   structure and returns the leftmost element of the structure matching
--   the predicate, or <a>Nothing</a> if there is no such element.
--   
--   <pre>
--   &gt;&gt;&gt; findOf each even (1,3,4,6)
--   Just 4
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; findOf folded even [1,3,5,7]
--   Nothing
--   </pre>
--   
--   <pre>
--   <a>findOf</a> :: <a>Getter</a> s a     -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Maybe</a> a
--   <a>findOf</a> :: <a>Fold</a> s a       -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Maybe</a> a
--   <a>findOf</a> :: <a>Iso'</a> s a       -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Maybe</a> a
--   <a>findOf</a> :: <a>Lens'</a> s a      -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Maybe</a> a
--   <a>findOf</a> :: <a>Traversal'</a> s a -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Maybe</a> a
--   </pre>
--   
--   <pre>
--   <a>find</a> ≡ <a>findOf</a> <a>folded</a>
--   <a>ifindOf</a> l ≡ <a>findOf</a> l <a>.</a> <a>Indexed</a>
--   </pre>
--   
--   A simpler version that didn't permit indexing, would be:
--   
--   <pre>
--   <a>findOf</a> :: <a>Getting</a> (<a>Endo</a> (<a>Maybe</a> a)) s a -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Maybe</a> a
--   <a>findOf</a> l p = <a>foldrOf</a> l (a y -&gt; if p a then <a>Just</a> a else y) <a>Nothing</a>
--   </pre>
findOf :: Conjoined p => Accessing p (Endo (Maybe a)) s a -> p a Bool -> s -> Maybe a

-- | Strictly fold right over the elements of a structure.
--   
--   <pre>
--   <a>foldr'</a> ≡ <a>foldrOf'</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>foldrOf'</a> :: <a>Getter</a> s a     -&gt; (a -&gt; r -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>foldrOf'</a> :: <a>Fold</a> s a       -&gt; (a -&gt; r -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>foldrOf'</a> :: <a>Iso'</a> s a       -&gt; (a -&gt; r -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>foldrOf'</a> :: <a>Lens'</a> s a      -&gt; (a -&gt; r -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>foldrOf'</a> :: <a>Traversal'</a> s a -&gt; (a -&gt; r -&gt; r) -&gt; r -&gt; s -&gt; r
--   </pre>
foldrOf' :: Getting (Dual (Endo (Endo r))) s a -> (a -> r -> r) -> r -> s -> r

-- | Fold over the elements of a structure, associating to the left, but
--   strictly.
--   
--   <pre>
--   <a>foldl'</a> ≡ <a>foldlOf'</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>foldlOf'</a> :: <a>Getter</a> s a     -&gt; (r -&gt; a -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>foldlOf'</a> :: <a>Fold</a> s a       -&gt; (r -&gt; a -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>foldlOf'</a> :: <a>Iso'</a> s a       -&gt; (r -&gt; a -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>foldlOf'</a> :: <a>Lens'</a> s a      -&gt; (r -&gt; a -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>foldlOf'</a> :: <a>Traversal'</a> s a -&gt; (r -&gt; a -&gt; r) -&gt; r -&gt; s -&gt; r
--   </pre>
foldlOf' :: Getting (Endo (Endo r)) s a -> (r -> a -> r) -> r -> s -> r

-- | A variant of <a>foldrOf</a> that has no base case and thus may only be
--   applied to lenses and structures such that the <a>Lens</a> views at
--   least one element of the structure.
--   
--   <pre>
--   &gt;&gt;&gt; foldr1Of each (+) (1,2,3,4)
--   10
--   </pre>
--   
--   <pre>
--   <a>foldr1Of</a> l f ≡ <a>foldr1</a> f <a>.</a> <a>toListOf</a> l
--   <a>foldr1</a> ≡ <a>foldr1Of</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>foldr1Of</a> :: <a>Getter</a> s a     -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; a
--   <a>foldr1Of</a> :: <a>Fold</a> s a       -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; a
--   <a>foldr1Of</a> :: <a>Iso'</a> s a       -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; a
--   <a>foldr1Of</a> :: <a>Lens'</a> s a      -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; a
--   <a>foldr1Of</a> :: <a>Traversal'</a> s a -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; a
--   </pre>
foldr1Of :: Getting (Endo (Maybe a)) s a -> (a -> a -> a) -> s -> a

-- | A variant of <a>foldlOf</a> that has no base case and thus may only be
--   applied to lenses and structures such that the <a>Lens</a> views at
--   least one element of the structure.
--   
--   <pre>
--   &gt;&gt;&gt; foldl1Of each (+) (1,2,3,4)
--   10
--   </pre>
--   
--   <pre>
--   <a>foldl1Of</a> l f ≡ <a>foldl1</a> f <a>.</a> <a>toListOf</a> l
--   <a>foldl1</a> ≡ <a>foldl1Of</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>foldl1Of</a> :: <a>Getter</a> s a     -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; a
--   <a>foldl1Of</a> :: <a>Fold</a> s a       -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; a
--   <a>foldl1Of</a> :: <a>Iso'</a> s a       -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; a
--   <a>foldl1Of</a> :: <a>Lens'</a> s a      -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; a
--   <a>foldl1Of</a> :: <a>Traversal'</a> s a -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; a
--   </pre>
foldl1Of :: Getting (Dual (Endo (Maybe a))) s a -> (a -> a -> a) -> s -> a

-- | A variant of <a>foldrOf'</a> that has no base case and thus may only
--   be applied to folds and structures such that the fold views at least
--   one element of the structure.
--   
--   <pre>
--   <a>foldr1Of</a> l f ≡ <a>foldr1</a> f <a>.</a> <a>toListOf</a> l
--   </pre>
--   
--   <pre>
--   <a>foldr1Of'</a> :: <a>Getter</a> s a     -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; a
--   <a>foldr1Of'</a> :: <a>Fold</a> s a       -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; a
--   <a>foldr1Of'</a> :: <a>Iso'</a> s a       -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; a
--   <a>foldr1Of'</a> :: <a>Lens'</a> s a      -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; a
--   <a>foldr1Of'</a> :: <a>Traversal'</a> s a -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; a
--   </pre>
foldr1Of' :: Getting (Dual (Endo (Endo (Maybe a)))) s a -> (a -> a -> a) -> s -> a

-- | A variant of <a>foldlOf'</a> that has no base case and thus may only
--   be applied to folds and structures such that the fold views at least
--   one element of the structure.
--   
--   <pre>
--   <a>foldl1Of'</a> l f ≡ <a>foldl1'</a> f <a>.</a> <a>toListOf</a> l
--   </pre>
--   
--   <pre>
--   <a>foldl1Of'</a> :: <a>Getter</a> s a     -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; a
--   <a>foldl1Of'</a> :: <a>Fold</a> s a       -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; a
--   <a>foldl1Of'</a> :: <a>Iso'</a> s a       -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; a
--   <a>foldl1Of'</a> :: <a>Lens'</a> s a      -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; a
--   <a>foldl1Of'</a> :: <a>Traversal'</a> s a -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; a
--   </pre>
foldl1Of' :: Getting (Endo (Endo (Maybe a))) s a -> (a -> a -> a) -> s -> a

-- | Monadic fold over the elements of a structure, associating to the
--   right, i.e. from right to left.
--   
--   <pre>
--   <a>foldrM</a> ≡ <a>foldrMOf</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>foldrMOf</a> :: <a>Monad</a> m =&gt; <a>Getter</a> s a     -&gt; (a -&gt; r -&gt; m r) -&gt; r -&gt; s -&gt; m r
--   <a>foldrMOf</a> :: <a>Monad</a> m =&gt; <a>Fold</a> s a       -&gt; (a -&gt; r -&gt; m r) -&gt; r -&gt; s -&gt; m r
--   <a>foldrMOf</a> :: <a>Monad</a> m =&gt; <a>Iso'</a> s a       -&gt; (a -&gt; r -&gt; m r) -&gt; r -&gt; s -&gt; m r
--   <a>foldrMOf</a> :: <a>Monad</a> m =&gt; <a>Lens'</a> s a      -&gt; (a -&gt; r -&gt; m r) -&gt; r -&gt; s -&gt; m r
--   <a>foldrMOf</a> :: <a>Monad</a> m =&gt; <a>Traversal'</a> s a -&gt; (a -&gt; r -&gt; m r) -&gt; r -&gt; s -&gt; m r
--   </pre>
foldrMOf :: Monad m => Getting (Dual (Endo (r -> m r))) s a -> (a -> r -> m r) -> r -> s -> m r

-- | Monadic fold over the elements of a structure, associating to the
--   left, i.e. from left to right.
--   
--   <pre>
--   <a>foldlM</a> ≡ <a>foldlMOf</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>foldlMOf</a> :: <a>Monad</a> m =&gt; <a>Getter</a> s a     -&gt; (r -&gt; a -&gt; m r) -&gt; r -&gt; s -&gt; m r
--   <a>foldlMOf</a> :: <a>Monad</a> m =&gt; <a>Fold</a> s a       -&gt; (r -&gt; a -&gt; m r) -&gt; r -&gt; s -&gt; m r
--   <a>foldlMOf</a> :: <a>Monad</a> m =&gt; <a>Iso'</a> s a       -&gt; (r -&gt; a -&gt; m r) -&gt; r -&gt; s -&gt; m r
--   <a>foldlMOf</a> :: <a>Monad</a> m =&gt; <a>Lens'</a> s a      -&gt; (r -&gt; a -&gt; m r) -&gt; r -&gt; s -&gt; m r
--   <a>foldlMOf</a> :: <a>Monad</a> m =&gt; <a>Traversal'</a> s a -&gt; (r -&gt; a -&gt; m r) -&gt; r -&gt; s -&gt; m r
--   </pre>
foldlMOf :: Monad m => Getting (Endo (r -> m r)) s a -> (r -> a -> m r) -> r -> s -> m r

-- | An infix version of <a>itoListOf</a>.
(^@..) :: s -> IndexedGetting i (Endo [(i, a)]) s a -> [(i, a)]

-- | Perform a safe <a>head</a> (with index) of an <a>IndexedFold</a> or
--   <a>IndexedTraversal</a> or retrieve <a>Just</a> the index and result
--   from an <a>IndexedGetter</a> or <a>IndexedLens</a>.
--   
--   When using a <a>IndexedTraversal</a> as a partial <a>IndexedLens</a>,
--   or an <a>IndexedFold</a> as a partial <a>IndexedGetter</a> this can be
--   a convenient way to extract the optional value.
--   
--   <pre>
--   (<a>^@?</a>) :: s -&gt; <a>IndexedGetter</a> i s a     -&gt; <a>Maybe</a> (i, a)
--   (<a>^@?</a>) :: s -&gt; <a>IndexedFold</a> i s a       -&gt; <a>Maybe</a> (i, a)
--   (<a>^@?</a>) :: s -&gt; <a>IndexedLens'</a> i s a      -&gt; <a>Maybe</a> (i, a)
--   (<a>^@?</a>) :: s -&gt; <a>IndexedTraversal'</a> i s a -&gt; <a>Maybe</a> (i, a)
--   </pre>
(^@?) :: s -> IndexedGetting i (Endo (Maybe (i, a))) s a -> Maybe (i, a)

-- | Perform an *UNSAFE* <a>head</a> (with index) of an <a>IndexedFold</a>
--   or <a>IndexedTraversal</a> assuming that it is there.
--   
--   <pre>
--   (<a>^@?!</a>) :: s -&gt; <a>IndexedGetter</a> i s a     -&gt; (i, a)
--   (<a>^@?!</a>) :: s -&gt; <a>IndexedFold</a> i s a       -&gt; (i, a)
--   (<a>^@?!</a>) :: s -&gt; <a>IndexedLens'</a> i s a      -&gt; (i, a)
--   (<a>^@?!</a>) :: s -&gt; <a>IndexedTraversal'</a> i s a -&gt; (i, a)
--   </pre>
(^@?!) :: s -> IndexedGetting i (Endo (i, a)) s a -> (i, a)

-- | Fold an <a>IndexedFold</a> or <a>IndexedTraversal</a> by mapping
--   indices and values to an arbitrary <a>Monoid</a> with access to the
--   <tt>i</tt>.
--   
--   When you don't need access to the index then <a>foldMapOf</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>foldMapOf</a> l ≡ <a>ifoldMapOf</a> l <a>.</a> <a>const</a>
--   </pre>
--   
--   <pre>
--   <a>ifoldMapOf</a> ::             <a>IndexedGetter</a> i s a     -&gt; (i -&gt; a -&gt; m) -&gt; s -&gt; m
--   <a>ifoldMapOf</a> :: <a>Monoid</a> m =&gt; <a>IndexedFold</a> i s a       -&gt; (i -&gt; a -&gt; m) -&gt; s -&gt; m
--   <a>ifoldMapOf</a> ::             <a>IndexedLens'</a> i s a      -&gt; (i -&gt; a -&gt; m) -&gt; s -&gt; m
--   <a>ifoldMapOf</a> :: <a>Monoid</a> m =&gt; <a>IndexedTraversal'</a> i s a -&gt; (i -&gt; a -&gt; m) -&gt; s -&gt; m
--   </pre>
ifoldMapOf :: IndexedGetting i m s a -> (i -> a -> m) -> s -> m

-- | Right-associative fold of parts of a structure that are viewed through
--   an <a>IndexedFold</a> or <a>IndexedTraversal</a> with access to the
--   <tt>i</tt>.
--   
--   When you don't need access to the index then <a>foldrOf</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>foldrOf</a> l ≡ <a>ifoldrOf</a> l <a>.</a> <a>const</a>
--   </pre>
--   
--   <pre>
--   <a>ifoldrOf</a> :: <a>IndexedGetter</a> i s a     -&gt; (i -&gt; a -&gt; r -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>ifoldrOf</a> :: <a>IndexedFold</a> i s a       -&gt; (i -&gt; a -&gt; r -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>ifoldrOf</a> :: <a>IndexedLens'</a> i s a      -&gt; (i -&gt; a -&gt; r -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>ifoldrOf</a> :: <a>IndexedTraversal'</a> i s a -&gt; (i -&gt; a -&gt; r -&gt; r) -&gt; r -&gt; s -&gt; r
--   </pre>
ifoldrOf :: IndexedGetting i (Endo r) s a -> (i -> a -> r -> r) -> r -> s -> r

-- | Left-associative fold of the parts of a structure that are viewed
--   through an <a>IndexedFold</a> or <a>IndexedTraversal</a> with access
--   to the <tt>i</tt>.
--   
--   When you don't need access to the index then <a>foldlOf</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>foldlOf</a> l ≡ <a>ifoldlOf</a> l <a>.</a> <a>const</a>
--   </pre>
--   
--   <pre>
--   <a>ifoldlOf</a> :: <a>IndexedGetter</a> i s a     -&gt; (i -&gt; r -&gt; a -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>ifoldlOf</a> :: <a>IndexedFold</a> i s a       -&gt; (i -&gt; r -&gt; a -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>ifoldlOf</a> :: <a>IndexedLens'</a> i s a      -&gt; (i -&gt; r -&gt; a -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>ifoldlOf</a> :: <a>IndexedTraversal'</a> i s a -&gt; (i -&gt; r -&gt; a -&gt; r) -&gt; r -&gt; s -&gt; r
--   </pre>
ifoldlOf :: IndexedGetting i (Dual (Endo r)) s a -> (i -> r -> a -> r) -> r -> s -> r

-- | Return whether or not any element viewed through an <a>IndexedFold</a>
--   or <a>IndexedTraversal</a> satisfy a predicate, with access to the
--   <tt>i</tt>.
--   
--   When you don't need access to the index then <a>anyOf</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>anyOf</a> l ≡ <a>ianyOf</a> l <a>.</a> <a>const</a>
--   </pre>
--   
--   <pre>
--   <a>ianyOf</a> :: <a>IndexedGetter</a> i s a     -&gt; (i -&gt; a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>ianyOf</a> :: <a>IndexedFold</a> i s a       -&gt; (i -&gt; a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>ianyOf</a> :: <a>IndexedLens'</a> i s a      -&gt; (i -&gt; a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>ianyOf</a> :: <a>IndexedTraversal'</a> i s a -&gt; (i -&gt; a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   </pre>
ianyOf :: IndexedGetting i Any s a -> (i -> a -> Bool) -> s -> Bool

-- | Return whether or not all elements viewed through an
--   <a>IndexedFold</a> or <a>IndexedTraversal</a> satisfy a predicate,
--   with access to the <tt>i</tt>.
--   
--   When you don't need access to the index then <a>allOf</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>allOf</a> l ≡ <a>iallOf</a> l <a>.</a> <a>const</a>
--   </pre>
--   
--   <pre>
--   <a>iallOf</a> :: <a>IndexedGetter</a> i s a     -&gt; (i -&gt; a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>iallOf</a> :: <a>IndexedFold</a> i s a       -&gt; (i -&gt; a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>iallOf</a> :: <a>IndexedLens'</a> i s a      -&gt; (i -&gt; a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>iallOf</a> :: <a>IndexedTraversal'</a> i s a -&gt; (i -&gt; a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   </pre>
iallOf :: IndexedGetting i All s a -> (i -> a -> Bool) -> s -> Bool

-- | Traverse the targets of an <a>IndexedFold</a> or
--   <a>IndexedTraversal</a> with access to the <tt>i</tt>, discarding the
--   results.
--   
--   When you don't need access to the index then <a>traverseOf_</a> is
--   more flexible in what it accepts.
--   
--   <pre>
--   <a>traverseOf_</a> l ≡ <a>itraverseOf</a> l <a>.</a> <a>const</a>
--   </pre>
--   
--   <pre>
--   <a>itraverseOf_</a> :: <a>Functor</a> f     =&gt; <a>IndexedGetter</a> i s a     -&gt; (i -&gt; a -&gt; f r) -&gt; s -&gt; f ()
--   <a>itraverseOf_</a> :: <a>Applicative</a> f =&gt; <a>IndexedFold</a> i s a       -&gt; (i -&gt; a -&gt; f r) -&gt; s -&gt; f ()
--   <a>itraverseOf_</a> :: <a>Functor</a> f     =&gt; <a>IndexedLens'</a> i s a      -&gt; (i -&gt; a -&gt; f r) -&gt; s -&gt; f ()
--   <a>itraverseOf_</a> :: <a>Applicative</a> f =&gt; <a>IndexedTraversal'</a> i s a -&gt; (i -&gt; a -&gt; f r) -&gt; s -&gt; f ()
--   </pre>
itraverseOf_ :: Functor f => IndexedGetting i (Traversed r f) s a -> (i -> a -> f r) -> s -> f ()

-- | Traverse the targets of an <a>IndexedFold</a> or
--   <a>IndexedTraversal</a> with access to the index, discarding the
--   results (with the arguments flipped).
--   
--   <pre>
--   <a>iforOf_</a> ≡ <a>flip</a> <a>.</a> <a>itraverseOf_</a>
--   </pre>
--   
--   When you don't need access to the index then <a>forOf_</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>forOf_</a> l a ≡ <a>iforOf_</a> l a <a>.</a> <a>const</a>
--   </pre>
--   
--   <pre>
--   <a>iforOf_</a> :: <a>Functor</a> f     =&gt; <a>IndexedGetter</a> i s a     -&gt; s -&gt; (i -&gt; a -&gt; f r) -&gt; f ()
--   <a>iforOf_</a> :: <a>Applicative</a> f =&gt; <a>IndexedFold</a> i s a       -&gt; s -&gt; (i -&gt; a -&gt; f r) -&gt; f ()
--   <a>iforOf_</a> :: <a>Functor</a> f     =&gt; <a>IndexedLens'</a> i s a      -&gt; s -&gt; (i -&gt; a -&gt; f r) -&gt; f ()
--   <a>iforOf_</a> :: <a>Applicative</a> f =&gt; <a>IndexedTraversal'</a> i s a -&gt; s -&gt; (i -&gt; a -&gt; f r) -&gt; f ()
--   </pre>
iforOf_ :: Functor f => IndexedGetting i (Traversed r f) s a -> s -> (i -> a -> f r) -> f ()

-- | Run monadic actions for each target of an <a>IndexedFold</a> or
--   <a>IndexedTraversal</a> with access to the index, discarding the
--   results.
--   
--   When you don't need access to the index then <a>mapMOf_</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>mapMOf_</a> l ≡ <a>imapMOf</a> l <a>.</a> <a>const</a>
--   </pre>
--   
--   <pre>
--   <a>imapMOf_</a> :: <a>Monad</a> m =&gt; <a>IndexedGetter</a> i s a     -&gt; (i -&gt; a -&gt; m r) -&gt; s -&gt; m ()
--   <a>imapMOf_</a> :: <a>Monad</a> m =&gt; <a>IndexedFold</a> i s a       -&gt; (i -&gt; a -&gt; m r) -&gt; s -&gt; m ()
--   <a>imapMOf_</a> :: <a>Monad</a> m =&gt; <a>IndexedLens'</a> i s a      -&gt; (i -&gt; a -&gt; m r) -&gt; s -&gt; m ()
--   <a>imapMOf_</a> :: <a>Monad</a> m =&gt; <a>IndexedTraversal'</a> i s a -&gt; (i -&gt; a -&gt; m r) -&gt; s -&gt; m ()
--   </pre>
imapMOf_ :: Monad m => IndexedGetting i (Sequenced r m) s a -> (i -> a -> m r) -> s -> m ()

-- | Run monadic actions for each target of an <a>IndexedFold</a> or
--   <a>IndexedTraversal</a> with access to the index, discarding the
--   results (with the arguments flipped).
--   
--   <pre>
--   <a>iforMOf_</a> ≡ <a>flip</a> <a>.</a> <a>imapMOf_</a>
--   </pre>
--   
--   When you don't need access to the index then <a>forMOf_</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>forMOf_</a> l a ≡ <a>iforMOf</a> l a <a>.</a> <a>const</a>
--   </pre>
--   
--   <pre>
--   <a>iforMOf_</a> :: <a>Monad</a> m =&gt; <a>IndexedGetter</a> i s a     -&gt; s -&gt; (i -&gt; a -&gt; m r) -&gt; m ()
--   <a>iforMOf_</a> :: <a>Monad</a> m =&gt; <a>IndexedFold</a> i s a       -&gt; s -&gt; (i -&gt; a -&gt; m r) -&gt; m ()
--   <a>iforMOf_</a> :: <a>Monad</a> m =&gt; <a>IndexedLens'</a> i s a      -&gt; s -&gt; (i -&gt; a -&gt; m r) -&gt; m ()
--   <a>iforMOf_</a> :: <a>Monad</a> m =&gt; <a>IndexedTraversal'</a> i s a -&gt; s -&gt; (i -&gt; a -&gt; m r) -&gt; m ()
--   </pre>
iforMOf_ :: Monad m => IndexedGetting i (Sequenced r m) s a -> s -> (i -> a -> m r) -> m ()

-- | Concatenate the results of a function of the elements of an
--   <a>IndexedFold</a> or <a>IndexedTraversal</a> with access to the
--   index.
--   
--   When you don't need access to the index then <a>concatMapOf</a> is
--   more flexible in what it accepts.
--   
--   <pre>
--   <a>concatMapOf</a> l ≡ <a>iconcatMapOf</a> l <a>.</a> <a>const</a>
--   <a>iconcatMapOf</a> ≡ <a>ifoldMapOf</a>
--   </pre>
--   
--   <pre>
--   <a>iconcatMapOf</a> :: <a>IndexedGetter</a> i s a     -&gt; (i -&gt; a -&gt; [r]) -&gt; s -&gt; [r]
--   <a>iconcatMapOf</a> :: <a>IndexedFold</a> i s a       -&gt; (i -&gt; a -&gt; [r]) -&gt; s -&gt; [r]
--   <a>iconcatMapOf</a> :: <a>IndexedLens'</a> i s a      -&gt; (i -&gt; a -&gt; [r]) -&gt; s -&gt; [r]
--   <a>iconcatMapOf</a> :: <a>IndexedTraversal'</a> i s a -&gt; (i -&gt; a -&gt; [r]) -&gt; s -&gt; [r]
--   </pre>
iconcatMapOf :: IndexedGetting i [r] s a -> (i -> a -> [r]) -> s -> [r]

-- | The <a>findOf</a> function takes an <a>IndexedFold</a> or
--   <a>IndexedTraversal</a>, a predicate that is also supplied the index,
--   a structure and returns the left-most element of the structure
--   matching the predicate, or <a>Nothing</a> if there is no such element.
--   
--   When you don't need access to the index then <a>findOf</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>findOf</a> l ≡ <a>ifindOf</a> l <a>.</a> <a>const</a>
--   </pre>
--   
--   <pre>
--   <a>ifindOf</a> :: <a>IndexedGetter</a> i s a     -&gt; (i -&gt; a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Maybe</a> a
--   <a>ifindOf</a> :: <a>IndexedFold</a> i s a       -&gt; (i -&gt; a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Maybe</a> a
--   <a>ifindOf</a> :: <a>IndexedLens'</a> i s a      -&gt; (i -&gt; a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Maybe</a> a
--   <a>ifindOf</a> :: <a>IndexedTraversal'</a> i s a -&gt; (i -&gt; a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Maybe</a> a
--   </pre>
ifindOf :: IndexedGetting i (Endo (Maybe a)) s a -> (i -> a -> Bool) -> s -> Maybe a

-- | <i>Strictly</i> fold right over the elements of a structure with an
--   index.
--   
--   When you don't need access to the index then <a>foldrOf'</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>foldrOf'</a> l ≡ <a>ifoldrOf'</a> l <a>.</a> <a>const</a>
--   </pre>
--   
--   <pre>
--   <a>ifoldrOf'</a> :: <a>IndexedGetter</a> i s a     -&gt; (i -&gt; a -&gt; r -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>ifoldrOf'</a> :: <a>IndexedFold</a> i s a       -&gt; (i -&gt; a -&gt; r -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>ifoldrOf'</a> :: <a>IndexedLens'</a> i s a      -&gt; (i -&gt; a -&gt; r -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>ifoldrOf'</a> :: <a>IndexedTraversal'</a> i s a -&gt; (i -&gt; a -&gt; r -&gt; r) -&gt; r -&gt; s -&gt; r
--   </pre>
ifoldrOf' :: IndexedGetting i (Dual (Endo (r -> r))) s a -> (i -> a -> r -> r) -> r -> s -> r

-- | Fold over the elements of a structure with an index, associating to
--   the left, but <i>strictly</i>.
--   
--   When you don't need access to the index then <a>foldlOf'</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>foldlOf'</a> l ≡ <a>ifoldlOf'</a> l <a>.</a> <a>const</a>
--   </pre>
--   
--   <pre>
--   <a>ifoldlOf'</a> :: <a>IndexedGetter</a> i s a       -&gt; (i -&gt; r -&gt; a -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>ifoldlOf'</a> :: <a>IndexedFold</a> i s a         -&gt; (i -&gt; r -&gt; a -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>ifoldlOf'</a> :: <a>IndexedLens'</a> i s a        -&gt; (i -&gt; r -&gt; a -&gt; r) -&gt; r -&gt; s -&gt; r
--   <a>ifoldlOf'</a> :: <a>IndexedTraversal'</a> i s a   -&gt; (i -&gt; r -&gt; a -&gt; r) -&gt; r -&gt; s -&gt; r
--   </pre>
ifoldlOf' :: IndexedGetting i (Endo (r -> r)) s a -> (i -> r -> a -> r) -> r -> s -> r

-- | Monadic fold right over the elements of a structure with an index.
--   
--   When you don't need access to the index then <a>foldrMOf</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>foldrMOf</a> l ≡ <a>ifoldrMOf</a> l <a>.</a> <a>const</a>
--   </pre>
--   
--   <pre>
--   <a>ifoldrMOf</a> :: <a>Monad</a> m =&gt; <a>IndexedGetter</a> i s a     -&gt; (i -&gt; a -&gt; r -&gt; m r) -&gt; r -&gt; s -&gt; m r
--   <a>ifoldrMOf</a> :: <a>Monad</a> m =&gt; <a>IndexedFold</a> i s a       -&gt; (i -&gt; a -&gt; r -&gt; m r) -&gt; r -&gt; s -&gt; m r
--   <a>ifoldrMOf</a> :: <a>Monad</a> m =&gt; <a>IndexedLens'</a> i s a      -&gt; (i -&gt; a -&gt; r -&gt; m r) -&gt; r -&gt; s -&gt; m r
--   <a>ifoldrMOf</a> :: <a>Monad</a> m =&gt; <a>IndexedTraversal'</a> i s a -&gt; (i -&gt; a -&gt; r -&gt; m r) -&gt; r -&gt; s -&gt; m r
--   </pre>
ifoldrMOf :: Monad m => IndexedGetting i (Dual (Endo (r -> m r))) s a -> (i -> a -> r -> m r) -> r -> s -> m r

-- | Monadic fold over the elements of a structure with an index,
--   associating to the left.
--   
--   When you don't need access to the index then <a>foldlMOf</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>foldlMOf</a> l ≡ <a>ifoldlMOf</a> l <a>.</a> <a>const</a>
--   </pre>
--   
--   <pre>
--   <a>ifoldlMOf</a> :: <a>Monad</a> m =&gt; <a>IndexedGetter</a> i s a     -&gt; (i -&gt; r -&gt; a -&gt; m r) -&gt; r -&gt; s -&gt; m r
--   <a>ifoldlMOf</a> :: <a>Monad</a> m =&gt; <a>IndexedFold</a> i s a       -&gt; (i -&gt; r -&gt; a -&gt; m r) -&gt; r -&gt; s -&gt; m r
--   <a>ifoldlMOf</a> :: <a>Monad</a> m =&gt; <a>IndexedLens'</a> i s a      -&gt; (i -&gt; r -&gt; a -&gt; m r) -&gt; r -&gt; s -&gt; m r
--   <a>ifoldlMOf</a> :: <a>Monad</a> m =&gt; <a>IndexedTraversal'</a> i s a -&gt; (i -&gt; r -&gt; a -&gt; m r) -&gt; r -&gt; s -&gt; m r
--   </pre>
ifoldlMOf :: Monad m => IndexedGetting i (Endo (r -> m r)) s a -> (i -> r -> a -> m r) -> r -> s -> m r

-- | Extract the key-value pairs from a structure.
--   
--   When you don't need access to the indices in the result, then
--   <a>toListOf</a> is more flexible in what it accepts.
--   
--   <pre>
--   <a>toListOf</a> l ≡ <a>map</a> <a>fst</a> <a>.</a> <a>itoListOf</a> l
--   </pre>
--   
--   <pre>
--   <a>itoListOf</a> :: <a>IndexedGetter</a> i s a     -&gt; s -&gt; [(i,a)]
--   <a>itoListOf</a> :: <a>IndexedFold</a> i s a       -&gt; s -&gt; [(i,a)]
--   <a>itoListOf</a> :: <a>IndexedLens'</a> i s a      -&gt; s -&gt; [(i,a)]
--   <a>itoListOf</a> :: <a>IndexedTraversal'</a> i s a -&gt; s -&gt; [(i,a)]
--   </pre>
itoListOf :: IndexedGetting i (Endo [(i, a)]) s a -> s -> [(i, a)]

-- | Filter an <a>IndexedFold</a> or <a>IndexedGetter</a>, obtaining an
--   <a>IndexedFold</a>.
--   
--   <pre>
--   &gt;&gt;&gt; [0,0,0,5,5,5]^..traversed.ifiltered (\i a -&gt; i &lt;= a)
--   [0,5,5,5]
--   </pre>
--   
--   Compose with <a>filtered</a> to filter another <a>IndexedLens</a>,
--   <tt>IndexedIso</tt>, <a>IndexedGetter</a>, <a>IndexedFold</a> (or
--   <a>IndexedTraversal</a>) with access to both the value and the index.
--   
--   Note: As with <a>filtered</a>, this is <i>not</i> a legal
--   <a>IndexedTraversal</a>, unless you are very careful not to invalidate
--   the predicate on the target!
ifiltered :: (Indexable i p, Applicative f) => (i -> a -> Bool) -> Overloading' p (Indexed i) f a a

-- | Obtain an <a>IndexedFold</a> by taking elements from another
--   <a>IndexedFold</a>, <a>IndexedLens</a>, <a>IndexedGetter</a> or
--   <a>IndexedTraversal</a> while a predicate holds.
--   
--   <pre>
--   <a>itakingWhile</a> :: (i -&gt; a -&gt; <a>Bool</a>) -&gt; <a>IndexedFold</a> i s a          -&gt; <a>IndexedFold</a> i s a
--   <a>itakingWhile</a> :: (i -&gt; a -&gt; <a>Bool</a>) -&gt; <a>IndexedTraversal'</a> i s a    -&gt; <a>IndexedFold</a> i s a
--   <a>itakingWhile</a> :: (i -&gt; a -&gt; <a>Bool</a>) -&gt; <a>IndexedLens'</a> i s a         -&gt; <a>IndexedFold</a> i s a
--   <a>itakingWhile</a> :: (i -&gt; a -&gt; <a>Bool</a>) -&gt; <a>IndexedGetter</a> i s a        -&gt; <a>IndexedFold</a> i s a
--   <a>itakingWhile</a> :: (i -&gt; a -&gt; <a>Bool</a>) -&gt; <a>IndexedMonadicFold</a> i m s a -&gt; <a>IndexedMonadicFold</a> i m s a
--   <a>itakingWhile</a> :: (i -&gt; a -&gt; <a>Bool</a>) -&gt; <a>IndexedAction</a> i m s a      -&gt; <a>IndexedMonadicFold</a> i m s a
--   </pre>
itakingWhile :: (Indexable i p, Profunctor q, Contravariant f, Applicative f) => (i -> a -> Bool) -> Overloading (Indexed i) q (Accessor (Endo (f s))) s s a a -> Overloading p q f s s a a

-- | Obtain an <a>IndexedFold</a> by dropping elements from another
--   <a>IndexedFold</a>, <a>IndexedLens</a>, <a>IndexedGetter</a> or
--   <a>IndexedTraversal</a> while a predicate holds.
--   
--   <pre>
--   <a>idroppingWhile</a> :: (i -&gt; a -&gt; <a>Bool</a>) -&gt; <a>IndexedFold</a> i s a          -&gt; <a>IndexedFold</a> i s a
--   <a>idroppingWhile</a> :: (i -&gt; a -&gt; <a>Bool</a>) -&gt; <a>IndexedTraversal'</a> i s a    -&gt; <a>IndexedFold</a> i s a -- see notes
--   <a>idroppingWhile</a> :: (i -&gt; a -&gt; <a>Bool</a>) -&gt; <a>IndexedLens'</a> i s a         -&gt; <a>IndexedFold</a> i s a -- see notes
--   <a>idroppingWhile</a> :: (i -&gt; a -&gt; <a>Bool</a>) -&gt; <a>IndexedGetter</a> i s a        -&gt; <a>IndexedFold</a> i s a
--   <a>idroppingWhile</a> :: (i -&gt; a -&gt; <a>Bool</a>) -&gt; <a>IndexedMonadicFold</a> i m s a -&gt; <a>IndexedMonadicFold</a> i m s a
--   <a>idroppingWhile</a> :: (i -&gt; a -&gt; <a>Bool</a>) -&gt; <a>IndexedAction</a> i m s a      -&gt; <a>IndexedMonadicFold</a> i m s a
--   </pre>
--   
--   Applying <a>idroppingWhile</a> to an <a>IndexedLens</a> or
--   <a>IndexedTraversal</a> will still allow you to use it as a
--   pseudo-<a>IndexedTraversal</a>, but if you change the value of the
--   targets to ones where the predicate returns <a>True</a>, then you will
--   break the <a>Traversal</a> laws and <a>Traversal</a> fusion will no
--   longer be sound.
idroppingWhile :: (Indexable i p, Profunctor q, Applicative f) => (i -> a -> Bool) -> Overloading (Indexed i) q (Compose (State Bool) f) s t a a -> Overloading p q f s t a a

-- | A deprecated alias for <a>firstOf</a>.

-- | <i>Deprecated: <a>headOf</a> will be removed after GHC 7.8 is
--   released. (Use <a>preview</a> or <a>firstOf</a>) </i>
headOf :: Getting (First a) s a -> s -> Maybe a

-- | Used for <a>preview</a>.
data Leftmost a

-- | Used for <a>lastOf</a>.
data Rightmost a

-- | Used internally by <a>traverseOf_</a> and the like.
--   
--   The argument <tt>a</tt> of the result should not be used!
data Traversed a f

-- | Used internally by <a>mapM_</a> and the like.
--   
--   The argument <tt>a</tt> of the result should not be used!
data Sequenced a m


-- | This module uses dirty tricks to generate a <a>Handler</a> from an
--   arbitrary <a>Fold</a>.
module Control.Lens.Internal.Exception

-- | Both <tt>MonadCatchIO-transformers</tt> and <a>Control.Exception</a>
--   provide a <a>Handler</a> type.
--   
--   This lets us write combinators to build handlers that are agnostic
--   about the choice of which of these they use.
class Handleable e (m :: * -> *) (h :: * -> *) | h -> e m where handler_ l = handler l . const
handler :: Handleable e m h => Getting (First a) e a -> (a -> m r) -> h r
handler_ :: Handleable e m h => Getting (First a) e a -> m r -> h r

-- | There was an <a>Exception</a> caused by abusing the internals of a
--   <a>Handler</a>.
data HandlingException
HandlingException :: HandlingException
instance Typeable HandlingException
instance Show HandlingException
instance Reifies s (SomeException -> Maybe a) => Exception (Handling a s m)
instance Show (Handling a s m)
instance Typeable (Handling a s m)
instance Exception HandlingException
instance Handleable SomeException m (Handler m)
instance Handleable SomeException IO Handler


-- | These are general purpose combinators that provide utility for
--   non-lens code
module Control.Lens.Combinators

-- | Passes the result of the left side to the function on the right side
--   (forward pipe operator).
--   
--   This is the flipped version of (<a>$</a>), which is more common in
--   languages like F# as (<tt>|&gt;</tt>) where it is needed for
--   inference. Here it is supplied for notational convenience and given a
--   precedence that allows it to be nested inside uses of (<a>$</a>).
--   
--   <pre>
--   &gt;&gt;&gt; a &amp; f
--   f a
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "hello" &amp; length &amp; succ
--   6
--   </pre>
--   
--   This combinator is commonly used when applying multiple <a>Lens</a>
--   operations in sequence.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world") &amp; _1.element 0 .~ 'j' &amp; _1.element 4 .~ 'y'
--   ("jelly","world")
--   </pre>
--   
--   This reads somewhat similar to:
--   
--   <pre>
--   &gt;&gt;&gt; flip execState ("hello","world") $ do _1.element 0 .= 'j'; _1.element 4 .= 'y'
--   ("jelly","world")
--   </pre>
(&) :: a -> (a -> b) -> b

-- | Infix flipped <a>fmap</a>.
--   
--   <pre>
--   (<a>&lt;&amp;&gt;</a>) = <a>flip</a> <a>fmap</a>
--   </pre>
(<&>) :: Functor f => f a -> (a -> b) -> f b

-- | This is convenient to <a>flip</a> argument order of composite
--   functions.
--   
--   <pre>
--   &gt;&gt;&gt; over _2 ?? ("hello","world") $ length
--   ("hello",5)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over ?? length ?? ("hello","world") $ _2
--   ("hello",5)
--   </pre>
(??) :: Functor f => f (a -> b) -> a -> f b


-- | A <tt><a>Lens</a> s t a b</tt> is a purely functional reference.
--   
--   While a <a>Traversal</a> could be used for <a>Getting</a> like a valid
--   <a>Fold</a>, it wasn't a valid <a>Getter</a> as <a>Applicative</a>
--   wasn't a superclass of <a>Gettable</a>.
--   
--   <a>Functor</a>, however is the superclass of both.
--   
--   <pre>
--   type <a>Lens</a> s t a b = forall f. <a>Functor</a> f =&gt; (a -&gt; f b) -&gt; s -&gt; f t
--   </pre>
--   
--   Every <a>Lens</a> is a valid <a>Setter</a>.
--   
--   Every <a>Lens</a> can be used for <a>Getting</a> like a <a>Fold</a>
--   that doesn't use the <a>Applicative</a> or <a>Gettable</a>.
--   
--   Every <a>Lens</a> is a valid <a>Traversal</a> that only uses the
--   <a>Functor</a> part of the <a>Applicative</a> it is supplied.
--   
--   Every <a>Lens</a> can be used for <a>Getting</a> like a valid
--   <a>Getter</a>, since <a>Functor</a> is a superclass of
--   <a>Gettable</a>.
--   
--   Since every <a>Lens</a> can be used for <a>Getting</a> like a valid
--   <a>Getter</a> it follows that it must view exactly one element in the
--   structure.
--   
--   The <a>Lens</a> laws follow from this property and the desire for it
--   to act like a <a>Traversable</a> when used as a <a>Traversal</a>.
--   
--   In the examples below, <tt>getter</tt> and <tt>setter</tt> are
--   supplied as example getters and setters, and are not actual functions
--   supplied by this package.
module Control.Lens.Lens

-- | A <a>Lens</a> is actually a lens family as described in
--   <a>http://comonad.com/reader/2012/mirrored-lenses/</a>.
--   
--   With great power comes great responsibility and a <a>Lens</a> is
--   subject to the three common sense <a>Lens</a> laws:
--   
--   1) You get back what you put in:
--   
--   <pre>
--   <a>view</a> l (<a>set</a> l b a)  ≡ b
--   </pre>
--   
--   2) Putting back what you got doesn't change anything:
--   
--   <pre>
--   <a>set</a> l (<a>view</a> l a) a  ≡ a
--   </pre>
--   
--   3) Setting twice is the same as setting once:
--   
--   <pre>
--   <a>set</a> l c (<a>set</a> l b a) ≡ <a>set</a> l c a
--   </pre>
--   
--   These laws are strong enough that the 4 type parameters of a
--   <a>Lens</a> cannot vary fully independently. For more on how they
--   interact, read the "Why is it a Lens Family?" section of
--   <a>http://comonad.com/reader/2012/mirrored-lenses/</a>.
--   
--   Every <a>Lens</a> can be used directly as a <a>Setter</a> or
--   <a>Traversal</a>.
--   
--   You can also use a <a>Lens</a> for <a>Getting</a> as if it were a
--   <a>Fold</a> or <a>Getter</a>.
--   
--   Since every <a>Lens</a> is a valid <a>Traversal</a>, the
--   <a>Traversal</a> laws are required of any <a>Lens</a> you create:
--   
--   <pre>
--   l <a>pure</a> ≡ <a>pure</a>
--   <a>fmap</a> (l f) <a>.</a> l g ≡ <a>getCompose</a> <a>.</a> l (<a>Compose</a> <a>.</a> <a>fmap</a> f <a>.</a> g)
--   </pre>
--   
--   <pre>
--   type <a>Lens</a> s t a b = forall f. <a>Functor</a> f =&gt; <a>LensLike</a> f s t a b
--   </pre>
type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t

-- | <pre>
--   type <a>Lens'</a> = <a>Simple</a> <a>Lens</a>
--   </pre>
type Lens' s a = Lens s s a a

-- | Every <a>IndexedLens</a> is a valid <a>Lens</a> and a valid
--   <a>IndexedTraversal</a>.
type IndexedLens i s t a b = forall f p. (Indexable i p, Functor f) => p a (f b) -> s -> f t

-- | <pre>
--   type <a>IndexedLens'</a> i = <a>Simple</a> (<a>IndexedLens</a> i)
--   </pre>
type IndexedLens' i s a = IndexedLens i s s a a

-- | When you see this as an argument to a function, it expects a
--   <a>Lens</a>.
--   
--   This type can also be used when you need to store a <a>Lens</a> in a
--   container, since it is rank-1. You can turn them back into a
--   <a>Lens</a> with <a>cloneLens</a>, or use it directly with combinators
--   like <a>storing</a> and (<a>^#</a>).
type ALens s t a b = LensLike (Pretext (->) a b) s t a b

-- | <pre>
--   type <a>ALens'</a> = <a>Simple</a> <a>ALens</a>
--   </pre>
type ALens' s a = ALens s s a a

-- | When you see this as an argument to a function, it expects an
--   <a>IndexedLens</a>
type AnIndexedLens i s t a b = Overloading (Indexed i) (->) (Pretext (Indexed i) a b) s t a b

-- | <pre>
--   type <a>AnIndexedLens'</a> = <a>Simple</a> (<a>AnIndexedLens</a> i)
--   </pre>
type AnIndexedLens' i s a = AnIndexedLens i s s a a

-- | Build a <a>Lens</a> from a getter and a setter.
--   
--   <pre>
--   <a>lens</a> :: <a>Functor</a> f =&gt; (s -&gt; a) -&gt; (s -&gt; b -&gt; t) -&gt; (a -&gt; f b) -&gt; s -&gt; f t
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; s ^. lens getter setter
--   getter s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; s &amp; lens getter setter .~ b
--   setter s b
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; s &amp; lens getter setter %~ f
--   setter s (f (getter s))
--   </pre>
lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b

-- | Build an <a>IndexedLens</a> from a <a>Getter</a> and a <a>Setter</a>.
ilens :: (s -> (i, a)) -> (s -> b -> t) -> IndexedLens i s t a b

-- | Build an index-preserving <a>Lens</a> from a <a>Getter</a> and a
--   <a>Setter</a>.
--   
--   <pre>
--   <a>lens</a> :: (s -&gt; a) -&gt; (s -&gt; b -&gt; t) -&gt; <a>Lens</a> s t a b
--   <a>lens</a> sa sbt afb s = sbt s <a>&lt;$&gt;</a> afb (sa s)
--   </pre>
iplens :: (Conjoined p, Functor f) => (s -> a) -> (s -> b -> t) -> Overloaded p f s t a b

-- | (<a>%%~</a>) can be used in one of two scenarios:
--   
--   When applied to a <a>Lens</a>, it can edit the target of the
--   <a>Lens</a> in a structure, extracting a functorial result.
--   
--   When applied to a <a>Traversal</a>, it can edit the targets of the
--   traversals, extracting an applicative summary of its actions.
--   
--   For all that the definition of this combinator is just:
--   
--   <pre>
--   (<a>%%~</a>) ≡ <a>id</a>
--   </pre>
--   
--   It may be beneficial to think about it as if it had these even more
--   restricted types, however:
--   
--   <pre>
--   (<a>%%~</a>) :: <a>Functor</a> f =&gt;     <a>Iso</a> s t a b       -&gt; (a -&gt; f b) -&gt; s -&gt; f t
--   (<a>%%~</a>) :: <a>Functor</a> f =&gt;     <a>Lens</a> s t a b      -&gt; (a -&gt; f b) -&gt; s -&gt; f t
--   (<a>%%~</a>) :: <a>Applicative</a> f =&gt; <a>Traversal</a> s t a b -&gt; (a -&gt; f b) -&gt; s -&gt; f t
--   </pre>
--   
--   When applied to a <a>Traversal</a>, it can edit the targets of the
--   traversals, extracting a supplemental monoidal summary of its actions,
--   by choosing <tt>f = ((,) m)</tt>
--   
--   <pre>
--   (<a>%%~</a>) ::             <a>Iso</a> s t a b       -&gt; (a -&gt; (r, b)) -&gt; s -&gt; (r, t)
--   (<a>%%~</a>) ::             <a>Lens</a> s t a b      -&gt; (a -&gt; (r, b)) -&gt; s -&gt; (r, t)
--   (<a>%%~</a>) :: <a>Monoid</a> m =&gt; <a>Traversal</a> s t a b -&gt; (a -&gt; (m, b)) -&gt; s -&gt; (m, t)
--   </pre>
(%%~) :: Overloading p q f s t a b -> p a (f b) -> q s (f t)

-- | Modify the target of a <a>Lens</a> in the current state returning some
--   extra information of type <tt>r</tt> or modify all targets of a
--   <a>Traversal</a> in the current state, extracting extra information of
--   type <tt>r</tt> and return a monoidal summary of the changes.
--   
--   <pre>
--   &gt;&gt;&gt; runState (_1 %%= \x -&gt; (f x, g x)) (a,b)
--   (f a,(g a,b))
--   </pre>
--   
--   <pre>
--   (<a>%%=</a>) ≡ (<a>state</a> <a>.</a>)
--   </pre>
--   
--   It may be useful to think of (<a>%%=</a>), instead, as having either
--   of the following more restricted type signatures:
--   
--   <pre>
--   (<a>%%=</a>) :: <a>MonadState</a> s m             =&gt; <a>Iso</a> s s a b       -&gt; (a -&gt; (r, b)) -&gt; m r
--   (<a>%%=</a>) :: <a>MonadState</a> s m             =&gt; <a>Lens</a> s s a b      -&gt; (a -&gt; (r, b)) -&gt; m r
--   (<a>%%=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> r) =&gt; <a>Traversal</a> s s a b -&gt; (a -&gt; (r, b)) -&gt; m r
--   </pre>
(%%=) :: MonadState s m => Overloading p (->) ((,) r) s s a b -> p a (r, b) -> m r

-- | Adjust the target of an <a>IndexedLens</a> returning a supplementary
--   result, or adjust all of the targets of an <a>IndexedTraversal</a> and
--   return a monoidal summary of the supplementary results and the answer.
--   
--   <pre>
--   (<a>%%@~</a>) ≡ <a>withIndex</a>
--   </pre>
--   
--   <pre>
--   (<a>%%@~</a>) :: <a>Functor</a> f =&gt; <a>IndexedLens</a> i s t a b      -&gt; (i -&gt; a -&gt; f b) -&gt; s -&gt; f t
--   (<a>%%@~</a>) :: <a>Applicative</a> f =&gt; <a>IndexedTraversal</a> i s t a b -&gt; (i -&gt; a -&gt; f b) -&gt; s -&gt; f t
--   </pre>
--   
--   In particular, it is often useful to think of this function as having
--   one of these even more restricted type signatures:
--   
--   <pre>
--   (<a>%%@~</a>) ::             <a>IndexedLens</a> i s t a b      -&gt; (i -&gt; a -&gt; (r, b)) -&gt; s -&gt; (r, t)
--   (<a>%%@~</a>) :: <a>Monoid</a> r =&gt; <a>IndexedTraversal</a> i s t a b -&gt; (i -&gt; a -&gt; (r, b)) -&gt; s -&gt; (r, t)
--   </pre>
(%%@~) :: IndexedLensLike i f s t a b -> (i -> a -> f b) -> s -> f t

-- | Adjust the target of an <a>IndexedLens</a> returning a supplementary
--   result, or adjust all of the targets of an <a>IndexedTraversal</a>
--   within the current state, and return a monoidal summary of the
--   supplementary results.
--   
--   <pre>
--   l <a>%%@=</a> f ≡ <a>state</a> (l <a>%%@~</a> f)
--   </pre>
--   
--   <pre>
--   (<a>%%@=</a>) :: <a>MonadState</a> s m                 =&gt; <a>IndexedLens</a> i s s a b      -&gt; (i -&gt; a -&gt; (r, b)) -&gt; s -&gt; m r
--   (<a>%%@=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> r) =&gt; <a>IndexedTraversal</a> i s s a b -&gt; (i -&gt; a -&gt; (r, b)) -&gt; s -&gt; m r
--   </pre>
(%%@=) :: MonadState s m => IndexedLensLike i ((,) r) s s a b -> (i -> a -> (r, b)) -> m r

-- | Adjust the target of an <a>IndexedLens</a> returning the intermediate
--   result, or adjust all of the targets of an <a>IndexedTraversal</a> and
--   return a monoidal summary along with the answer.
--   
--   <pre>
--   l <a>&lt;%~</a> f ≡ l <a>&lt;%@~</a> <a>const</a> f
--   </pre>
--   
--   When you do not need access to the index then (<a>&lt;%~</a>) is more
--   liberal in what it can accept.
--   
--   If you do not need the intermediate result, you can use (<a>%@~</a>)
--   or even (<a>%~</a>).
--   
--   <pre>
--   (<a>&lt;%@~</a>) ::             <a>IndexedLens</a> i s t a b      -&gt; (i -&gt; a -&gt; b) -&gt; s -&gt; (b, t)
--   (<a>&lt;%@~</a>) :: <a>Monoid</a> b =&gt; <a>IndexedTraversal</a> i s t a b -&gt; (i -&gt; a -&gt; b) -&gt; s -&gt; (b, t)
--   </pre>
(<%@~) :: Overloading (Indexed i) q ((,) b) s t a b -> (i -> a -> b) -> q s (b, t)

-- | Adjust the target of an <a>IndexedLens</a> returning the intermediate
--   result, or adjust all of the targets of an <a>IndexedTraversal</a>
--   within the current state, and return a monoidal summary of the
--   intermediate results.
--   
--   <pre>
--   (<a>&lt;%@=</a>) :: <a>MonadState</a> s m                 =&gt; <a>IndexedLens</a> i s s a b      -&gt; (i -&gt; a -&gt; b) -&gt; m b
--   (<a>&lt;%@=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> b) =&gt; <a>IndexedTraversal</a> i s s a b -&gt; (i -&gt; a -&gt; b) -&gt; m b
--   </pre>
(<%@=) :: MonadState s m => IndexedLensLike i ((,) b) s s a b -> (i -> a -> b) -> m b

-- | Adjust the target of an <a>IndexedLens</a> returning the old value, or
--   adjust all of the targets of an <a>IndexedTraversal</a> and return a
--   monoidal summary of the old values along with the answer.
--   
--   <pre>
--   (<a>&lt;&lt;%@~</a>) ::             <a>IndexedLens</a> i s t a b      -&gt; (i -&gt; a -&gt; b) -&gt; s -&gt; (a, t)
--   (<a>&lt;&lt;%@~</a>) :: <a>Monoid</a> a =&gt; <a>IndexedTraversal</a> i s t a b -&gt; (i -&gt; a -&gt; b) -&gt; s -&gt; (a, t)
--   </pre>
(<<%@~) :: Overloading (Indexed i) q ((,) a) s t a b -> (i -> a -> b) -> q s (a, t)

-- | Adjust the target of an <a>IndexedLens</a> returning the old value, or
--   adjust all of the targets of an <a>IndexedTraversal</a> within the
--   current state, and return a monoidal summary of the old values.
--   
--   <pre>
--   (<a>&lt;&lt;%@=</a>) :: <a>MonadState</a> s m                 =&gt; <a>IndexedLens</a> i s s a b      -&gt; (i -&gt; a -&gt; b) -&gt; m a
--   (<a>&lt;&lt;%@=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> b) =&gt; <a>IndexedTraversal</a> i s s a b -&gt; (i -&gt; a -&gt; b) -&gt; m a
--   </pre>
(<<%@=) :: MonadState s m => IndexedLensLike i ((,) a) s s a b -> (i -> a -> b) -> m a

-- | Merge two lenses, getters, setters, folds or traversals.
--   
--   <pre>
--   <a>chosen</a> ≡ <a>choosing</a> <a>id</a> <a>id</a>
--   </pre>
--   
--   <pre>
--   <a>choosing</a> :: <a>Getter</a> s a     -&gt; <a>Getter</a> s' a     -&gt; <a>Getter</a> (<a>Either</a> s s') a
--   <a>choosing</a> :: <a>Fold</a> s a       -&gt; <a>Fold</a> s' a       -&gt; <a>Fold</a> (<a>Either</a> s s') a
--   <a>choosing</a> :: <a>Lens'</a> s a      -&gt; <a>Lens'</a> s' a      -&gt; <a>Lens'</a> (<a>Either</a> s s') a
--   <a>choosing</a> :: <a>Traversal'</a> s a -&gt; <a>Traversal'</a> s' a -&gt; <a>Traversal'</a> (<a>Either</a> s s') a
--   <a>choosing</a> :: <a>Setter'</a> s a    -&gt; <a>Setter'</a> s' a    -&gt; <a>Setter'</a> (<a>Either</a> s s') a
--   </pre>
choosing :: Functor f => LensLike f s t a b -> LensLike f s' t' a b -> LensLike f (Either s s') (Either t t') a b

-- | This is a <a>Lens</a> that updates either side of an <a>Either</a>,
--   where both sides have the same type.
--   
--   <pre>
--   <a>chosen</a> ≡ <a>choosing</a> <a>id</a> <a>id</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Left a^.chosen
--   a
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Right a^.chosen
--   a
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Right "hello"^.chosen
--   "hello"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Right a &amp; chosen *~ b
--   Right (a * b)
--   </pre>
--   
--   <pre>
--   <a>chosen</a> :: <a>Lens</a> (<a>Either</a> a a) (<a>Either</a> b b) a b
--   <a>chosen</a> f (<a>Left</a> a)  = <a>Left</a> <a>&lt;$&gt;</a> f a
--   <a>chosen</a> f (<a>Right</a> a) = <a>Right</a> <a>&lt;$&gt;</a> f a
--   </pre>
chosen :: IndexPreservingLens (Either a a) (Either b b) a b

-- | <a>alongside</a> makes a <a>Lens</a> from two other lenses.
--   
--   <pre>
--   &gt;&gt;&gt; (Left a, Right b)^.alongside chosen chosen
--   (a,b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (Left a, Right b) &amp; alongside chosen chosen .~ (c,d)
--   (Left c,Right d)
--   </pre>
--   
--   <pre>
--   <a>alongside</a> :: <a>Lens</a> s t a b -&gt; <a>Lens</a> s' t' a' b' -&gt; <a>Lens</a> (s,s') (t,t') (a,a') (b,b')
--   </pre>
alongside :: ALens s t a b -> ALens s' t' a' b' -> Lens (s, s') (t, t') (a, a') (b, b')

-- | Lift a <a>Lens</a> so it can run under a function.
inside :: ALens s t a b -> Lens (e -> s) (e -> t) (e -> a) (e -> b)

-- | Modify the target of a <a>Lens</a> and return the result.
--   
--   When you do not need the result of the addition, (<a>%~</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;%~</a>) ::             <a>Lens</a> s t a b      -&gt; (a -&gt; b) -&gt; s -&gt; (b, t)
--   (<a>&lt;%~</a>) ::             <a>Iso</a> s t a b       -&gt; (a -&gt; b) -&gt; s -&gt; (b, t)
--   (<a>&lt;%~</a>) :: <a>Monoid</a> b =&gt; <a>Traversal</a> s t a b -&gt; (a -&gt; b) -&gt; s -&gt; (b, t)
--   </pre>
(<%~) :: Profunctor p => Overloading p q ((,) b) s t a b -> p a b -> q s (b, t)

-- | Increment the target of a numerically valued <a>Lens</a> and return
--   the result.
--   
--   When you do not need the result of the addition, (<a>+~</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;+~</a>) :: <a>Num</a> a =&gt; <a>Lens'</a> s a -&gt; a -&gt; s -&gt; (a, s)
--   (<a>&lt;+~</a>) :: <a>Num</a> a =&gt; <a>Iso'</a> s a  -&gt; a -&gt; s -&gt; (a, s)
--   </pre>
(<+~) :: Num a => Overloading (->) q ((,) a) s t a a -> a -> q s (a, t)

-- | Decrement the target of a numerically valued <a>Lens</a> and return
--   the result.
--   
--   When you do not need the result of the subtraction, (<a>-~</a>) is
--   more flexible.
--   
--   <pre>
--   (<a>&lt;-~</a>) :: <a>Num</a> a =&gt; <a>Lens'</a> s a -&gt; a -&gt; s -&gt; (a, s)
--   (<a>&lt;-~</a>) :: <a>Num</a> a =&gt; <a>Iso'</a> s a  -&gt; a -&gt; s -&gt; (a, s)
--   </pre>
(<-~) :: Num a => Overloading (->) q ((,) a) s t a a -> a -> q s (a, t)

-- | Multiply the target of a numerically valued <a>Lens</a> and return the
--   result.
--   
--   When you do not need the result of the multiplication, (<a>*~</a>) is
--   more flexible.
--   
--   <pre>
--   (<a>&lt;*~</a>) :: <a>Num</a> a =&gt; <a>Lens'</a> s a -&gt; a -&gt; s -&gt; (a, s)
--   (<a>&lt;*~</a>) :: <a>Num</a> a =&gt; <a>Iso'</a>  s a -&gt; a -&gt; s -&gt; (a, s)
--   </pre>
(<*~) :: Num a => Overloading (->) q ((,) a) s t a a -> a -> q s (a, t)

-- | Divide the target of a fractionally valued <a>Lens</a> and return the
--   result.
--   
--   When you do not need the result of the division, (<a>//~</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;//~</a>) :: <a>Fractional</a> a =&gt; <a>Lens'</a> s a -&gt; a -&gt; s -&gt; (a, s)
--   (<a>&lt;//~</a>) :: <a>Fractional</a> a =&gt; <a>Iso'</a>  s a -&gt; a -&gt; s -&gt; (a, s)
--   </pre>
(<//~) :: Fractional a => Overloading (->) q ((,) a) s t a a -> a -> q s (a, t)

-- | Raise the target of a numerically valued <a>Lens</a> to a non-negative
--   <a>Integral</a> power and return the result.
--   
--   When you do not need the result of the division, (<a>^~</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;^~</a>) :: (<a>Num</a> a, <a>Integral</a> e) =&gt; <a>Lens'</a> s a -&gt; e -&gt; s -&gt; (a, s)
--   (<a>&lt;^~</a>) :: (<a>Num</a> a, <a>Integral</a> e) =&gt; <a>Iso'</a> s a -&gt; e -&gt; s -&gt; (a, s)
--   </pre>
(<^~) :: (Num a, Integral e) => Overloading (->) q ((,) a) s t a a -> e -> q s (a, t)

-- | Raise the target of a fractionally valued <a>Lens</a> to an
--   <a>Integral</a> power and return the result.
--   
--   When you do not need the result of the division, (<a>^^~</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;^^~</a>) :: (<a>Fractional</a> a, <a>Integral</a> e) =&gt; <a>Lens'</a> s a -&gt; e -&gt; s -&gt; (a, s)
--   (<a>&lt;^^~</a>) :: (<a>Fractional</a> a, <a>Integral</a> e) =&gt; <a>Iso'</a> s a -&gt; e -&gt; s -&gt; (a, s)
--   </pre>
(<^^~) :: (Fractional a, Integral e) => Overloading (->) q ((,) a) s t a a -> e -> q s (a, t)

-- | Raise the target of a floating-point valued <a>Lens</a> to an
--   arbitrary power and return the result.
--   
--   When you do not need the result of the division, (<a>**~</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;**~</a>) :: <a>Floating</a> a =&gt; <a>Lens'</a> s a -&gt; a -&gt; s -&gt; (a, s)
--   (<a>&lt;**~</a>) :: <a>Floating</a> a =&gt; <a>Iso'</a> s a  -&gt; a -&gt; s -&gt; (a, s)
--   </pre>
(<**~) :: Floating a => Overloading (->) q ((,) a) s t a a -> a -> q s (a, t)

-- | Logically <a>||</a> a Boolean valued <a>Lens</a> and return the
--   result.
--   
--   When you do not need the result of the operation, (<a>||~</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;||~</a>) :: <a>Lens'</a> s <a>Bool</a> -&gt; <a>Bool</a> -&gt; s -&gt; (<a>Bool</a>, s)
--   (<a>&lt;||~</a>) :: <a>Iso'</a> s <a>Bool</a>  -&gt; <a>Bool</a> -&gt; s -&gt; (<a>Bool</a>, s)
--   </pre>
(<||~) :: Overloading (->) q ((,) Bool) s t Bool Bool -> Bool -> q s (Bool, t)

-- | Logically <a>&amp;&amp;</a> a Boolean valued <a>Lens</a> and return
--   the result.
--   
--   When you do not need the result of the operation, (<a>&amp;&amp;~</a>)
--   is more flexible.
--   
--   <pre>
--   (<a>&lt;&amp;&amp;~</a>) :: <a>Lens'</a> s <a>Bool</a> -&gt; <a>Bool</a> -&gt; s -&gt; (<a>Bool</a>, s)
--   (<a>&lt;&amp;&amp;~</a>) :: <a>Iso'</a> s <a>Bool</a>  -&gt; <a>Bool</a> -&gt; s -&gt; (<a>Bool</a>, s)
--   </pre>
(<&&~) :: Overloading (->) q ((,) Bool) s t Bool Bool -> Bool -> q s (Bool, t)

-- | <a>mappend</a> a monoidal value onto the end of the target of a
--   <a>Lens</a> and return the result.
--   
--   When you do not need the result of the operation, (<a>&lt;&gt;~</a>)
--   is more flexible.
(<<>~) :: Monoid m => Overloading (->) q ((,) m) s t m m -> m -> q s (m, t)

-- | Modify the target of a <a>Lens</a>, but return the old value.
--   
--   When you do not need the result of the addition, (<a>%~</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;&lt;%~</a>) ::             <a>Lens</a> s t a b      -&gt; (a -&gt; b) -&gt; s -&gt; (a, t)
--   (<a>&lt;&lt;%~</a>) ::             <a>Iso</a> s t a b       -&gt; (a -&gt; b) -&gt; s -&gt; (a, t)
--   (<a>&lt;&lt;%~</a>) :: <a>Monoid</a> a =&gt; <a>Traversal</a> s t a b -&gt; (a -&gt; b) -&gt; s -&gt; (a, t)
--   </pre>
(<<%~) :: Strong p => Overloading p q ((,) a) s t a b -> p a b -> q s (a, t)

-- | Modify the target of a <a>Lens</a>, but return the old value.
--   
--   When you do not need the old value, (<a>%~</a>) is more flexible.
--   
--   <pre>
--   (<a>&lt;&lt;.~</a>) ::             <a>Lens</a> s t a b      -&gt; b -&gt; s -&gt; (a, t)
--   (<a>&lt;&lt;.~</a>) ::             <a>Iso</a> s t a b       -&gt; b -&gt; s -&gt; (a, t)
--   (<a>&lt;&lt;.~</a>) :: <a>Monoid</a> a =&gt; <a>Traversal</a> s t a b -&gt; b -&gt; s -&gt; (a, t)
--   </pre>
(<<.~) :: Overloading (->) q ((,) a) s t a b -> b -> q s (a, t)

-- | Modify the target of a <a>Lens</a> into your 'Monad'\'s state by a
--   user supplied function and return the result.
--   
--   When applied to a <a>Traversal</a>, it this will return a monoidal
--   summary of all of the intermediate results.
--   
--   When you do not need the result of the operation, (<a>%=</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;%=</a>) :: <a>MonadState</a> s m             =&gt; <a>Lens'</a> s a      -&gt; (a -&gt; a) -&gt; m a
--   (<a>&lt;%=</a>) :: <a>MonadState</a> s m             =&gt; <a>Iso'</a> s a       -&gt; (a -&gt; a) -&gt; m a
--   (<a>&lt;%=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> a) =&gt; <a>Traversal'</a> s a -&gt; (a -&gt; a) -&gt; m a
--   </pre>
(<%=) :: (Profunctor p, MonadState s m) => Overloading p (->) ((,) b) s s a b -> p a b -> m b

-- | Add to the target of a numerically valued <a>Lens</a> into your
--   'Monad'\'s state and return the result.
--   
--   When you do not need the result of the addition, (<a>+=</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;+=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Lens'</a> s a -&gt; a -&gt; m a
--   (<a>&lt;+=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Iso'</a> s a -&gt; a -&gt; m a
--   </pre>
(<+=) :: (MonadState s m, Num a) => LensLike' ((,) a) s a -> a -> m a

-- | Subtract from the target of a numerically valued <a>Lens</a> into your
--   'Monad'\'s state and return the result.
--   
--   When you do not need the result of the subtraction, (<a>-=</a>) is
--   more flexible.
--   
--   <pre>
--   (<a>&lt;-=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Lens'</a> s a -&gt; a -&gt; m a
--   (<a>&lt;-=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Iso'</a> s a -&gt; a -&gt; m a
--   </pre>
(<-=) :: (MonadState s m, Num a) => LensLike' ((,) a) s a -> a -> m a

-- | Multiply the target of a numerically valued <a>Lens</a> into your
--   'Monad'\'s state and return the result.
--   
--   When you do not need the result of the multiplication, (<a>*=</a>) is
--   more flexible.
--   
--   <pre>
--   (<a>&lt;*=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Lens'</a> s a -&gt; a -&gt; m a
--   (<a>&lt;*=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Iso'</a> s a -&gt; a -&gt; m a
--   </pre>
(<*=) :: (MonadState s m, Num a) => LensLike' ((,) a) s a -> a -> m a

-- | Divide the target of a fractionally valued <a>Lens</a> into your
--   'Monad'\'s state and return the result.
--   
--   When you do not need the result of the division, (<a>//=</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;//=</a>) :: (<a>MonadState</a> s m, <a>Fractional</a> a) =&gt; <a>Lens'</a> s a -&gt; a -&gt; m a
--   (<a>&lt;//=</a>) :: (<a>MonadState</a> s m, <a>Fractional</a> a) =&gt; <a>Iso'</a> s a -&gt; a -&gt; m a
--   </pre>
(<//=) :: (MonadState s m, Fractional a) => LensLike' ((,) a) s a -> a -> m a

-- | Raise the target of a numerically valued <a>Lens</a> into your
--   'Monad'\'s state to a non-negative <a>Integral</a> power and return
--   the result.
--   
--   When you do not need the result of the operation, (<a>**=</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;^=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a, <a>Integral</a> e) =&gt; <a>Lens'</a> s a -&gt; e -&gt; m a
--   (<a>&lt;^=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a, <a>Integral</a> e) =&gt; <a>Iso'</a> s a -&gt; e -&gt; m a
--   </pre>
(<^=) :: (MonadState s m, Num a, Integral e) => LensLike' ((,) a) s a -> e -> m a

-- | Raise the target of a fractionally valued <a>Lens</a> into your
--   'Monad'\'s state to an <a>Integral</a> power and return the result.
--   
--   When you do not need the result of the operation, (<a>^^=</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;^^=</a>) :: (<a>MonadState</a> s m, <a>Fractional</a> b, <a>Integral</a> e) =&gt; <a>Lens'</a> s a -&gt; e -&gt; m a
--   (<a>&lt;^^=</a>) :: (<a>MonadState</a> s m, <a>Fractional</a> b, <a>Integral</a> e) =&gt; <a>Iso'</a> s a  -&gt; e -&gt; m a
--   </pre>
(<^^=) :: (MonadState s m, Fractional a, Integral e) => LensLike' ((,) a) s a -> e -> m a

-- | Raise the target of a floating-point valued <a>Lens</a> into your
--   'Monad'\'s state to an arbitrary power and return the result.
--   
--   When you do not need the result of the operation, (<a>**=</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;**=</a>) :: (<a>MonadState</a> s m, <a>Floating</a> a) =&gt; <a>Lens'</a> s a -&gt; a -&gt; m a
--   (<a>&lt;**=</a>) :: (<a>MonadState</a> s m, <a>Floating</a> a) =&gt; <a>Iso'</a> s a -&gt; a -&gt; m a
--   </pre>
(<**=) :: (MonadState s m, Floating a) => LensLike' ((,) a) s a -> a -> m a

-- | Logically <a>||</a> a Boolean valued <a>Lens</a> into your 'Monad'\'s
--   state and return the result.
--   
--   When you do not need the result of the operation, (<a>||=</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;||=</a>) :: <a>MonadState</a> s m =&gt; <a>Lens'</a> s <a>Bool</a> -&gt; <a>Bool</a> -&gt; m <a>Bool</a>
--   (<a>&lt;||=</a>) :: <a>MonadState</a> s m =&gt; <a>Iso'</a> s <a>Bool</a>  -&gt; <a>Bool</a> -&gt; m <a>Bool</a>
--   </pre>
(<||=) :: MonadState s m => LensLike' ((,) Bool) s Bool -> Bool -> m Bool

-- | Logically <a>&amp;&amp;</a> a Boolean valued <a>Lens</a> into your
--   'Monad'\'s state and return the result.
--   
--   When you do not need the result of the operation, (<a>&amp;&amp;=</a>)
--   is more flexible.
--   
--   <pre>
--   (<a>&lt;&amp;&amp;=</a>) :: <a>MonadState</a> s m =&gt; <a>Lens'</a> s <a>Bool</a> -&gt; <a>Bool</a> -&gt; m <a>Bool</a>
--   (<a>&lt;&amp;&amp;=</a>) :: <a>MonadState</a> s m =&gt; <a>Iso'</a> s <a>Bool</a>  -&gt; <a>Bool</a> -&gt; m <a>Bool</a>
--   </pre>
(<&&=) :: MonadState s m => LensLike' ((,) Bool) s Bool -> Bool -> m Bool

-- | <a>mappend</a> a monoidal value onto the end of the target of a
--   <a>Lens</a> into your 'Monad'\'s state and return the result.
--   
--   When you do not need the result of the operation, (<a>&lt;&gt;=</a>)
--   is more flexible.
(<<>=) :: (MonadState s m, Monoid r) => LensLike' ((,) r) s r -> r -> m r

-- | Modify the target of a <a>Lens</a> into your 'Monad'\'s state by a
--   user supplied function and return the <i>old</i> value that was
--   replaced.
--   
--   When applied to a <a>Traversal</a>, it this will return a monoidal
--   summary of all of the old values present.
--   
--   When you do not need the result of the operation, (<a>%=</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;&lt;%=</a>) :: <a>MonadState</a> s m             =&gt; <a>Lens'</a> s a      -&gt; (a -&gt; a) -&gt; m a
--   (<a>&lt;&lt;%=</a>) :: <a>MonadState</a> s m             =&gt; <a>Iso'</a> s a       -&gt; (a -&gt; a) -&gt; m a
--   (<a>&lt;&lt;%=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> b) =&gt; <a>Traversal'</a> s a -&gt; (a -&gt; a) -&gt; m a
--   </pre>
--   
--   <pre>
--   (<a>&lt;&lt;%=</a>) :: <a>MonadState</a> s m =&gt; <a>LensLike</a> ((,)a) s s a b -&gt; (a -&gt; b) -&gt; m a
--   </pre>
(<<%=) :: (Strong p, MonadState s m) => Overloading p (->) ((,) a) s s a b -> p a b -> m a

-- | Modify the target of a <a>Lens</a> into your 'Monad'\'s state by a
--   user supplied function and return the <i>old</i> value that was
--   replaced.
--   
--   When applied to a <a>Traversal</a>, it this will return a monoidal
--   summary of all of the old values present.
--   
--   When you do not need the result of the operation, (<a>%=</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;&lt;%=</a>) :: <a>MonadState</a> s m             =&gt; <a>Lens'</a> s a      -&gt; (a -&gt; a) -&gt; m a
--   (<a>&lt;&lt;%=</a>) :: <a>MonadState</a> s m             =&gt; <a>Iso'</a> s a       -&gt; (a -&gt; a) -&gt; m a
--   (<a>&lt;&lt;%=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> t) =&gt; <a>Traversal'</a> s a -&gt; (a -&gt; a) -&gt; m a
--   </pre>
(<<.=) :: MonadState s m => LensLike ((,) a) s s a b -> b -> m a

-- | Run a monadic action, and set the target of <a>Lens</a> to its result.
--   
--   <pre>
--   (<a>&lt;&lt;~</a>) :: <a>MonadState</a> s m =&gt; <a>Iso</a> s s a b   -&gt; m b -&gt; m b
--   (<a>&lt;&lt;~</a>) :: <a>MonadState</a> s m =&gt; <a>Lens</a> s s a b  -&gt; m b -&gt; m b
--   </pre>
--   
--   NB: This is limited to taking an actual <a>Lens</a> than admitting a
--   <a>Traversal</a> because there are potential loss of state issues
--   otherwise.
(<<~) :: MonadState s m => ALens s s a b -> m b -> m b

-- | Cloning a <a>Lens</a> is one way to make sure you aren't given
--   something weaker, such as a <a>Traversal</a> and can be used as a way
--   to pass around lenses that have to be monomorphic in <tt>f</tt>.
--   
--   Note: This only accepts a proper <a>Lens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; let example l x = set (cloneLens l) (x^.cloneLens l + 1) x in example _2 ("hello",1,"you")
--   ("hello",2,"you")
--   </pre>
cloneLens :: ALens s t a b -> Lens s t a b

-- | Clone a <a>Lens</a> as an <tt>IndexedPreservingLens</tt> that just
--   passes through whatever index is on any <a>IndexedLens</a>,
--   <a>IndexedFold</a>, <a>IndexedGetter</a> or <a>IndexedTraversal</a> it
--   is composed with.
cloneIndexPreservingLens :: ALens s t a b -> IndexPreservingLens s t a b

-- | Clone an <a>IndexedLens</a> as an <a>IndexedLens</a> with the same
--   index.
cloneIndexedLens :: AnIndexedLens i s t a b -> IndexedLens i s t a b

-- | A version of <a>set</a> that works on <a>ALens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; storing _2 "world" ("hello","there")
--   ("hello","world")
--   </pre>
storing :: ALens s t a b -> b -> s -> t

-- | A version of (<a>^.</a>) that works on <a>ALens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world")^#_2
--   "world"
--   </pre>
(^#) :: s -> ALens s t a b -> a

-- | A version of (<a>.~</a>) that works on <a>ALens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","there") &amp; _2 #~ "world"
--   ("hello","world")
--   </pre>
(#~) :: ALens s t a b -> b -> s -> t

-- | A version of (<a>%~</a>) that works on <a>ALens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world") &amp; _2 #%~ length
--   ("hello",5)
--   </pre>
(#%~) :: ALens s t a b -> (a -> b) -> s -> t

-- | A version of (<a>%%~</a>) that works on <a>ALens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world") &amp; _2 #%%~ \x -&gt; (length x, x ++ "!")
--   (5,("hello","world!"))
--   </pre>
(#%%~) :: Functor f => ALens s t a b -> (a -> f b) -> s -> f t

-- | A version of (<a>&lt;.~</a>) that works on <a>ALens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","there") &amp; _2 &lt;#~ "world"
--   ("world",("hello","world"))
--   </pre>
(<#~) :: ALens s t a b -> b -> s -> (b, t)

-- | A version of (<a>&lt;%~</a>) that works on <a>ALens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world") &amp; _2 &lt;#%~ length
--   (5,("hello",5))
--   </pre>
(<#%~) :: ALens s t a b -> (a -> b) -> s -> (b, t)

-- | A version of (<a>.=</a>) that works on <a>ALens</a>.
(#=) :: MonadState s m => ALens s s a b -> b -> m ()

-- | A version of (<a>%=</a>) that works on <a>ALens</a>.
(#%=) :: MonadState s m => ALens s s a b -> (a -> b) -> m ()

-- | A version of (<a>%%=</a>) that works on <a>ALens</a>.
(#%%=) :: MonadState s m => ALens s s a b -> (a -> (r, b)) -> m r

-- | A version of (<a>&lt;#=</a>) that works on <a>ALens</a>.
(<#=) :: MonadState s m => ALens s s a b -> b -> m b

-- | A version of (<a>&lt;%=</a>) that works on <a>ALens</a>.
(<#%=) :: MonadState s m => ALens s s a b -> (a -> b) -> m b

-- | There is a field for every type in the <a>Void</a>. Very zen.
--   
--   <pre>
--   &gt;&gt;&gt; [] &amp; mapped.devoid +~ 1
--   []
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Nothing &amp; mapped.devoid %~ abs
--   Nothing
--   </pre>
--   
--   <pre>
--   <a>devoid</a> :: <a>Lens'</a> <a>Void</a> a
--   </pre>
devoid :: Over p f Void Void a b

-- | We can always retrieve a <tt>()</tt> from any type.
--   
--   <pre>
--   &gt;&gt;&gt; "hello"^.united
--   ()
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "hello" &amp; united .~ ()
--   "hello"
--   </pre>
united :: Lens' a ()

-- | The indexed store can be used to characterize a <a>Lens</a> and is
--   used by <a>clone</a>.
--   
--   <tt><a>Context</a> a b t</tt> is isomorphic to <tt>newtype
--   <a>Context</a> a b t = <a>Context</a> { runContext :: forall f.
--   <a>Functor</a> f =&gt; (a -&gt; f b) -&gt; f t }</tt>, and to
--   <tt>exists s. (s, <a>Lens</a> s t a b)</tt>.
--   
--   A <a>Context</a> is like a <a>Lens</a> that has already been applied
--   to a some structure.
data Context a b t
Context :: (b -> t) -> a -> Context a b t

-- | <pre>
--   type <a>Context'</a> a s = <a>Context</a> a a s
--   </pre>
type Context' a = Context a a

-- | This <a>Lens</a> lets you <tt>view</tt> the current <tt>pos</tt> of
--   any indexed store comonad and <tt>seek</tt> to a new position. This
--   reduces the API for working these instances to a single <a>Lens</a>.
--   
--   <pre>
--   <a>ipos</a> w ≡ w <a>^.</a> <a>locus</a>
--   <a>iseek</a> s w ≡ w <a>&amp;</a> <a>locus</a> <a>.~</a> s
--   <a>iseeks</a> f w ≡ w <a>&amp;</a> <a>locus</a> <a>%~</a> f
--   </pre>
--   
--   <pre>
--   <a>locus</a> :: <a>Lens'</a> (<a>Context'</a> a s) a
--   <a>locus</a> :: <a>Conjoined</a> p =&gt; <a>Lens'</a> (<a>Pretext'</a> p a s) a
--   <a>locus</a> :: <a>Conjoined</a> p =&gt; <a>Lens'</a> (<a>PretextT'</a> p g a s) a
--   </pre>
locus :: IndexedComonadStore p => Lens (p a c s) (p b c s) a b


-- | This module exports a minimalist API for working with lenses in highly
--   monomorphic settings.
module Control.Lens.Loupe

-- | When you see this as an argument to a function, it expects a
--   <a>Lens</a>.
--   
--   This type can also be used when you need to store a <a>Lens</a> in a
--   container, since it is rank-1. You can turn them back into a
--   <a>Lens</a> with <a>cloneLens</a>, or use it directly with combinators
--   like <a>storing</a> and (<a>^#</a>).
type ALens s t a b = LensLike (Pretext (->) a b) s t a b

-- | <pre>
--   type <a>ALens'</a> = <a>Simple</a> <a>ALens</a>
--   </pre>
type ALens' s a = ALens s s a a

-- | Cloning a <a>Lens</a> is one way to make sure you aren't given
--   something weaker, such as a <a>Traversal</a> and can be used as a way
--   to pass around lenses that have to be monomorphic in <tt>f</tt>.
--   
--   Note: This only accepts a proper <a>Lens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; let example l x = set (cloneLens l) (x^.cloneLens l + 1) x in example _2 ("hello",1,"you")
--   ("hello",2,"you")
--   </pre>
cloneLens :: ALens s t a b -> Lens s t a b

-- | A version of <a>set</a> that works on <a>ALens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; storing _2 "world" ("hello","there")
--   ("hello","world")
--   </pre>
storing :: ALens s t a b -> b -> s -> t

-- | A version of (<a>^.</a>) that works on <a>ALens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world")^#_2
--   "world"
--   </pre>
(^#) :: s -> ALens s t a b -> a

-- | A version of (<a>.~</a>) that works on <a>ALens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","there") &amp; _2 #~ "world"
--   ("hello","world")
--   </pre>
(#~) :: ALens s t a b -> b -> s -> t

-- | A version of (<a>%~</a>) that works on <a>ALens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world") &amp; _2 #%~ length
--   ("hello",5)
--   </pre>
(#%~) :: ALens s t a b -> (a -> b) -> s -> t

-- | A version of (<a>%%~</a>) that works on <a>ALens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world") &amp; _2 #%%~ \x -&gt; (length x, x ++ "!")
--   (5,("hello","world!"))
--   </pre>
(#%%~) :: Functor f => ALens s t a b -> (a -> f b) -> s -> f t

-- | A version of (<a>&lt;.~</a>) that works on <a>ALens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","there") &amp; _2 &lt;#~ "world"
--   ("world",("hello","world"))
--   </pre>
(<#~) :: ALens s t a b -> b -> s -> (b, t)

-- | A version of (<a>&lt;%~</a>) that works on <a>ALens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world") &amp; _2 &lt;#%~ length
--   (5,("hello",5))
--   </pre>
(<#%~) :: ALens s t a b -> (a -> b) -> s -> (b, t)

-- | A version of (<a>.=</a>) that works on <a>ALens</a>.
(#=) :: MonadState s m => ALens s s a b -> b -> m ()

-- | A version of (<a>%=</a>) that works on <a>ALens</a>.
(#%=) :: MonadState s m => ALens s s a b -> (a -> b) -> m ()

-- | A version of (<a>%%=</a>) that works on <a>ALens</a>.
(#%%=) :: MonadState s m => ALens s s a b -> (a -> (r, b)) -> m r

-- | A version of (<a>&lt;#=</a>) that works on <a>ALens</a>.
(<#=) :: MonadState s m => ALens s s a b -> b -> m b

-- | A version of (<a>&lt;%=</a>) that works on <a>ALens</a>.
(<#%=) :: MonadState s m => ALens s s a b -> (a -> b) -> m b

-- | 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 <a>ALens</a> for
--   consistency.

-- | <i>Deprecated: use ALens </i>
type Loupe s t a b = LensLike (Pretext (->) a b) s t a b

-- | <pre>
--   type <a>SimpleLoupe</a> = <a>Simple</a> <a>Loupe</a>
--   </pre>
--   
--   Deprecated for two reasons. <a>Loupe</a> is now <a>ALens</a>, and we
--   no longer use the verbose <tt>SimpleFoo</tt> naming convention, this
--   has since been renamed to <a>ALens'</a> for consistency.

-- | <i>Deprecated: use ALens' </i>
type SimpleLoupe s a = Loupe s s a a


module Control.Lens.Prism

-- | A <a>Prism</a> <tt>l</tt> is a 0-or-1 target <a>Traversal</a> that can
--   also be turned around with <a>re</a> to obtain a <a>Getter</a> in the
--   opposite direction.
--   
--   There are two laws that a <a>Prism</a> should satisfy:
--   
--   First, if I <a>re</a> or <a>review</a> a value with a <a>Prism</a> and
--   then <a>preview</a> or use (<a>^?</a>), I will get it back:
--   
--   <pre>
--   <a>preview</a> l (<a>review</a> l b) ≡ <a>Just</a> b
--   </pre>
--   
--   Second, if you can extract a value <tt>a</tt> using a <a>Prism</a>
--   <tt>l</tt> from a value <tt>s</tt>, then the value <tt>s</tt> is
--   completely described my <tt>l</tt> and <tt>a</tt>:
--   
--   If <tt><a>preview</a> l s ≡ <a>Just</a> a</tt> then <tt><a>review</a>
--   l a ≡ s</tt>
--   
--   These two laws imply that the <a>Traversal</a> laws hold for every
--   <a>Prism</a> and that we <a>traverse</a> at most 1 element:
--   
--   <pre>
--   <a>lengthOf</a> l x <a>&lt;=</a> 1
--   </pre>
--   
--   It may help to think of this as a <a>Iso</a> that can be partial in
--   one direction.
--   
--   Every <a>Prism</a> is a valid <a>Traversal</a>.
--   
--   Every <a>Iso</a> is a valid <a>Prism</a>.
--   
--   For example, you might have a <tt><a>Prism'</a> <a>Integer</a>
--   <a>Natural</a></tt> allows you to always go from a <a>Natural</a> to
--   an <a>Integer</a>, and provide you with tools to check if an
--   <a>Integer</a> is a <a>Natural</a> and/or to edit one if it is.
--   
--   <pre>
--   <tt>nat</tt> :: <a>Prism'</a> <a>Integer</a> <a>Natural</a>
--   <tt>nat</tt> = <a>prism</a> <a>toInteger</a> <a>$</a> \ i -&gt;
--      if i <a>&lt;</a> 0
--      then <a>Left</a> i
--      else <a>Right</a> (<a>fromInteger</a> i)
--   </pre>
--   
--   Now we can ask if an <a>Integer</a> is a <a>Natural</a>.
--   
--   <pre>
--   &gt;&gt;&gt; 5^?nat
--   Just 5
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (-5)^?nat
--   Nothing
--   </pre>
--   
--   We can update the ones that are:
--   
--   <pre>
--   &gt;&gt;&gt; (-3,4) &amp; both.nat *~ 2
--   (-3,8)
--   </pre>
--   
--   And we can then convert from a <a>Natural</a> to an <a>Integer</a>.
--   
--   <pre>
--   &gt;&gt;&gt; 5 ^. re nat -- :: Natural
--   5
--   </pre>
--   
--   Similarly we can use a <a>Prism</a> to <a>traverse</a> the <a>Left</a>
--   half of an <a>Either</a>:
--   
--   <pre>
--   &gt;&gt;&gt; Left "hello" &amp; _Left %~ length
--   Left 5
--   </pre>
--   
--   or to construct an <a>Either</a>:
--   
--   <pre>
--   &gt;&gt;&gt; 5^.re _Left
--   Left 5
--   </pre>
--   
--   such that if you query it with the <a>Prism</a>, you will get your
--   original input back.
--   
--   <pre>
--   &gt;&gt;&gt; 5^.re _Left ^? _Left
--   Just 5
--   </pre>
--   
--   Another interesting way to think of a <a>Prism</a> is as the
--   categorical dual of a <a>Lens</a> -- a co-<a>Lens</a>, so to speak.
--   This is what permits the construction of <a>outside</a>.
--   
--   Note: Composition with a <a>Prism</a> is index-preserving.
type Prism s t a b = forall p f. (Choice p, Applicative f) => p a (f b) -> p s (f t)

-- | A <a>Simple</a> <a>Prism</a>.
type Prism' s a = Prism s s a a

-- | If you see this in a signature for a function, the function is
--   expecting a <a>Prism</a>.
type APrism s t a b = Market a b a (Mutator b) -> Market a b s (Mutator t)

-- | <pre>
--   type APrism' = <a>Simple</a> <a>APrism</a>
--   </pre>
type APrism' s a = APrism s s a a

-- | Build a <a>Prism</a>.
--   
--   <tt><a>Either</a> t a</tt> is used instead of <tt><a>Maybe</a> a</tt>
--   to permit the types of <tt>s</tt> and <tt>t</tt> to differ.
prism :: (b -> t) -> (s -> Either t a) -> Prism s t a b

-- | This is usually used to build a <a>Prism'</a>, when you have to use an
--   operation like <a>cast</a> which already returns a <a>Maybe</a>.
prism' :: (b -> s) -> (s -> Maybe a) -> Prism s s a b

-- | Clone a <a>Prism</a> so that you can reuse the same monomorphically
--   typed <a>Prism</a> for different purposes.
--   
--   See <a>cloneLens</a> and <a>cloneTraversal</a> for examples of why you
--   might want to do this.
clonePrism :: APrism s t a b -> Prism s t a b

-- | Use a <a>Prism</a> as a kind of first-class pattern.
--   
--   <pre>
--   <a>outside</a> :: <a>Prism</a> s t a b -&gt; <a>Lens</a> (t -&gt; r) (s -&gt; r) (b -&gt; r) (a -&gt; r)
--   </pre>
outside :: APrism s t a b -> Lens (t -> r) (s -> r) (b -> r) (a -> r)

-- | Use a <a>Prism</a> to work over part of a structure.
aside :: APrism s t a b -> Prism (e, s) (e, t) (e, a) (e, b)

-- | Given a pair of prisms, project sums.
--   
--   Viewing a <a>Prism</a> as a co-<a>Lens</a>, this combinator can be
--   seen to be dual to <a>alongside</a>.
without :: APrism s t a b -> APrism u v c d -> Prism (Either s u) (Either t v) (Either a c) (Either b d)

-- | Check to see if this <a>Prism</a> doesn't match.
--   
--   <pre>
--   &gt;&gt;&gt; isn't _Left (Right 12)
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; isn't _Left (Left 12)
--   False
--   </pre>
isn't :: APrism s t a b -> s -> Bool

-- | This <a>Prism</a> provides a <a>Traversal</a> for tweaking the
--   <a>Left</a> half of an <a>Either</a>:
--   
--   <pre>
--   &gt;&gt;&gt; over _Left (+1) (Left 2)
--   Left 3
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over _Left (+1) (Right 2)
--   Right 2
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Right 42 ^._Left :: String
--   ""
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Left "hello" ^._Left
--   "hello"
--   </pre>
--   
--   It also can be turned around to obtain the embedding into the
--   <a>Left</a> half of an <a>Either</a>:
--   
--   <pre>
--   &gt;&gt;&gt; _Left # 5
--   Left 5
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; 5^.re _Left
--   Left 5
--   </pre>
_Left :: Prism (Either a c) (Either b c) a b

-- | This <a>Prism</a> provides a <a>Traversal</a> for tweaking the
--   <a>Right</a> half of an <a>Either</a>:
--   
--   <pre>
--   &gt;&gt;&gt; over _Right (+1) (Left 2)
--   Left 2
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over _Right (+1) (Right 2)
--   Right 3
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Right "hello" ^._Right
--   "hello"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Left "hello" ^._Right :: [Double]
--   []
--   </pre>
--   
--   It also can be turned around to obtain the embedding into the
--   <a>Right</a> half of an <a>Either</a>:
--   
--   <pre>
--   &gt;&gt;&gt; _Right # 5
--   Right 5
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; 5^.re _Right
--   Right 5
--   </pre>
_Right :: Prism (Either c a) (Either c b) a b

-- | This <a>Prism</a> provides a <a>Traversal</a> for tweaking the target
--   of the value of <a>Just</a> in a <a>Maybe</a>.
--   
--   <pre>
--   &gt;&gt;&gt; over _Just (+1) (Just 2)
--   Just 3
--   </pre>
--   
--   Unlike <a>traverse</a> this is a <a>Prism</a>, and so you can use it
--   to inject as well:
--   
--   <pre>
--   &gt;&gt;&gt; _Just # 5
--   Just 5
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; 5^.re _Just
--   Just 5
--   </pre>
--   
--   Interestingly,
--   
--   <pre>
--   m <tt>^?</tt> <a>_Just</a> ≡ m
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Just x ^? _Just
--   Just x
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Nothing ^? _Just
--   Nothing
--   </pre>
_Just :: Prism (Maybe a) (Maybe b) a b

-- | This <a>Prism</a> provides the <a>Traversal</a> of a <a>Nothing</a> in
--   a <a>Maybe</a>.
--   
--   <pre>
--   &gt;&gt;&gt; Nothing ^? _Nothing
--   Just ()
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Just () ^? _Nothing
--   Nothing
--   </pre>
--   
--   But you can turn it around and use it to construct <a>Nothing</a> as
--   well:
--   
--   <pre>
--   &gt;&gt;&gt; _Nothing # ()
--   Nothing
--   </pre>
_Nothing :: Prism' (Maybe a) ()

-- | <a>Void</a> is a logically uninhabited data type.
--   
--   This is a <a>Prism</a> that will always fail to match.
_Void :: Prism s s a Void

-- | This <a>Prism</a> compares for exact equality with a given value.
--   
--   <pre>
--   &gt;&gt;&gt; only 4 # ()
--   4
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; 5 ^? only 4
--   Nothing
--   </pre>
only :: Eq a => a -> Prism' a ()

-- | The generalization of <a>DownStar</a> of a "costrong" <a>Functor</a>
--   
--   Minimal complete definition: <a>left'</a> or <a>right'</a>
--   
--   <i>Note:</i> We use <a>traverse</a> and <a>extract</a> as approximate
--   costrength as needed.
class Profunctor p => Choice (p :: * -> * -> *)
left' :: Choice p => p a b -> p (Either a c) (Either b c)
right' :: Choice p => p a b -> p (Either c a) (Either c b)


-- | A <tt><a>Traversal</a> s t a b</tt> is a generalization of
--   <a>traverse</a> from <a>Traversable</a>. It allows you to
--   <a>traverse</a> over a structure and change out its contents with
--   monadic or <a>Applicative</a> side-effects. Starting from
--   
--   <pre>
--   <a>traverse</a> :: (<a>Traversable</a> t, <a>Applicative</a> f) =&gt; (a -&gt; f b) -&gt; t a -&gt; f (t b)
--   </pre>
--   
--   we monomorphize the contents and result to obtain
--   
--   <pre>
--   type <a>Traversal</a> s t a b = forall f. <a>Applicative</a> f =&gt; (a -&gt; f b) -&gt; s -&gt; f t
--   </pre>
--   
--   While a <a>Traversal</a> isn't quite a <a>Fold</a>, it _can_ be used
--   for <a>Getting</a> like a <a>Fold</a>, because given a <a>Monoid</a>
--   <tt>m</tt>, we have an <a>Applicative</a> for <tt>(<a>Const</a>
--   m)</tt>. Everything you know how to do with a <a>Traversable</a>
--   container, you can with with a <a>Traversal</a>, and here we provide
--   combinators that generalize the usual <a>Traversable</a> operations.
module Control.Lens.Traversal

-- | A <a>Traversal</a> can be used directly as a <a>Setter</a> or a
--   <a>Fold</a> (but not as a <a>Lens</a>) and provides the ability to
--   both read and update multiple fields, subject to some relatively weak
--   <a>Traversal</a> laws.
--   
--   These have also been known as multilenses, but they have the signature
--   and spirit of
--   
--   <pre>
--   <a>traverse</a> :: <a>Traversable</a> f =&gt; <a>Traversal</a> (f a) (f b) a b
--   </pre>
--   
--   and the more evocative name suggests their application.
--   
--   Most of the time the <a>Traversal</a> you will want to use is just
--   <a>traverse</a>, but you can also pass any <a>Lens</a> or <a>Iso</a>
--   as a <a>Traversal</a>, and composition of a <a>Traversal</a> (or
--   <a>Lens</a> or <a>Iso</a>) with a <a>Traversal</a> (or <a>Lens</a> or
--   <a>Iso</a>) using (<a>.</a>) forms a valid <a>Traversal</a>.
--   
--   The laws for a <a>Traversal</a> <tt>t</tt> follow from the laws for
--   <a>Traversable</a> as stated in "The Essence of the Iterator Pattern".
--   
--   <pre>
--   t <a>pure</a> ≡ <a>pure</a>
--   <a>fmap</a> (t f) <a>.</a> t g ≡ <a>getCompose</a> <a>.</a> t (<a>Compose</a> <a>.</a> <a>fmap</a> f <a>.</a> g)
--   </pre>
--   
--   One consequence of this requirement is that a <a>Traversal</a> needs
--   to leave the same number of elements as a candidate for subsequent
--   <a>Traversal</a> that it started with. Another testament to the
--   strength of these laws is that the caveat expressed in section 5.5 of
--   the "Essence of the Iterator Pattern" about exotic <a>Traversable</a>
--   instances that <a>traverse</a> the same entry multiple times was
--   actually already ruled out by the second law in that same paper!
type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t

-- | <pre>
--   type <a>Traversal'</a> = <a>Simple</a> <a>Traversal</a>
--   </pre>
type Traversal' s a = Traversal s s a a

-- | Every <a>IndexedTraversal</a> is a valid <a>Traversal</a> or
--   <a>IndexedFold</a>.
--   
--   The <a>Indexed</a> constraint is used to allow an
--   <a>IndexedTraversal</a> to be used directly as a <a>Traversal</a>.
--   
--   The <a>Traversal</a> laws are still required to hold.
type IndexedTraversal i s t a b = forall p f. (Indexable i p, Applicative f) => p a (f b) -> s -> f t

-- | <pre>
--   type <a>IndexedTraversal'</a> i = <a>Simple</a> (<a>IndexedTraversal</a> i)
--   </pre>
type IndexedTraversal' i s a = IndexedTraversal i s s a a

-- | When you see this as an argument to a function, it expects a
--   <a>Traversal</a>.
type ATraversal s t a b = LensLike (Bazaar (->) a b) s t a b

-- | <pre>
--   type <a>ATraversal'</a> = <a>Simple</a> <a>ATraversal</a>
--   </pre>
type ATraversal' s a = ATraversal s s a a

-- | When you see this as an argument to a function, it expects an
--   <a>IndexedTraversal</a>.
type AnIndexedTraversal i s t a b = Over (Indexed i) (Bazaar (Indexed i) a b) s t a b

-- | <pre>
--   type <a>AnIndexedTraversal'</a> = <a>Simple</a> (<a>AnIndexedTraversal</a> i)
--   </pre>
type AnIndexedTraversal' i s a = AnIndexedTraversal i s s a a

-- | When you see this as an argument to a function, it expects
--   
--   <ul>
--   <li>to be indexed if <tt>p</tt> is an instance of <a>Indexed</a>
--   i,</li>
--   <li>to be unindexed if <tt>p</tt> is <tt>(-&gt;)</tt>,</li>
--   <li>a <a>Traversal</a> if <tt>f</tt> is <a>Applicative</a>,</li>
--   <li>a <a>Getter</a> if <tt>f</tt> is only <tt>Gettable</tt>,</li>
--   <li>a <a>Lens</a> if <tt>p</tt> is only a <a>Functor</a>,</li>
--   <li>a <a>Fold</a> if <tt>f</tt> is <tt>Gettable</tt> and
--   <a>Applicative</a>.</li>
--   </ul>
type Traversing p f s t a b = Over p (BazaarT p f a b) s t a b

-- | <pre>
--   type <a>Traversing'</a> f = <a>Simple</a> (<a>Traversing</a> f)
--   </pre>
type Traversing' p f s a = Traversing p f s s a a

-- | Map each element of a structure targeted by a <a>Lens</a> or
--   <a>Traversal</a>, evaluate these actions from left to right, and
--   collect the results.
--   
--   This function is only provided for consistency, <a>id</a> is strictly
--   more general.
--   
--   <pre>
--   &gt;&gt;&gt; traverseOf each print (1,2,3)
--   1
--   2
--   3
--   ((),(),())
--   </pre>
--   
--   <pre>
--   <a>traverseOf</a> ≡ <a>id</a>
--   <a>itraverseOf</a> l ≡ <a>traverseOf</a> l <a>.</a> <a>Indexed</a>
--   </pre>
--   
--   This yields the obvious law:
--   
--   <pre>
--   <a>traverse</a> ≡ <a>traverseOf</a> <a>traverse</a>
--   </pre>
--   
--   <pre>
--   <a>traverseOf</a> :: <a>Functor</a> f =&gt; <a>Iso</a> s t a b       -&gt; (a -&gt; f b) -&gt; s -&gt; f t
--   <a>traverseOf</a> :: <a>Functor</a> f =&gt; <a>Lens</a> s t a b      -&gt; (a -&gt; f b) -&gt; s -&gt; f t
--   <a>traverseOf</a> :: <a>Applicative</a> f =&gt; <a>Traversal</a> s t a b -&gt; (a -&gt; f b) -&gt; s -&gt; f t
--   </pre>
traverseOf :: Over p f s t a b -> p a (f b) -> s -> f t

-- | A version of <a>traverseOf</a> with the arguments flipped, such that:
--   
--   <pre>
--   &gt;&gt;&gt; forOf each (1,2,3) print
--   1
--   2
--   3
--   ((),(),())
--   </pre>
--   
--   This function is only provided for consistency, <a>flip</a> is
--   strictly more general.
--   
--   <pre>
--   <a>forOf</a> ≡ <a>flip</a>
--   <a>forOf</a> ≡ <a>flip</a> . <a>traverseOf</a>
--   </pre>
--   
--   <pre>
--   <a>for</a> ≡ <a>forOf</a> <a>traverse</a>
--   <a>ifor</a> l s ≡ <a>for</a> l s <a>.</a> <a>Indexed</a>
--   </pre>
--   
--   <pre>
--   <a>forOf</a> :: <a>Functor</a> f =&gt; <a>Iso</a> s t a b -&gt; s -&gt; (a -&gt; f b) -&gt; f t
--   <a>forOf</a> :: <a>Functor</a> f =&gt; <a>Lens</a> s t a b -&gt; s -&gt; (a -&gt; f b) -&gt; f t
--   <a>forOf</a> :: <a>Applicative</a> f =&gt; <a>Traversal</a> s t a b -&gt; s -&gt; (a -&gt; f b) -&gt; f t
--   </pre>
forOf :: Over p f s t a b -> s -> p a (f b) -> f t

-- | Evaluate each action in the structure from left to right, and collect
--   the results.
--   
--   <pre>
--   &gt;&gt;&gt; sequenceAOf both ([1,2],[3,4])
--   [(1,3),(1,4),(2,3),(2,4)]
--   </pre>
--   
--   <pre>
--   <a>sequenceA</a> ≡ <a>sequenceAOf</a> <a>traverse</a> ≡ <a>traverse</a> <a>id</a>
--   <a>sequenceAOf</a> l ≡ <a>traverseOf</a> l <a>id</a> ≡ l <a>id</a>
--   </pre>
--   
--   <pre>
--   <a>sequenceAOf</a> :: <a>Functor</a> f =&gt; <a>Iso</a> s t (f b) b       -&gt; s -&gt; f t
--   <a>sequenceAOf</a> :: <a>Functor</a> f =&gt; <a>Lens</a> s t (f b) b      -&gt; s -&gt; f t
--   <a>sequenceAOf</a> :: <a>Applicative</a> f =&gt; <a>Traversal</a> s t (f b) b -&gt; s -&gt; f t
--   </pre>
sequenceAOf :: LensLike f s t (f b) b -> s -> f t

-- | Map each element of a structure targeted by a <a>Lens</a> to a monadic
--   action, evaluate these actions from left to right, and collect the
--   results.
--   
--   <pre>
--   &gt;&gt;&gt; mapMOf both (\x -&gt; [x, x + 1]) (1,3)
--   [(1,3),(1,4),(2,3),(2,4)]
--   </pre>
--   
--   <pre>
--   <a>mapM</a> ≡ <a>mapMOf</a> <a>traverse</a>
--   <a>imapMOf</a> l ≡ <a>forM</a> l <a>.</a> <a>Indexed</a>
--   </pre>
--   
--   <pre>
--   <a>mapMOf</a> :: <a>Monad</a> m =&gt; <a>Iso</a> s t a b       -&gt; (a -&gt; m b) -&gt; s -&gt; m t
--   <a>mapMOf</a> :: <a>Monad</a> m =&gt; <a>Lens</a> s t a b      -&gt; (a -&gt; m b) -&gt; s -&gt; m t
--   <a>mapMOf</a> :: <a>Monad</a> m =&gt; <a>Traversal</a> s t a b -&gt; (a -&gt; m b) -&gt; s -&gt; m t
--   </pre>
mapMOf :: Profunctor p => Over p (WrappedMonad m) s t a b -> p a (m b) -> s -> m t

-- | <a>forMOf</a> is a flipped version of <a>mapMOf</a>, consistent with
--   the definition of <a>forM</a>.
--   
--   <pre>
--   &gt;&gt;&gt; forMOf both (1,3) $ \x -&gt; [x, x + 1]
--   [(1,3),(1,4),(2,3),(2,4)]
--   </pre>
--   
--   <pre>
--   <a>forM</a> ≡ <a>forMOf</a> <a>traverse</a>
--   <a>forMOf</a> l ≡ <a>flip</a> (<a>mapMOf</a> l)
--   <a>iforMOf</a> l s ≡ <a>forM</a> l s <a>.</a> <a>Indexed</a>
--   </pre>
--   
--   <pre>
--   <a>forMOf</a> :: <a>Monad</a> m =&gt; <a>Iso</a> s t a b       -&gt; s -&gt; (a -&gt; m b) -&gt; m t
--   <a>forMOf</a> :: <a>Monad</a> m =&gt; <a>Lens</a> s t a b      -&gt; s -&gt; (a -&gt; m b) -&gt; m t
--   <a>forMOf</a> :: <a>Monad</a> m =&gt; <a>Traversal</a> s t a b -&gt; s -&gt; (a -&gt; m b) -&gt; m t
--   </pre>
forMOf :: Profunctor p => Over p (WrappedMonad m) s t a b -> s -> p a (m b) -> m t

-- | Sequence the (monadic) effects targeted by a <a>Lens</a> in a
--   container from left to right.
--   
--   <pre>
--   &gt;&gt;&gt; sequenceOf each ([1,2],[3,4],[5,6])
--   [(1,3,5),(1,3,6),(1,4,5),(1,4,6),(2,3,5),(2,3,6),(2,4,5),(2,4,6)]
--   </pre>
--   
--   <pre>
--   <a>sequence</a> ≡ <a>sequenceOf</a> <a>traverse</a>
--   <a>sequenceOf</a> l ≡ <a>mapMOf</a> l <a>id</a>
--   <a>sequenceOf</a> l ≡ <a>unwrapMonad</a> <a>.</a> l <a>WrapMonad</a>
--   </pre>
--   
--   <pre>
--   <a>sequenceOf</a> :: <a>Monad</a> m =&gt; <a>Iso</a> s t (m b) b       -&gt; s -&gt; m t
--   <a>sequenceOf</a> :: <a>Monad</a> m =&gt; <a>Lens</a> s t (m b) b      -&gt; s -&gt; m t
--   <a>sequenceOf</a> :: <a>Monad</a> m =&gt; <a>Traversal</a> s t (m b) b -&gt; s -&gt; m t
--   </pre>
sequenceOf :: LensLike (WrappedMonad m) s t (m b) b -> s -> m t

-- | This generalizes <a>transpose</a> to an arbitrary <a>Traversal</a>.
--   
--   Note: <a>transpose</a> handles ragged inputs more intelligently, but
--   for non-ragged inputs:
--   
--   <pre>
--   &gt;&gt;&gt; transposeOf traverse [[1,2,3],[4,5,6]]
--   [[1,4],[2,5],[3,6]]
--   </pre>
--   
--   <pre>
--   <a>transpose</a> ≡ <a>transposeOf</a> <a>traverse</a>
--   </pre>
--   
--   Since every <a>Lens</a> is a <a>Traversal</a>, we can use this as a
--   form of monadic strength as well:
--   
--   <pre>
--   <a>transposeOf</a> <a>_2</a> :: (b, [a]) -&gt; [(b, a)]
--   </pre>
transposeOf :: LensLike ZipList s t [a] a -> s -> [t]

-- | This generalizes <a>mapAccumL</a> to an arbitrary <a>Traversal</a>.
--   
--   <pre>
--   <a>mapAccumL</a> ≡ <a>mapAccumLOf</a> <a>traverse</a>
--   </pre>
--   
--   <a>mapAccumLOf</a> accumulates <a>State</a> from left to right.
--   
--   <pre>
--   <a>mapAccumLOf</a> :: <a>Iso</a> s t a b       -&gt; (acc -&gt; a -&gt; (acc, b)) -&gt; acc -&gt; s -&gt; (acc, t)
--   <a>mapAccumLOf</a> :: <a>Lens</a> s t a b      -&gt; (acc -&gt; a -&gt; (acc, b)) -&gt; acc -&gt; s -&gt; (acc, t)
--   <a>mapAccumLOf</a> :: <a>Traversal</a> s t a b -&gt; (acc -&gt; a -&gt; (acc, b)) -&gt; acc -&gt; s -&gt; (acc, t)
--   </pre>
--   
--   <pre>
--   <a>mapAccumLOf</a> :: <a>LensLike</a> (<a>State</a> acc) s t a b -&gt; (acc -&gt; a -&gt; (acc, b)) -&gt; acc -&gt; s -&gt; (acc, t)
--   <a>mapAccumLOf</a> l f acc0 s = <a>swap</a> (<a>runState</a> (l (a -&gt; <a>state</a> (acc -&gt; <a>swap</a> (f acc a))) s) acc0)
--   </pre>
mapAccumLOf :: Conjoined p => Over p (State acc) s t a b -> p acc (a -> (acc, b)) -> acc -> s -> (acc, t)

-- | This generalizes <a>mapAccumR</a> to an arbitrary <a>Traversal</a>.
--   
--   <pre>
--   <a>mapAccumR</a> ≡ <a>mapAccumROf</a> <a>traverse</a>
--   </pre>
--   
--   <a>mapAccumROf</a> accumulates <a>State</a> from right to left.
--   
--   <pre>
--   <a>mapAccumROf</a> :: <a>Iso</a> s t a b       -&gt; (acc -&gt; a -&gt; (acc, b)) -&gt; acc -&gt; s -&gt; (acc, t)
--   <a>mapAccumROf</a> :: <a>Lens</a> s t a b      -&gt; (acc -&gt; a -&gt; (acc, b)) -&gt; acc -&gt; s -&gt; (acc, t)
--   <a>mapAccumROf</a> :: <a>Traversal</a> s t a b -&gt; (acc -&gt; a -&gt; (acc, b)) -&gt; acc -&gt; s -&gt; (acc, t)
--   </pre>
--   
--   <pre>
--   <a>mapAccumROf</a> :: <a>LensLike</a> (<a>Backwards</a> (<a>State</a> acc)) s t a b -&gt; (acc -&gt; a -&gt; (acc, b)) -&gt; acc -&gt; s -&gt; (acc, t)
--   </pre>
mapAccumROf :: Conjoined p => Over p (Backwards (State acc)) s t a b -> p acc (a -> (acc, b)) -> acc -> s -> (acc, t)

-- | This permits the use of <a>scanr1</a> over an arbitrary
--   <a>Traversal</a> or <a>Lens</a>.
--   
--   <pre>
--   <a>scanr1</a> ≡ <a>scanr1Of</a> <a>traverse</a>
--   </pre>
--   
--   <pre>
--   <a>scanr1Of</a> :: <a>Iso</a> s t a a       -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; t
--   <a>scanr1Of</a> :: <a>Lens</a> s t a a      -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; t
--   <a>scanr1Of</a> :: <a>Traversal</a> s t a a -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; t
--   </pre>
scanr1Of :: LensLike (Backwards (State (Maybe a))) s t a a -> (a -> a -> a) -> s -> t

-- | This permits the use of <a>scanl1</a> over an arbitrary
--   <a>Traversal</a> or <a>Lens</a>.
--   
--   <pre>
--   <a>scanl1</a> ≡ <a>scanl1Of</a> <a>traverse</a>
--   </pre>
--   
--   <pre>
--   <a>scanl1Of</a> :: <a>Iso</a> s t a a       -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; t
--   <a>scanl1Of</a> :: <a>Lens</a> s t a a      -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; t
--   <a>scanl1Of</a> :: <a>Traversal</a> s t a a -&gt; (a -&gt; a -&gt; a) -&gt; s -&gt; t
--   </pre>
scanl1Of :: LensLike (State (Maybe a)) s t a a -> (a -> a -> a) -> s -> t

-- | Try to map a function over this <a>Traversal</a>, failing if the
--   <a>Traversal</a> has no targets.
--   
--   <pre>
--   &gt;&gt;&gt; failover (element 3) (*2) [1,2] :: Maybe [Int]
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; failover _Left (*2) (Right 4) :: Maybe (Either Int Int)
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; failover _Right (*2) (Right 4) :: Maybe (Either Int Int)
--   Just (Right 8)
--   </pre>
failover :: MonadPlus m => LensLike ((,) Any) s t a b -> (a -> b) -> s -> m t

-- | A <a>Traversal</a> is completely characterized by its behavior on a
--   <a>Bazaar</a>.
--   
--   Cloning a <a>Traversal</a> is one way to make sure you aren't given
--   something weaker, such as a <a>Fold</a> and can be used as a way to
--   pass around traversals that have to be monomorphic in <tt>f</tt>.
--   
--   Note: This only accepts a proper <a>Traversal</a> (or <a>Lens</a>). To
--   clone a <a>Lens</a> as such, use <a>cloneLens</a>.
--   
--   Note: It is usually better to use <a>ReifiedTraversal</a> and
--   <a>reflectTraversal</a> than to <a>cloneTraversal</a>. The former can
--   execute at full speed, while the latter needs to round trip through
--   the <a>Bazaar</a>.
--   
--   <pre>
--   &gt;&gt;&gt; let foo l a = (view (coerced (cloneTraversal l)) a, set (cloneTraversal l) 10 a)
--   
--   &gt;&gt;&gt; foo both ("hello","world")
--   ("helloworld",(10,10))
--   </pre>
--   
--   <pre>
--   <a>cloneTraversal</a> :: <a>LensLike</a> (<a>Bazaar</a> (-&gt;) a b) s t a b -&gt; <a>Traversal</a> s t a b
--   </pre>
cloneTraversal :: ATraversal s t a b -> Traversal s t a b

-- | Clone a <a>Traversal</a> yielding an <a>IndexPreservingTraversal</a>
--   that passes through whatever index it is composed with.
cloneIndexPreservingTraversal :: ATraversal s t a b -> IndexPreservingTraversal s t a b

-- | Clone an <a>IndexedTraversal</a> yielding an <a>IndexedTraversal</a>
--   with the same index.
cloneIndexedTraversal :: AnIndexedTraversal i s t a b -> IndexedTraversal i s t a b

-- | <a>partsOf</a> turns a <a>Traversal</a> into a <a>Lens</a> that
--   resembles an early version of the <a>uniplate</a> (or <a>biplate</a>)
--   type.
--   
--   <i>Note:</i> You should really try to maintain the invariant of the
--   number of children in the list.
--   
--   Any extras will be lost. If you do not supply enough, then the
--   remainder will come from the original structure.
--   
--   So technically, this is only a <a>Lens</a> if you do not change the
--   number of results it returns.
--   
--   When applied to a <a>Fold</a> the result is merely a <a>Getter</a>.
--   
--   <pre>
--   <a>partsOf</a> :: <a>Iso'</a> s a       -&gt; <a>Lens'</a> s [a]
--   <a>partsOf</a> :: <a>Lens'</a> s a      -&gt; <a>Lens'</a> s [a]
--   <a>partsOf</a> :: <a>Traversal'</a> s a -&gt; <a>Lens'</a> s [a]
--   <a>partsOf</a> :: <a>Fold</a> s a       -&gt; <a>Getter</a> s [a]
--   <a>partsOf</a> :: <a>Getter</a> s a     -&gt; <a>Getter</a> s [a]
--   </pre>
partsOf :: Functor f => Traversing (->) f s t a a -> LensLike f s t [a] [a]

-- | A type-restricted version of <a>partsOf</a> that can only be used with
--   a <a>Traversal</a>.
partsOf' :: ATraversal s t a a -> Lens s t [a] [a]

-- | <a>unsafePartsOf</a> turns a <a>Traversal</a> into a <a>uniplate</a>
--   (or <a>biplate</a>) family.
--   
--   If you do not need the types of <tt>s</tt> and <tt>t</tt> to be
--   different, it is recommended that you use <a>partsOf</a>.
--   
--   It is generally safer to traverse with the <a>Bazaar</a> rather than
--   use this combinator. However, it is sometimes convenient.
--   
--   This is unsafe because if you don't supply at least as many
--   <tt>b</tt>'s as you were given <tt>a</tt>'s, then the reconstruction
--   of <tt>t</tt> <i>will</i> result in an error!
--   
--   When applied to a <a>Fold</a> the result is merely a <a>Getter</a>
--   (and becomes safe).
--   
--   <pre>
--   <a>unsafePartsOf</a> :: <a>Iso</a> s t a b       -&gt; <a>Lens</a> s t [a] [b]
--   <a>unsafePartsOf</a> :: <a>Lens</a> s t a b      -&gt; <a>Lens</a> s t [a] [b]
--   <a>unsafePartsOf</a> :: <a>Traversal</a> s t a b -&gt; <a>Lens</a> s t [a] [b]
--   <a>unsafePartsOf</a> :: <a>Fold</a> s a          -&gt; <a>Getter</a> s [a]
--   <a>unsafePartsOf</a> :: <a>Getter</a> s a        -&gt; <a>Getter</a> s [a]
--   </pre>
unsafePartsOf :: Functor f => Traversing (->) f s t a b -> LensLike f s t [a] [b]
unsafePartsOf' :: ATraversal s t a b -> Lens s t [a] [b]

-- | The one-level version of <a>contextsOf</a>. This extracts a list of
--   the immediate children according to a given <a>Traversal</a> as
--   editable contexts.
--   
--   Given a context you can use <a>pos</a> to see the values, <a>peek</a>
--   at what the structure would be like with an edited result, or simply
--   <a>extract</a> the original structure.
--   
--   <pre>
--   propChildren l x = childrenOf l x <a>==</a> <a>map</a> <a>pos</a> (<a>holesOf</a> l x)
--   propId l x = <a>all</a> (<a>==</a> x) [<a>extract</a> w | w &lt;- <a>holesOf</a> l x]
--   </pre>
--   
--   <pre>
--   <a>holesOf</a> :: <a>Iso'</a> s a                -&gt; s -&gt; [<a>Pretext'</a> (-&gt;) a s]
--   <a>holesOf</a> :: <a>Lens'</a> s a               -&gt; s -&gt; [<a>Pretext'</a> (-&gt;) a s]
--   <a>holesOf</a> :: <a>Traversal'</a> s a          -&gt; s -&gt; [<a>Pretext'</a> (-&gt;) a s]
--   <a>holesOf</a> :: <a>IndexedLens'</a> i s a      -&gt; s -&gt; [<a>Pretext'</a> (<a>Indexed</a> i) a s]
--   <a>holesOf</a> :: <a>IndexedTraversal'</a> i s a -&gt; s -&gt; [<a>Pretext'</a> (<a>Indexed</a> i) a s]
--   </pre>
holesOf :: Conjoined p => Over p (Bazaar p a a) s t a a -> s -> [Pretext p a a t]

-- | This converts a <a>Traversal</a> that you "know" will target one or
--   more elements to a <a>Lens</a>. It can also be used to transform a
--   non-empty <a>Fold</a> into a <a>Getter</a> or a non-empty
--   <a>MonadicFold</a> into an <a>Action</a>.
--   
--   The resulting <a>Lens</a>, <a>Getter</a>, or <a>Action</a> will be
--   partial if the supplied <a>Traversal</a> returns no results.
--   
--   <pre>
--   <a>singular</a> :: <a>Traversal</a> s t a a          -&gt; <a>Lens</a> s t a a
--   <a>singular</a> :: <a>Fold</a> s a                   -&gt; <a>Getter</a> s a
--   <a>singular</a> :: <a>MonadicFold</a> m s a          -&gt; <a>Action</a> m s a
--   <a>singular</a> :: <a>IndexedTraversal</a> i s t a a -&gt; <a>IndexedLens</a> i s t a a
--   <a>singular</a> :: <a>IndexedFold</a> i s a          -&gt; <a>IndexedGetter</a> i s a
--   <a>singular</a> :: <a>IndexedMonadicFold</a> i m s a -&gt; <a>IndexedAction</a> i m s a
--   </pre>
singular :: (Conjoined p, Functor f) => Over p (BazaarT p f a a) s t a a -> Over p f s t a a

-- | This converts a <a>Traversal</a> that you "know" will target only one
--   element to a <a>Lens</a>. It can also be used to transform a
--   <a>Fold</a> into a <a>Getter</a> or a <a>MonadicFold</a> into an
--   <a>Action</a>.
--   
--   The resulting <a>Lens</a>, <a>Getter</a>, or <a>Action</a> will be
--   partial if the <a>Traversal</a> targets nothing or more than one
--   element.
--   
--   <pre>
--   <a>unsafeSingular</a> :: <a>Traversal</a> s t a b          -&gt; <a>Lens</a> s t a b
--   <a>unsafeSingular</a> :: <a>Fold</a> s a                   -&gt; <a>Getter</a> s a
--   <a>unsafeSingular</a> :: <a>MonadicFold</a> m s a          -&gt; <a>Action</a> m s a
--   <a>unsafeSingular</a> :: <a>IndexedTraversal</a> i s t a b -&gt; <a>IndexedLens</a> i s t a b
--   <a>unsafeSingular</a> :: <a>IndexedFold</a> i s a          -&gt; <a>IndexedGetter</a> i s a
--   <a>unsafeSingular</a> :: <a>IndexedMonadicFold</a> i m s a -&gt; <a>IndexedAction</a> i m s a
--   </pre>
unsafeSingular :: (Conjoined p, Functor f) => Over p (BazaarT p f a b) s t a b -> Over p f s t a b

-- | Functors representing data structures that can be traversed from left
--   to right.
--   
--   Minimal complete definition: <a>traverse</a> or <a>sequenceA</a>.
--   
--   Instances are similar to <a>Functor</a>, e.g. given a data type
--   
--   <pre>
--   data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
--   </pre>
--   
--   a suitable instance would be
--   
--   <pre>
--   instance Traversable Tree where
--      traverse f Empty = pure Empty
--      traverse f (Leaf x) = Leaf &lt;$&gt; f x
--      traverse f (Node l k r) = Node &lt;$&gt; traverse f l &lt;*&gt; f k &lt;*&gt; traverse f r
--   </pre>
--   
--   This is suitable even for abstract types, as the laws for
--   <a>&lt;*&gt;</a> imply a form of associativity.
--   
--   The superclass instances should satisfy the following:
--   
--   <ul>
--   <li>In the <a>Functor</a> instance, <a>fmap</a> should be equivalent
--   to traversal with the identity applicative functor
--   (<a>fmapDefault</a>).</li>
--   <li>In the <a>Foldable</a> instance, <a>foldMap</a> should be
--   equivalent to traversal with a constant applicative functor
--   (<a>foldMapDefault</a>).</li>
--   </ul>
class (Functor t, Foldable t) => Traversable (t :: * -> *)
traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)

-- | Traverse both parts of a tuple with matching types.
--   
--   <pre>
--   &gt;&gt;&gt; both *~ 10 $ (1,2)
--   (10,20)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over both length ("hello","world")
--   (5,5)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world")^.both
--   "helloworld"
--   </pre>
both :: Traversal (a, a) (b, b) a b

-- | Apply a different <a>Traversal</a> or <a>Fold</a> to each side of a
--   tuple.
--   
--   <pre>
--   <a>beside</a> :: <a>Traversal</a> s t a b                -&gt; <a>Traversal</a> s' t' a b                -&gt; <a>Traversal</a> (s,s') (t,t') a b
--   <a>beside</a> :: <a>Lens</a> s t a b                     -&gt; <a>Lens</a> s' t' a b                     -&gt; <a>Traversal</a> (s,s') (t,t') a b
--   <a>beside</a> :: <a>Fold</a> s a                         -&gt; <a>Fold</a> s' a                          -&gt; <a>Fold</a> (s,s') a
--   <a>beside</a> :: <a>Getter</a> s a                       -&gt; <a>Getter</a> s' a                        -&gt; <a>Fold</a> (s,s') a
--   <a>beside</a> :: <a>Action</a> m s a                     -&gt; <a>Action</a> m s' a                      -&gt; <a>MonadicFold</a> m (s,s') a
--   <a>beside</a> :: <a>MonadicFold</a> m s a                -&gt; <a>MonadicFold</a> m s' a                 -&gt; <a>MonadicFold</a> m (s,s') a
--   </pre>
--   
--   <pre>
--   <a>beside</a> :: <a>IndexedTraversal</a> i s t a b       -&gt; <a>IndexedTraversal</a> i s' t' a b       -&gt; <a>IndexedTraversal</a> i (s,s') (t,t') a b
--   <a>beside</a> :: <a>IndexedLens</a> i s t a b            -&gt; <a>IndexedLens</a> i s' t' a b            -&gt; <a>IndexedTraversal</a> i (s,s') (t,t') a b
--   <a>beside</a> :: <a>IndexedFold</a> i s a                -&gt; <a>IndexedFold</a> i s' a                 -&gt; <a>IndexedFold</a> i (s,s') a
--   <a>beside</a> :: <a>IndexedGetter</a> i s a              -&gt; <a>IndexedGetter</a> i s' a               -&gt; <a>IndexedFold</a> i (s,s') a
--   <a>beside</a> :: <a>IndexedAction</a> i m s a            -&gt; <a>IndexedAction</a> i m s' a             -&gt; <a>IndexedMonadicFold</a> i m (s,s') a
--   <a>beside</a> :: <a>IndexedMonadicFold</a> i m s a       -&gt; <a>IndexedMonadicFold</a> i m s' a        -&gt; <a>IndexedMonadicFold</a> i m (s,s') a
--   </pre>
--   
--   <pre>
--   <a>beside</a> :: <a>IndexPreservingTraversal</a> s t a b -&gt; <a>IndexPreservingTraversal</a> s' t' a b -&gt; <a>IndexPreservingTraversal</a> (s,s') (t,t') a b
--   <a>beside</a> :: <a>IndexPreservingLens</a> s t a b      -&gt; <a>IndexPreservingLens</a> s' t' a b      -&gt; <a>IndexPreservingTraversal</a> (s,s') (t,t') a b
--   <a>beside</a> :: <a>IndexPreservingFold</a> s a          -&gt; <a>IndexPreservingFold</a> s' a           -&gt; <a>IndexPreservingFold</a> (s,s') a
--   <a>beside</a> :: <a>IndexPreservingGetter</a> s a        -&gt; <a>IndexPreservingGetter</a> s' a         -&gt; <a>IndexPreservingFold</a> (s,s') a
--   <a>beside</a> :: <a>IndexPreservingAction</a> m s a      -&gt; <a>IndexPreservingAction</a> m s' a       -&gt; <a>IndexPreservingMonadicFold</a> m (s,s') a
--   <a>beside</a> :: <a>IndexPreservingMonadicFold</a> m s a -&gt; <a>IndexPreservingMonadicFold</a> m s' a  -&gt; <a>IndexPreservingMonadicFold</a> m (s,s') a
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ("hello",["world","!!!"])^..beside id traverse
--   ["hello","world","!!!"]
--   </pre>
beside :: (Representable q, Applicative (Rep q), Applicative f) => Overloading p q f s t a b -> Overloading p q f s' t' a b -> Overloading p q f (s, s') (t, t') a b

-- | Visit the first <i>n</i> targets of a <a>Traversal</a>, <a>Fold</a>,
--   <a>Getter</a> or <a>Lens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; [("hello","world"),("!!!","!!!")]^.. taking 2 (traverse.both)
--   ["hello","world"]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; timingOut $ [1..] ^.. taking 3 traverse
--   [1,2,3]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over (taking 5 traverse) succ "hello world"
--   "ifmmp world"
--   </pre>
--   
--   <pre>
--   <a>taking</a> :: <a>Int</a> -&gt; <a>Traversal'</a> s a                   -&gt; <a>Traversal'</a> s a
--   <a>taking</a> :: <a>Int</a> -&gt; <a>Lens'</a> s a                        -&gt; <a>Traversal'</a> s a
--   <a>taking</a> :: <a>Int</a> -&gt; <a>Iso'</a> s a                         -&gt; <a>Traversal'</a> s a
--   <a>taking</a> :: <a>Int</a> -&gt; <a>Prism'</a> s a                       -&gt; <a>Traversal'</a> s a
--   <a>taking</a> :: <a>Int</a> -&gt; <a>Getter</a> s a                       -&gt; <a>Fold</a> s a
--   <a>taking</a> :: <a>Int</a> -&gt; <a>Fold</a> s a                         -&gt; <a>Fold</a> s a
--   <a>taking</a> :: <a>Int</a> -&gt; <a>Action</a> m s a                     -&gt; <a>MonadicFold</a> m s a
--   <a>taking</a> :: <a>Int</a> -&gt; <a>MonadicFold</a> m s a                -&gt; <a>MonadicFold</a> m s a
--   <a>taking</a> :: <a>Int</a> -&gt; <a>IndexedTraversal'</a> i s a          -&gt; <a>IndexedTraversal'</a> i s a
--   <a>taking</a> :: <a>Int</a> -&gt; <a>IndexedLens'</a> i s a               -&gt; <a>IndexedTraversal'</a> i s a
--   <a>taking</a> :: <a>Int</a> -&gt; <a>IndexedGetter</a> i s a              -&gt; <a>IndexedFold</a> i s a
--   <a>taking</a> :: <a>Int</a> -&gt; <a>IndexedFold</a> i s a                -&gt; <a>IndexedFold</a> i s a
--   <a>taking</a> :: <a>Int</a> -&gt; <a>IndexedAction</a> i m s a            -&gt; <a>IndexedMonadicFold</a> i m s a
--   <a>taking</a> :: <a>Int</a> -&gt; <a>IndexedMonadicFold</a> i m s a       -&gt; <a>IndexedMonadicFold</a> i m s a
--   </pre>
taking :: (Conjoined p, Applicative f) => Int -> Over p (BazaarT p f a a) s t a a -> Over p f s t a a

-- | Visit all but the first <i>n</i> targets of a <a>Traversal</a>,
--   <a>Fold</a>, <a>Getter</a> or <a>Lens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world") ^? dropping 1 both
--   Just "world"
--   </pre>
--   
--   Dropping works on infinite traversals as well:
--   
--   <pre>
--   &gt;&gt;&gt; [1..] ^? dropping 1 folded
--   Just 2
--   </pre>
--   
--   <pre>
--   <a>dropping</a> :: <a>Int</a> -&gt; <a>Traversal'</a> s a                   -&gt; <a>Traversal'</a> s a
--   <a>dropping</a> :: <a>Int</a> -&gt; <a>Lens'</a> s a                        -&gt; <a>Traversal'</a> s a
--   <a>dropping</a> :: <a>Int</a> -&gt; <a>Iso'</a> s a                         -&gt; <a>Traversal'</a> s a
--   <a>dropping</a> :: <a>Int</a> -&gt; <a>Prism'</a> s a                       -&gt; <a>Traversal'</a> s a
--   <a>dropping</a> :: <a>Int</a> -&gt; <a>Getter</a> s a                       -&gt; <a>Fold</a> s a
--   <a>dropping</a> :: <a>Int</a> -&gt; <a>Fold</a> s a                         -&gt; <a>Fold</a> s a
--   <a>dropping</a> :: <a>Int</a> -&gt; <a>Action</a> m s a                     -&gt; <a>MonadicFold</a> m s a
--   <a>dropping</a> :: <a>Int</a> -&gt; <a>MonadicFold</a> m s a                -&gt; <a>MonadicFold</a> m s a
--   <a>dropping</a> :: <a>Int</a> -&gt; <a>IndexedTraversal'</a> i s a          -&gt; <a>IndexedTraversal'</a> i s a
--   <a>dropping</a> :: <a>Int</a> -&gt; <a>IndexedLens'</a> i s a               -&gt; <a>IndexedTraversal'</a> i s a
--   <a>dropping</a> :: <a>Int</a> -&gt; <a>IndexedGetter</a> i s a              -&gt; <a>IndexedFold</a> i s a
--   <a>dropping</a> :: <a>Int</a> -&gt; <a>IndexedFold</a> i s a                -&gt; <a>IndexedFold</a> i s a
--   <a>dropping</a> :: <a>Int</a> -&gt; <a>IndexedAction</a> i m s a            -&gt; <a>IndexedMonadicFold</a> i m s a
--   <a>dropping</a> :: <a>Int</a> -&gt; <a>IndexedMonadicFold</a> i m s a       -&gt; <a>IndexedMonadicFold</a> i m s a
--   </pre>
dropping :: (Conjoined p, Applicative f) => Int -> Over p (Indexing f) s t a a -> Over p f s t a a

-- | This is the trivial empty <a>Traversal</a>.
--   
--   <pre>
--   <a>ignored</a> :: <a>IndexedTraversal</a> i s s a b
--   </pre>
--   
--   <pre>
--   <a>ignored</a> ≡ <a>const</a> <a>pure</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; 6 &amp; ignored %~ absurd
--   6
--   </pre>
ignored :: Applicative f => pafb -> s -> f s

-- | Allows <a>IndexedTraversal</a> the value at the smallest index.
class Ord k => TraverseMin k m | m -> k
traverseMin :: TraverseMin k m => IndexedTraversal' k (m v) v

-- | Allows <a>IndexedTraversal</a> of the value at the largest index.
class Ord k => TraverseMax k m | m -> k
traverseMax :: TraverseMax k m => IndexedTraversal' k (m v) v

-- | Traverse any <a>Traversable</a> container. This is an
--   <a>IndexedTraversal</a> that is indexed by ordinal position.
traversed :: Traversable f => IndexedTraversal Int (f a) (f b) a b

-- | Traverse any <a>Traversable</a> container. This is an
--   <a>IndexedTraversal</a> that is indexed by ordinal position.
traversed64 :: Traversable f => IndexedTraversal Int64 (f a) (f b) a b

-- | Traverse the <i>nth</i> element <a>elementOf</a> a <a>Traversal</a>,
--   <a>Lens</a> or <a>Iso</a> if it exists.
--   
--   <pre>
--   &gt;&gt;&gt; [[1],[3,4]] &amp; elementOf (traverse.traverse) 1 .~ 5
--   [[1],[5,4]]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [[1],[3,4]] ^? elementOf (folded.folded) 1
--   Just 3
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; timingOut $ ['a'..] ^?! elementOf folded 5
--   'f'
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; timingOut $ take 10 $ elementOf traverse 3 .~ 16 $ [0..]
--   [0,1,2,16,4,5,6,7,8,9]
--   </pre>
--   
--   <pre>
--   <a>elementOf</a> :: <a>Traversal'</a> s a -&gt; <a>Int</a> -&gt; <a>IndexedTraversal'</a> <a>Int</a> s a
--   <a>elementOf</a> :: <a>Fold</a> s a       -&gt; <a>Int</a> -&gt; <a>IndexedFold</a> <a>Int</a> s a
--   </pre>
elementOf :: Applicative f => LensLike (Indexing f) s t a a -> Int -> IndexedLensLike Int f s t a a

-- | Traverse the <i>nth</i> element of a <a>Traversable</a> container.
--   
--   <pre>
--   <a>element</a> ≡ <a>elementOf</a> <a>traverse</a>
--   </pre>
element :: Traversable t => Int -> IndexedTraversal' Int (t a) a

-- | Traverse (or fold) selected elements of a <a>Traversal</a> (or
--   <a>Fold</a>) where their ordinal positions match a predicate.
--   
--   <pre>
--   <a>elementsOf</a> :: <a>Traversal'</a> s a -&gt; (<a>Int</a> -&gt; <a>Bool</a>) -&gt; <a>IndexedTraversal'</a> <a>Int</a> s a
--   <a>elementsOf</a> :: <a>Fold</a> s a       -&gt; (<a>Int</a> -&gt; <a>Bool</a>) -&gt; <a>IndexedFold</a> <a>Int</a> s a
--   </pre>
elementsOf :: Applicative f => LensLike (Indexing f) s t a a -> (Int -> Bool) -> IndexedLensLike Int f s t a a

-- | Traverse elements of a <a>Traversable</a> container where their
--   ordinal positions matches a predicate.
--   
--   <pre>
--   <a>elements</a> ≡ <a>elementsOf</a> <a>traverse</a>
--   </pre>
elements :: Traversable t => (Int -> Bool) -> IndexedTraversal' Int (t a) a

-- | An indexed version of <a>partsOf</a> that receives the entire list of
--   indices as its index.
ipartsOf :: (Indexable [i] p, Functor f) => Traversing (Indexed i) f s t a a -> Over p f s t [a] [a]

-- | A type-restricted version of <a>ipartsOf</a> that can only be used
--   with an <a>IndexedTraversal</a>.
ipartsOf' :: (Indexable [i] p, Functor f) => Over (Indexed i) (Bazaar' (Indexed i) a) s t a a -> Over p f s t [a] [a]

-- | An indexed version of <a>unsafePartsOf</a> that receives the entire
--   list of indices as its index.
iunsafePartsOf :: (Indexable [i] p, Functor f) => Traversing (Indexed i) f s t a b -> Over p f s t [a] [b]
iunsafePartsOf' :: Over (Indexed i) (Bazaar (Indexed i) a b) s t a b -> IndexedLens [i] s t [a] [b]

-- | Traversal with an index.
--   
--   <i>NB:</i> When you don't need access to the index then you can just
--   apply your <a>IndexedTraversal</a> directly as a function!
--   
--   <pre>
--   <a>itraverseOf</a> ≡ <a>withIndex</a>
--   <a>traverseOf</a> l = <a>itraverseOf</a> l <a>.</a> <a>const</a> = <a>id</a>
--   </pre>
--   
--   <pre>
--   <a>itraverseOf</a> :: <a>Functor</a> f     =&gt; <a>IndexedLens</a> i s t a b      -&gt; (i -&gt; a -&gt; f b) -&gt; s -&gt; f t
--   <a>itraverseOf</a> :: <a>Applicative</a> f =&gt; <a>IndexedTraversal</a> i s t a b -&gt; (i -&gt; a -&gt; f b) -&gt; s -&gt; f t
--   </pre>
itraverseOf :: (Indexed i a (f b) -> s -> f t) -> (i -> a -> f b) -> s -> f t

-- | Traverse with an index (and the arguments flipped).
--   
--   <pre>
--   <a>forOf</a> l a ≡ <a>iforOf</a> l a <a>.</a> <a>const</a>
--   <a>iforOf</a> ≡ <a>flip</a> <a>.</a> <a>itraverseOf</a>
--   </pre>
--   
--   <pre>
--   <a>iforOf</a> :: <a>Functor</a> f =&gt; <a>IndexedLens</a> i s t a b      -&gt; s -&gt; (i -&gt; a -&gt; f b) -&gt; f t
--   <a>iforOf</a> :: <a>Applicative</a> f =&gt; <a>IndexedTraversal</a> i s t a b -&gt; s -&gt; (i -&gt; a -&gt; f b) -&gt; f t
--   </pre>
iforOf :: (Indexed i a (f b) -> s -> f t) -> s -> (i -> a -> f b) -> f t

-- | Map each element of a structure targeted by a <a>Lens</a> to a monadic
--   action, evaluate these actions from left to right, and collect the
--   results, with access its position.
--   
--   When you don't need access to the index <a>mapMOf</a> is more liberal
--   in what it can accept.
--   
--   <pre>
--   <a>mapMOf</a> l ≡ <a>imapMOf</a> l <a>.</a> <a>const</a>
--   </pre>
--   
--   <pre>
--   <a>imapMOf</a> :: <a>Monad</a> m =&gt; <a>IndexedLens</a>      i s t a b -&gt; (i -&gt; a -&gt; m b) -&gt; s -&gt; m t
--   <a>imapMOf</a> :: <a>Monad</a> m =&gt; <a>IndexedTraversal</a> i s t a b -&gt; (i -&gt; a -&gt; m b) -&gt; s -&gt; m t
--   </pre>
imapMOf :: (Indexed i a (WrappedMonad m b) -> s -> WrappedMonad m t) -> (i -> a -> m b) -> s -> m t

-- | Map each element of a structure targeted by a <a>Lens</a> to a monadic
--   action, evaluate these actions from left to right, and collect the
--   results, with access its position (and the arguments flipped).
--   
--   <pre>
--   <a>forMOf</a> l a ≡ <a>iforMOf</a> l a <a>.</a> <a>const</a>
--   <a>iforMOf</a> ≡ <a>flip</a> <a>.</a> <a>imapMOf</a>
--   </pre>
--   
--   <pre>
--   <a>iforMOf</a> :: <a>Monad</a> m =&gt; <a>IndexedLens</a> i s t a b      -&gt; s -&gt; (i -&gt; a -&gt; m b) -&gt; m t
--   <a>iforMOf</a> :: <a>Monad</a> m =&gt; <a>IndexedTraversal</a> i s t a b -&gt; s -&gt; (i -&gt; a -&gt; m b) -&gt; m t
--   </pre>
iforMOf :: (Indexed i a (WrappedMonad m b) -> s -> WrappedMonad m t) -> s -> (i -> a -> m b) -> m t

-- | Generalizes <a>mapAccumR</a> to an arbitrary <a>IndexedTraversal</a>
--   with access to the index.
--   
--   <a>imapAccumROf</a> accumulates state from right to left.
--   
--   <pre>
--   <a>mapAccumROf</a> l ≡ <a>imapAccumROf</a> l <a>.</a> <a>const</a>
--   </pre>
--   
--   <pre>
--   <a>imapAccumROf</a> :: <a>IndexedLens</a> i s t a b      -&gt; (i -&gt; acc -&gt; a -&gt; (acc, b)) -&gt; acc -&gt; s -&gt; (acc, t)
--   <a>imapAccumROf</a> :: <a>IndexedTraversal</a> i s t a b -&gt; (i -&gt; acc -&gt; a -&gt; (acc, b)) -&gt; acc -&gt; s -&gt; (acc, t)
--   </pre>
imapAccumROf :: Over (Indexed i) (Backwards (State acc)) s t a b -> (i -> acc -> a -> (acc, b)) -> acc -> s -> (acc, t)

-- | Generalizes <a>mapAccumL</a> to an arbitrary <a>IndexedTraversal</a>
--   with access to the index.
--   
--   <a>imapAccumLOf</a> accumulates state from left to right.
--   
--   <pre>
--   <a>mapAccumLOf</a> l ≡ <a>imapAccumLOf</a> l <a>.</a> <a>const</a>
--   </pre>
--   
--   <pre>
--   <a>imapAccumLOf</a> :: <a>IndexedLens</a> i s t a b      -&gt; (i -&gt; acc -&gt; a -&gt; (acc, b)) -&gt; acc -&gt; s -&gt; (acc, t)
--   <a>imapAccumLOf</a> :: <a>IndexedTraversal</a> i s t a b -&gt; (i -&gt; acc -&gt; a -&gt; (acc, b)) -&gt; acc -&gt; s -&gt; (acc, t)
--   </pre>
imapAccumLOf :: Over (Indexed i) (State acc) s t a b -> (i -> acc -> a -> (acc, b)) -> acc -> s -> (acc, t)

-- | This is used to characterize a <a>Traversal</a>.
--   
--   a.k.a. indexed Cartesian store comonad, indexed Kleene store comonad,
--   or an indexed <tt>FunList</tt>.
--   
--   <a>http://twanvl.nl/blog/haskell/non-regular1</a>
--   
--   A <a>Bazaar</a> is like a <a>Traversal</a> that has already been
--   applied to some structure.
--   
--   Where a <tt><a>Context</a> a b t</tt> holds an <tt>a</tt> and a
--   function from <tt>b</tt> to <tt>t</tt>, a <tt><a>Bazaar</a> a b t</tt>
--   holds <tt>N</tt> <tt>a</tt>s and a function from <tt>N</tt>
--   <tt>b</tt>s to <tt>t</tt>, (where <tt>N</tt> might be infinite).
--   
--   Mnemonically, a <a>Bazaar</a> holds many stores and you can easily add
--   more.
--   
--   This is a final encoding of <a>Bazaar</a>.
newtype Bazaar p a b t
Bazaar :: (forall f. Applicative f => p a (f b) -> f t) -> Bazaar p a b t
runBazaar :: Bazaar p a b t -> forall f. Applicative f => p a (f b) -> f t

-- | This alias is helpful when it comes to reducing repetition in type
--   signatures.
--   
--   <pre>
--   type <a>Bazaar'</a> p a t = <a>Bazaar</a> p a a t
--   </pre>
type Bazaar' p a = Bazaar p a a

-- | This <a>Traversal</a> allows you to <a>traverse</a> the individual
--   stores in a <a>Bazaar</a>.
loci :: Traversal (Bazaar (->) a c s) (Bazaar (->) b c s) a b

-- | This <a>IndexedTraversal</a> allows you to <a>traverse</a> the
--   individual stores in a <a>Bazaar</a> with access to their indices.
iloci :: IndexedTraversal i (Bazaar (Indexed i) a c s) (Bazaar (Indexed i) b c s) a b
instance Ord k => TraverseMax k (Map k)
instance TraverseMax Int IntMap
instance Ord k => TraverseMin k (Map k)
instance TraverseMin Int IntMap


-- | (The classes in here need to be defined together for
--   <tt>DefaultSignatures</tt> to work.)
module Control.Lens.Indexed

-- | This class permits overloading of function application for things that
--   also admit a notion of a key or index.
class Conjoined p => Indexable i p
indexed :: Indexable i p => p a b -> i -> a -> b

-- | This is a <a>Profunctor</a> that is both <a>Corepresentable</a> by
--   <tt>f</tt> and <a>Representable</a> by <tt>g</tt> such that <tt>f</tt>
--   is left adjoint to <tt>g</tt>. From this you can derive a lot of
--   structure due to the preservation of limits and colimits.
class (Choice p, Corepresentable p, Comonad (Corep p), Traversable (Corep p), Strong p, Representable p, Monad (Rep p), MonadFix (Rep p), Distributive (Rep p), ArrowLoop p, ArrowApply p, ArrowChoice p) => Conjoined p where distrib = tabulate . collect . rep conjoined _ r = r
distrib :: (Conjoined p, Functor f) => p a b -> p (f a) (f b)
conjoined :: Conjoined p => (p ~ (->) => q (a -> b) r) -> q (p a b) r -> q (p a b) r

-- | A function with access to a index. This constructor may be useful when
--   you need to store an <a>Indexable</a> in a container to avoid
--   <tt>ImpredicativeTypes</tt>.
--   
--   <pre>
--   index :: Indexed i a b -&gt; i -&gt; a -&gt; b
--   </pre>
newtype Indexed i a b
Indexed :: (i -> a -> b) -> Indexed i a b
runIndexed :: Indexed i a b -> i -> a -> b

-- | Compose an <a>Indexed</a> function with a non-indexed function.
--   
--   Mnemonically, the <tt>&lt;</tt> points to the indexing we want to
--   preserve.
(<.) :: Indexable i p => (Indexed i s t -> r) -> ((a -> b) -> s -> t) -> p a b -> r

-- | Composition of <a>Indexed</a> functions.
--   
--   Mnemonically, the <tt>&lt;</tt> and <tt>&gt;</tt> points to the fact
--   that we want to preserve the indices.
(<.>) :: Indexable (i, j) p => (Indexed i s t -> r) -> (Indexed j a b -> s -> t) -> p a b -> r

-- | Compose a non-indexed function with an <a>Indexed</a> function.
--   
--   Mnemonically, the <tt>&gt;</tt> points to the indexing we want to
--   preserve.
--   
--   This is the same as <tt>(<a>.</a>)</tt>.
--   
--   <tt>f <a>.</a> g</tt> (and <tt>f <a>.&gt;</a> g</tt>) gives you the
--   index of <tt>g</tt> unless <tt>g</tt> is index-preserving, like a
--   <a>Prism</a>, <a>Iso</a> or <a>Equality</a>, in which case it'll pass
--   through the index of <tt>f</tt>.
(.>) :: (st -> r) -> (kab -> st) -> kab -> r

-- | Remap the index.
reindexed :: Indexable j p => (i -> j) -> (Indexed i a b -> r) -> p a b -> r

-- | Composition of <a>Indexed</a> functions with a user supplied function
--   for combining indices.
icompose :: Indexable p c => (i -> j -> p) -> (Indexed i s t -> r) -> (Indexed j a b -> s -> t) -> c a b -> r

-- | Transform a <a>Traversal</a> into an <a>IndexedTraversal</a> or a
--   <a>Fold</a> into an <a>IndexedFold</a>, etc.
--   
--   <pre>
--   <a>indexing</a> :: <a>Traversal</a> s t a b -&gt; <a>IndexedTraversal</a> <a>Int</a> s t a b
--   <a>indexing</a> :: <a>Prism</a> s t a b     -&gt; <a>IndexedTraversal</a> <a>Int</a> s t a b
--   <a>indexing</a> :: <a>Lens</a> s t a b      -&gt; <a>IndexedLens</a> <a>Int</a>  s t a b
--   <a>indexing</a> :: <a>Iso</a> s t a b       -&gt; <a>IndexedLens</a> <a>Int</a> s t a b
--   <a>indexing</a> :: <a>Fold</a> s a          -&gt; <a>IndexedFold</a> <a>Int</a> s a
--   <a>indexing</a> :: <a>Getter</a> s a        -&gt; <a>IndexedGetter</a> <a>Int</a> s a
--   </pre>
--   
--   <pre>
--   <a>indexing</a> :: <a>Indexable</a> <a>Int</a> p =&gt; <a>LensLike</a> (<a>Indexing</a> f) s t a b -&gt; <a>Overloading</a> p (-&gt;) f s t a b
--   </pre>
indexing :: Indexable Int p => ((a -> Indexing f b) -> s -> Indexing f t) -> p a (f b) -> s -> f t

-- | Transform a <a>Traversal</a> into an <a>IndexedTraversal</a> or a
--   <a>Fold</a> into an <a>IndexedFold</a>, etc.
--   
--   This combinator is like <a>indexing</a> except that it handles large
--   traversals and folds gracefully.
--   
--   <pre>
--   <a>indexing64</a> :: <a>Traversal</a> s t a b -&gt; <a>IndexedTraversal</a> <a>Int64</a> s t a b
--   <a>indexing64</a> :: <a>Prism</a> s t a b     -&gt; <a>IndexedTraversal</a> <a>Int64</a> s t a b
--   <a>indexing64</a> :: <a>Lens</a> s t a b      -&gt; <a>IndexedLens</a> <a>Int64</a> s t a b
--   <a>indexing64</a> :: <a>Iso</a> s t a b       -&gt; <a>IndexedLens</a> <a>Int64</a> s t a b
--   <a>indexing64</a> :: <a>Fold</a> s a          -&gt; <a>IndexedFold</a> <a>Int64</a> s a
--   <a>indexing64</a> :: <a>Getter</a> s a        -&gt; <a>IndexedGetter</a> <a>Int64</a> s a
--   </pre>
--   
--   <pre>
--   <a>indexing64</a> :: <a>Indexable</a> <a>Int64</a> p =&gt; <a>LensLike</a> (<a>Indexing64</a> f) s t a b -&gt; <a>Overloading</a> p (-&gt;) f s t a b
--   </pre>
indexing64 :: Indexable Int64 p => ((a -> Indexing64 f b) -> s -> Indexing64 f t) -> p a (f b) -> s -> f t

-- | A <a>Functor</a> with an additional index.
--   
--   Instances must satisfy a modified form of the <a>Functor</a> laws:
--   
--   <pre>
--   <a>imap</a> f <a>.</a> <a>imap</a> g ≡ <a>imap</a> (\i -&gt; f i <a>.</a> g i)
--   <a>imap</a> (\_ a -&gt; a) ≡ <a>id</a>
--   </pre>
class Functor f => FunctorWithIndex i f | f -> i where imap = iover itraversed imapped = conjoined mapped (isets imap)
imap :: FunctorWithIndex i f => (i -> a -> b) -> f a -> f b
imapped :: (FunctorWithIndex i f, FunctorWithIndex i f) => IndexedSetter i (f a) (f b) a b

-- | A container that supports folding with an additional index.
class Foldable f => FoldableWithIndex i f | f -> i where ifoldMap = ifoldMapOf itraversed ifolded = conjoined folded $ \ f -> coerce . getFolding . ifoldMap (\ i -> Folding #. indexed f i) ifoldr f z t = appEndo (ifoldMap (\ i -> Endo #. f i) t) z ifoldl f z t = appEndo (getDual (ifoldMap (\ i -> Dual #. Endo #. flip (f i)) t)) z ifoldr' f z0 xs = ifoldl f' id xs z0 where f' i k x z = k $! f i x z ifoldl' f z0 xs = ifoldr f' id xs z0 where f' i x k z = k $! f i z x
ifoldMap :: (FoldableWithIndex i f, Monoid m) => (i -> a -> m) -> f a -> m
ifolded :: FoldableWithIndex i f => IndexedFold i (f a) a
ifoldr :: FoldableWithIndex i f => (i -> a -> b -> b) -> b -> f a -> b
ifoldl :: FoldableWithIndex i f => (i -> b -> a -> b) -> b -> f a -> b
ifoldr' :: FoldableWithIndex i f => (i -> a -> b -> b) -> b -> f a -> b
ifoldl' :: FoldableWithIndex i f => (i -> b -> a -> b) -> b -> f a -> b

-- | Obtain a <a>Fold</a> by lifting an operation that returns a
--   <a>Foldable</a> result.
--   
--   This can be useful to lift operations from <tt><a>List</a></tt> and
--   elsewhere into a <a>Fold</a>.
ifolding :: FoldableWithIndex i f => (s -> f a) -> IndexedFold i s a

-- | Return whether or not any element in a container satisfies a
--   predicate, with access to the index <tt>i</tt>.
--   
--   When you don't need access to the index then <a>any</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>any</a> ≡ <a>iany</a> <a>.</a> <a>const</a>
--   </pre>
iany :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Bool

-- | Return whether or not all elements in a container satisfy a predicate,
--   with access to the index <tt>i</tt>.
--   
--   When you don't need access to the index then <a>all</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>all</a> ≡ <a>iall</a> <a>.</a> <a>const</a>
--   </pre>
iall :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Bool

-- | Traverse elements with access to the index <tt>i</tt>, discarding the
--   results.
--   
--   When you don't need access to the index then <a>traverse_</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>traverse_</a> l = <a>itraverse</a> <a>.</a> <a>const</a>
--   </pre>
itraverse_ :: (FoldableWithIndex i t, Applicative f) => (i -> a -> f b) -> t a -> f ()

-- | Traverse elements with access to the index <tt>i</tt>, discarding the
--   results (with the arguments flipped).
--   
--   <pre>
--   <a>ifor_</a> ≡ <a>flip</a> <a>itraverse_</a>
--   </pre>
--   
--   When you don't need access to the index then <a>for_</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>for_</a> a ≡ <a>ifor_</a> a <a>.</a> <a>const</a>
--   </pre>
ifor_ :: (FoldableWithIndex i t, Applicative f) => t a -> (i -> a -> f b) -> f ()

-- | Run monadic actions for each target of an <a>IndexedFold</a> or
--   <a>IndexedTraversal</a> with access to the index, discarding the
--   results.
--   
--   When you don't need access to the index then <a>mapMOf_</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>mapM_</a> ≡ <a>imapM</a> <a>.</a> <a>const</a>
--   </pre>
imapM_ :: (FoldableWithIndex i t, Monad m) => (i -> a -> m b) -> t a -> m ()

-- | Run monadic actions for each target of an <a>IndexedFold</a> or
--   <a>IndexedTraversal</a> with access to the index, discarding the
--   results (with the arguments flipped).
--   
--   <pre>
--   <a>iforM_</a> ≡ <a>flip</a> <a>imapM_</a>
--   </pre>
--   
--   When you don't need access to the index then <a>forMOf_</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>forMOf_</a> l a ≡ <a>iforMOf</a> l a <a>.</a> <a>const</a>
--   </pre>
iforM_ :: (FoldableWithIndex i t, Monad m) => t a -> (i -> a -> m b) -> m ()

-- | Concatenate 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 <a>concatMap</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>concatMap</a> ≡ <a>iconcatMap</a> <a>.</a> <a>const</a>
--   <a>iconcatMap</a> ≡ <a>ifoldMap</a>
--   </pre>
iconcatMap :: FoldableWithIndex i f => (i -> a -> [b]) -> f a -> [b]

-- | Searches a container with a predicate that is also supplied the index,
--   returning the left-most element of the structure matching the
--   predicate, or <a>Nothing</a> if there is no such element.
--   
--   When you don't need access to the index then <a>find</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>find</a> ≡ <a>ifind</a> <a>.</a> <a>const</a>
--   </pre>
ifind :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Maybe (i, a)

-- | Monadic fold right over the elements of a structure with an index.
--   
--   When you don't need access to the index then <a>foldrM</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>foldrM</a> ≡ <a>ifoldrM</a> <a>.</a> <a>const</a>
--   </pre>
ifoldrM :: (FoldableWithIndex i f, Monad m) => (i -> a -> b -> m b) -> b -> f a -> m b

-- | Monadic fold over the elements of a structure with an index,
--   associating to the left.
--   
--   When you don't need access to the index then <a>foldlM</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>foldlM</a> ≡ <a>ifoldlM</a> <a>.</a> <a>const</a>
--   </pre>
ifoldlM :: (FoldableWithIndex i f, Monad m) => (i -> b -> a -> m b) -> b -> f a -> m b

-- | Extract the key-value pairs from a structure.
--   
--   When you don't need access to the indices in the result, then
--   <a>toList</a> is more flexible in what it accepts.
--   
--   <pre>
--   <a>toList</a> ≡ <a>map</a> <a>fst</a> <a>.</a> <a>itoList</a>
--   </pre>
itoList :: FoldableWithIndex i f => f a -> [(i, a)]

-- | Fold a container with indices returning both the indices and the
--   values.
--   
--   The result is only valid to compose in a <a>Traversal</a>, if you
--   don't edit the index as edits to the index have no effect.
withIndex :: (Indexable i p, Functor f) => Overloading p (Indexed i) f s t (i, s) (j, t)

-- | When composed with an <a>IndexedFold</a> or <a>IndexedTraversal</a>
--   this yields an (<a>Indexed</a>) <a>Fold</a> of the indices.
asIndex :: (Indexable i p, Contravariant f, Functor f) => Overloading' p (Indexed i) f s i

-- | This allows you to filter an <a>IndexedFold</a>, <a>IndexedGetter</a>,
--   <a>IndexedTraversal</a> or <a>IndexedLens</a> based on a predicate on
--   the indices.
--   
--   <pre>
--   &gt;&gt;&gt; ["hello","the","world","!!!"]^..traversed.indices even
--   ["hello","world"]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over (traversed.indices (&gt;0)) Prelude.reverse $ ["He","was","stressed","o_O"]
--   ["He","saw","desserts","O_o"]
--   </pre>
indices :: (Indexable i p, Applicative f) => (i -> Bool) -> Overloading' p (Indexed i) f a a

-- | This allows you to filter an <a>IndexedFold</a>, <a>IndexedGetter</a>,
--   <a>IndexedTraversal</a> or <a>IndexedLens</a> based on an index.
--   
--   <pre>
--   &gt;&gt;&gt; ["hello","the","world","!!!"]^?traversed.index 2
--   Just "world"
--   </pre>
index :: (Indexable i p, Eq i, Applicative f) => i -> Overloading' p (Indexed i) f a a

-- | A <a>Traversable</a> with an additional index.
--   
--   An instance must satisfy a (modified) form of the <a>Traversable</a>
--   laws:
--   
--   <pre>
--   <a>itraverse</a> (<a>const</a> <a>Identity</a>) ≡ <a>Identity</a>
--   <a>fmap</a> (<a>itraverse</a> f) <a>.</a> <a>itraverse</a> g ≡ <a>getCompose</a> <a>.</a> <a>itraverse</a> (\i -&gt; <a>Compose</a> <a>.</a> <a>fmap</a> (f i) <a>.</a> g i)
--   </pre>
class (FunctorWithIndex i t, FoldableWithIndex i t, Traversable t) => TraversableWithIndex i t | t -> i where itraverse = traversed .# Indexed itraversed = conjoined traverse (itraverse . indexed)
itraverse :: (TraversableWithIndex i t, Applicative f) => (i -> a -> f b) -> t a -> f (t b)
itraversed :: TraversableWithIndex i t => IndexedTraversal i (t a) (t b) a b

-- | Traverse with an index (and the arguments flipped).
--   
--   <pre>
--   <a>for</a> a ≡ <a>ifor</a> a <a>.</a> <a>const</a>
--   <a>ifor</a> ≡ <a>flip</a> <a>itraverse</a>
--   </pre>
ifor :: (TraversableWithIndex i t, Applicative f) => t a -> (i -> a -> f b) -> f (t b)

-- | Map each element of a structure to a monadic action, evaluate these
--   actions from left to right, and collect the results, with access the
--   index.
--   
--   When you don't need access to the index <a>mapM</a> is more liberal in
--   what it can accept.
--   
--   <pre>
--   <a>mapM</a> ≡ <a>imapM</a> <a>.</a> <a>const</a>
--   </pre>
imapM :: (TraversableWithIndex i t, Monad m) => (i -> a -> m b) -> t a -> m (t b)

-- | Map each element of a structure to a monadic action, evaluate these
--   actions from left to right, and collect the results, with access its
--   position (and the arguments flipped).
--   
--   <pre>
--   <a>forM</a> a ≡ <a>iforM</a> a <a>.</a> <a>const</a>
--   <a>iforM</a> ≡ <a>flip</a> <a>imapM</a>
--   </pre>
iforM :: (TraversableWithIndex i t, Monad m) => t a -> (i -> a -> m b) -> m (t b)

-- | Generalizes <a>mapAccumR</a> to add access to the index.
--   
--   <a>imapAccumROf</a> accumulates state from right to left.
--   
--   <pre>
--   <a>mapAccumR</a> ≡ <a>imapAccumR</a> <a>.</a> <a>const</a>
--   </pre>
imapAccumR :: TraversableWithIndex i t => (i -> s -> a -> (s, b)) -> s -> t a -> (s, t b)

-- | Generalizes <a>mapAccumL</a> to add access to the index.
--   
--   <a>imapAccumLOf</a> accumulates state from left to right.
--   
--   <pre>
--   <a>mapAccumLOf</a> ≡ <a>imapAccumL</a> <a>.</a> <a>const</a>
--   </pre>
imapAccumL :: TraversableWithIndex i t => (i -> s -> a -> (s, b)) -> s -> t a -> (s, t b)
instance TraversableWithIndex i (Magma i t b)
instance FoldableWithIndex i (Magma i t b)
instance FunctorWithIndex i (Magma i t b)
instance TraversableWithIndex i (Level i)
instance FoldableWithIndex i (Level i)
instance FunctorWithIndex i (Level i)
instance FunctorWithIndex r ((->) r)
instance (Eq k, Hashable k) => TraversableWithIndex k (HashMap k)
instance (Eq k, Hashable k) => FoldableWithIndex k (HashMap k)
instance (Eq k, Hashable k) => FunctorWithIndex k (HashMap k)
instance TraversableWithIndex k (Map k)
instance FoldableWithIndex k (Map k)
instance FunctorWithIndex k (Map k)
instance TraversableWithIndex Int IntMap
instance FoldableWithIndex Int IntMap
instance FunctorWithIndex Int IntMap
instance TraversableWithIndex Int Vector
instance FoldableWithIndex Int Vector
instance FunctorWithIndex Int Vector
instance TraversableWithIndex Int Seq
instance FoldableWithIndex Int Seq
instance FunctorWithIndex Int Seq
instance TraversableWithIndex () Maybe
instance FoldableWithIndex () Maybe
instance FunctorWithIndex () Maybe
instance TraversableWithIndex Int []
instance FoldableWithIndex Int []
instance FunctorWithIndex Int []
instance TraversableWithIndex k ((,) k)
instance FoldableWithIndex k ((,) k)
instance FunctorWithIndex k ((,) k)
instance TraversableWithIndex () Identity
instance FoldableWithIndex () Identity
instance FunctorWithIndex () Identity
instance TraversableWithIndex i f => TraversableWithIndex i (Reverse f)
instance FoldableWithIndex i f => FoldableWithIndex i (Reverse f)
instance FunctorWithIndex i f => FunctorWithIndex i (Reverse f)
instance TraversableWithIndex i f => TraversableWithIndex i (Backwards f)
instance FoldableWithIndex i f => FoldableWithIndex i (Backwards f)
instance FunctorWithIndex i f => FunctorWithIndex i (Backwards f)


module Control.Lens.Tuple

-- | Provides access to 1st field of a tuple.
class Field1 s t a b | s -> a, t -> b, s b -> t, t a -> s
_1 :: Field1 s t a b => IndexedLens Int s t a b

-- | Provides access to the 2nd field of a tuple.
class Field2 s t a b | s -> a, t -> b, s b -> t, t a -> s
_2 :: Field2 s t a b => IndexedLens Int s t a b

-- | Provides access to the 3rd field of a tuple.
class Field3 s t a b | s -> a, t -> b, s b -> t, t a -> s
_3 :: Field3 s t a b => IndexedLens Int s t a b

-- | Provide access to the 4th field of a tuple.
class Field4 s t a b | s -> a, t -> b, s b -> t, t a -> s
_4 :: Field4 s t a b => IndexedLens Int s t a b

-- | Provides access to the 5th field of a tuple.
class Field5 s t a b | s -> a, t -> b, s b -> t, t a -> s
_5 :: Field5 s t a b => IndexedLens Int s t a b

-- | Provides access to the 6th element of a tuple.
class Field6 s t a b | s -> a, t -> b, s b -> t, t a -> s
_6 :: Field6 s t a b => IndexedLens Int s t a b

-- | Provide access to the 7th field of a tuple.
class Field7 s t a b | s -> a, t -> b, s b -> t, t a -> s
_7 :: Field7 s t a b => IndexedLens Int s t a b

-- | Provide access to the 8th field of a tuple.
class Field8 s t a b | s -> a, t -> b, s b -> t, t a -> s
_8 :: Field8 s t a b => IndexedLens Int s t a b

-- | Provides access to the 9th field of a tuple.
class Field9 s t a b | s -> a, t -> b, s b -> t, t a -> s
_9 :: Field9 s t a b => IndexedLens Int s t a b
instance Field9 (a, b, c, d, e, f, g, h, i) (a, b, c, d, e, f, g, h, i') i i'
instance Field8 (a, b, c, d, e, f, g, h, i) (a, b, c, d, e, f, g, h', i) h h'
instance Field8 (a, b, c, d, e, f, g, h) (a, b, c, d, e, f, g, h') h h'
instance Field7 (a, b, c, d, e, f, g, h, i) (a, b, c, d, e, f, g', h, i) g g'
instance Field7 (a, b, c, d, e, f, g, h) (a, b, c, d, e, f, g', h) g g'
instance Field7 (a, b, c, d, e, f, g) (a, b, c, d, e, f, g') g g'
instance Field6 (a, b, c, d, e, f, g, h, i) (a, b, c, d, e, f', g, h, i) f f'
instance Field6 (a, b, c, d, e, f, g, h) (a, b, c, d, e, f', g, h) f f'
instance Field6 (a, b, c, d, e, f, g) (a, b, c, d, e, f', g) f f'
instance Field6 (a, b, c, d, e, f) (a, b, c, d, e, f') f f'
instance Field5 (a, b, c, d, e, f, g, h, i) (a, b, c, d, e', f, g, h, i) e e'
instance Field5 (a, b, c, d, e, f, g, h) (a, b, c, d, e', f, g, h) e e'
instance Field5 (a, b, c, d, e, f, g) (a, b, c, d, e', f, g) e e'
instance Field5 (a, b, c, d, e, f) (a, b, c, d, e', f) e e'
instance Field5 (a, b, c, d, e) (a, b, c, d, e') e e'
instance Field4 (a, b, c, d, e, f, g, h, i) (a, b, c, d', e, f, g, h, i) d d'
instance Field4 (a, b, c, d, e, f, g, h) (a, b, c, d', e, f, g, h) d d'
instance Field4 (a, b, c, d, e, f, g) (a, b, c, d', e, f, g) d d'
instance Field4 (a, b, c, d, e, f) (a, b, c, d', e, f) d d'
instance Field4 (a, b, c, d, e) (a, b, c, d', e) d d'
instance Field4 (a, b, c, d) (a, b, c, d') d d'
instance Field3 (a, b, c, d, e, f, g, h, i) (a, b, c', d, e, f, g, h, i) c c'
instance Field3 (a, b, c, d, e, f, g, h) (a, b, c', d, e, f, g, h) c c'
instance Field3 (a, b, c, d, e, f, g) (a, b, c', d, e, f, g) c c'
instance Field3 (a, b, c, d, e, f) (a, b, c', d, e, f) c c'
instance Field3 (a, b, c, d, e) (a, b, c', d, e) c c'
instance Field3 (a, b, c, d) (a, b, c', d) c c'
instance Field3 (a, b, c) (a, b, c') c c'
instance Field2 (a, b, c, d, e, f, g, h, i) (a, b', c, d, e, f, g, h, i) b b'
instance Field2 (a, b, c, d, e, f, g, h) (a, b', c, d, e, f, g, h) b b'
instance Field2 (a, b, c, d, e, f, g) (a, b', c, d, e, f, g) b b'
instance Field2 (a, b, c, d, e, f) (a, b', c, d, e, f) b b'
instance Field2 (a, b, c, d, e) (a, b', c, d, e) b b'
instance Field2 (a, b, c, d) (a, b', c, d) b b'
instance Field2 (a, b, c) (a, b', c) b b'
instance Field2 (a, b) (a, b') b b'
instance Field1 (a, b, c, d, e, f, g, h, i) (a', b, c, d, e, f, g, h, i) a a'
instance Field1 (a, b, c, d, e, f, g, h) (a', b, c, d, e, f, g, h) a a'
instance Field1 (a, b, c, d, e, f, g) (a', b, c, d, e, f, g) a a'
instance Field1 (a, b, c, d, e, f) (a', b, c, d, e, f) a a'
instance Field1 (a, b, c, d, e) (a', b, c, d, e) a a'
instance Field1 (a, b, c, d) (a', b, c, d) a a'
instance Field1 (a, b, c) (a', b, c) a a'
instance Field1 (a, b) (a', b) a a'
instance Field1 (Identity a) (Identity b) a b


module Control.Lens.Cons

-- | This class provides a way to attach or detach elements on the left
--   side of a structure in a flexible manner.
class (Profunctor p, Functor f) => Cons p f s t a b | s -> a, t -> b, s b -> t, t a -> s
_Cons :: Cons p f s t a b => Overloaded p f s t (a, s) (b, t)

-- | <a>cons</a> an element onto a container.
--   
--   This is an infix alias for <a>cons</a>.
(<|) :: Cons Reviewed Identity s s a a => a -> s -> s

-- | <a>cons</a> an element onto a container.
cons :: Cons Reviewed Identity s s a a => a -> s -> s

-- | Attempt to extract the left-most element from a container, and a
--   version of the container without that element.
uncons :: Cons (->) (Accessor (First (a, s))) s s a a => s -> Maybe (a, s)

-- | A <a>Traversal</a> reading and writing to the <a>head</a> of a
--   <i>non-empty</i> container.
--   
--   <pre>
--   &gt;&gt;&gt; [a,b,c]^? _head
--   Just a
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [a,b,c] &amp; _head .~ d
--   [d,b,c]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [a,b,c] &amp; _head %~ f
--   [f a,b,c]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [] &amp; _head %~ f
--   []
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [1,2,3]^?!_head
--   1
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; []^?_head
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [1,2]^?_head
--   Just 1
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [] &amp; _head .~ 1
--   []
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [0] &amp; _head .~ 2
--   [2]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [0,1] &amp; _head .~ 2
--   [2,1]
--   </pre>
--   
--   This isn't limited to lists.
--   
--   For instance you can also <a>traverse</a> the head of a <a>Seq</a>:
--   
--   <pre>
--   &gt;&gt;&gt; Seq.fromList [a,b,c,d] &amp; _head %~ f
--   fromList [f a,b,c,d]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Seq.fromList [] ^? _head
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Seq.fromList [a,b,c,d] ^? _head
--   Just a
--   </pre>
--   
--   <pre>
--   <a>_head</a> :: <a>Traversal'</a> [a] a
--   <a>_head</a> :: <a>Traversal'</a> (<a>Seq</a> a) a
--   <a>_head</a> :: <a>Traversal'</a> (<a>Vector</a> a) a
--   </pre>
_head :: Cons (->) f s s a a => LensLike' f s a

-- | A <a>Traversal</a> reading and writing to the <a>tail</a> of a
--   <i>non-empty</i> container.
--   
--   <pre>
--   &gt;&gt;&gt; [a,b] &amp; _tail .~ [c,d,e]
--   [a,c,d,e]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [] &amp; _tail .~ [a,b]
--   []
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [a,b,c,d,e] &amp; _tail.traverse %~ f
--   [a,f b,f c,f d,f e]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [1,2] &amp; _tail .~ [3,4,5]
--   [1,3,4,5]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [] &amp; _tail .~ [1,2]
--   []
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [a,b,c]^?_tail
--   Just [b,c]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [1,2]^?!_tail
--   [2]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "hello"^._tail
--   "ello"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ""^._tail
--   ""
--   </pre>
--   
--   This isn't limited to lists. For instance you can also <a>traverse</a>
--   the tail of a <a>Seq</a>.
--   
--   <pre>
--   &gt;&gt;&gt; Seq.fromList [a,b] &amp; _tail .~ Seq.fromList [c,d,e]
--   fromList [a,c,d,e]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Seq.fromList [a,b,c] ^? _tail
--   Just (fromList [b,c])
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Seq.fromList [] ^? _tail
--   Nothing
--   </pre>
--   
--   <pre>
--   <a>_tail</a> :: <a>Traversal'</a> [a] [a]
--   <a>_tail</a> :: <a>Traversal'</a> (<a>Seq</a> a) (<a>Seq</a> a)
--   <a>_tail</a> :: <a>Traversal'</a> (<a>Vector</a> a) (<a>Vector</a> a)
--   </pre>
_tail :: Cons (->) f s s a a => LensLike' f s s

-- | This class provides a way to attach or detach elements on the right
--   side of a structure in a flexible manner.
class (Profunctor p, Functor f) => Snoc p f s t a b | s -> a, t -> b, s b -> t, t a -> s
_Snoc :: Snoc p f s t a b => Overloaded p f s t (s, a) (t, b)

-- | <a>snoc</a> an element onto the end of a container.
--   
--   This is an infix alias for <a>snoc</a>.
(|>) :: Snoc Reviewed Identity s s a a => s -> a -> s

-- | <a>snoc</a> an element onto the end of a container.
snoc :: Snoc Reviewed Identity s s a a => s -> a -> s

-- | Attempt to extract the right-most element from a container, and a
--   version of the container without that element.
unsnoc :: Snoc (->) (Accessor (First (s, a))) s s a a => s -> Maybe (s, a)

-- | A <a>Traversal</a> reading and replacing all but the a last element of
--   a <i>non-empty</i> container.
--   
--   <pre>
--   &gt;&gt;&gt; [a,b,c,d]^?_init
--   Just [a,b,c]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; []^?_init
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [a,b] &amp; _init .~ [c,d,e]
--   [c,d,e,b]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [] &amp; _init .~ [a,b]
--   []
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [a,b,c,d] &amp; _init.traverse %~ f
--   [f a,f b,f c,d]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [1,2,3]^?_init
--   Just [1,2]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [1,2,3,4]^?!_init
--   [1,2,3]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "hello"^._init
--   "hell"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ""^._init
--   ""
--   </pre>
--   
--   <pre>
--   <a>_init</a> :: <a>Traversal'</a> [a] [a]
--   <a>_init</a> :: <a>Traversal'</a> (<a>Seq</a> a) (<a>Seq</a> a)
--   <a>_init</a> :: <a>Traversal'</a> (<a>Vector</a> a) (<a>Vector</a> a)
--   </pre>
_init :: Snoc (->) f s s a a => LensLike' f s s

-- | A <a>Traversal</a> reading and writing to the last element of a
--   <i>non-empty</i> container.
--   
--   <pre>
--   &gt;&gt;&gt; [a,b,c]^?!_last
--   c
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; []^?_last
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [a,b,c] &amp; _last %~ f
--   [a,b,f c]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [1,2]^?_last
--   Just 2
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [] &amp; _last .~ 1
--   []
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [0] &amp; _last .~ 2
--   [2]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [0,1] &amp; _last .~ 2
--   [0,2]
--   </pre>
--   
--   This <a>Traversal</a> is not limited to lists, however. We can also
--   work with other containers, such as a <a>Vector</a>.
--   
--   <pre>
--   &gt;&gt;&gt; Vector.fromList "abcde" ^? _last
--   Just 'e'
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Vector.empty ^? _last
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Vector.fromList "abcde" &amp; _last .~ 'Q'
--   fromList "abcdQ"
--   </pre>
--   
--   <pre>
--   <a>_last</a> :: <a>Traversal'</a> [a] a
--   <a>_last</a> :: <a>Traversal'</a> (<a>Seq</a> a) a
--   <a>_last</a> :: <a>Traversal'</a> (<a>Vector</a> a) a
--   </pre>
_last :: Snoc (->) f s s a a => LensLike' f s a
instance (Choice p, Applicative f) => Snoc p f Text Text Char Char
instance (Choice p, Applicative f) => Snoc p f Text Text Char Char
instance (Choice p, Applicative f) => Snoc p f ByteString ByteString Word8 Word8
instance (Choice p, Applicative f) => Snoc p f ByteString ByteString Word8 Word8
instance (Choice p, Applicative f, Unbox a, Unbox b) => Snoc p f (Vector a) (Vector b) a b
instance (Choice p, Applicative f, Storable a, Storable b) => Snoc p f (Vector a) (Vector b) a b
instance (Choice p, Applicative f, Prim a, Prim b) => Snoc p f (Vector a) (Vector b) a b
instance (Choice p, Applicative f) => Snoc p f (Vector a) (Vector b) a b
instance (Choice p, Applicative f) => Snoc p f (Seq a) (Seq b) a b
instance (Choice p, Applicative f) => Snoc p f [a] [b] a b
instance (Choice p, Applicative f, Unbox a, Unbox b) => Cons p f (Vector a) (Vector b) a b
instance (Choice p, Applicative f, Storable a, Storable b) => Cons p f (Vector a) (Vector b) a b
instance (Choice p, Applicative f, Prim a, Prim b) => Cons p f (Vector a) (Vector b) a b
instance (Choice p, Applicative f) => Cons p f (Vector a) (Vector b) a b
instance (Choice p, Applicative f) => Cons p f Text Text Char Char
instance (Choice p, Applicative f) => Cons p f Text Text Char Char
instance (Choice p, Applicative f) => Cons p f ByteString ByteString Word8 Word8
instance (Choice p, Applicative f) => Cons p f ByteString ByteString Word8 Word8
instance (Choice p, Applicative f) => Cons p f (Seq a) (Seq b) a b
instance (Choice p, Applicative f) => Cons p f [a] [b] a b


-- | This module provides combinators for breadth-first searching within
--   arbitrary traversals.
module Control.Lens.Level

-- | This data type represents a path-compressed copy of one level of a
--   source data structure. We can safely use path-compression because we
--   know the depth of the tree.
--   
--   Path compression is performed by viewing a <a>Level</a> as a PATRICIA
--   trie of the paths into the structure to leaves at a given depth,
--   similar in many ways to a <a>IntMap</a>, but unlike a regular PATRICIA
--   trie we do not need to store the mask bits merely the depth of the
--   fork.
--   
--   One invariant of this structure is that underneath a <a>Two</a> node
--   you will not find any <a>Zero</a> nodes, so <a>Zero</a> can only occur
--   at the root.
data Level i a

-- | This provides a breadth-first <a>Traversal</a> of the individual
--   <a>levels</a> of any other <a>Traversal</a> via iterative deepening
--   depth-first search. The levels are returned to you in a compressed
--   format.
--   
--   This can permit us to extract the <a>levels</a> directly:
--   
--   <pre>
--   &gt;&gt;&gt; ["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']
--   </pre>
--   
--   But we can also traverse them in turn:
--   
--   <pre>
--   &gt;&gt;&gt; ["hello","world"]^..levels (traverse.traverse).traverse
--   "hewlolrold"
--   </pre>
--   
--   We can use this to traverse to a fixed depth in the tree of
--   (<a>&lt;*&gt;</a>) used in the <a>Traversal</a>:
--   
--   <pre>
--   &gt;&gt;&gt; ["hello","world"] &amp; taking 4 (levels (traverse.traverse)).traverse %~ toUpper
--   ["HEllo","World"]
--   </pre>
--   
--   Or we can use it to traverse the first <tt>n</tt> elements in found in
--   that <a>Traversal</a> regardless of the depth at which they were
--   found.
--   
--   <pre>
--   &gt;&gt;&gt; ["hello","world"] &amp; taking 4 (levels (traverse.traverse).traverse) %~ toUpper
--   ["HELlo","World"]
--   </pre>
--   
--   The resulting <a>Traversal</a> of the <a>levels</a> which is indexed
--   by the depth of each <a>Level</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ["dog","cat"]^@..levels (traverse.traverse) &lt;. traverse
--   [(2,'d'),(3,'o'),(3,'c'),(4,'g'),(4,'a'),(5,'t')]
--   </pre>
--   
--   <i>Note:</i> Internally this is implemented by using an illegal
--   <a>Applicative</a>, as it extracts information in an order that
--   violates the <a>Applicative</a> laws.
levels :: ATraversal s t a b -> IndexedTraversal Int s t (Level () a) (Level () b)

-- | This provides a breadth-first <a>Traversal</a> of the individual
--   levels of any other <a>Traversal</a> via iterative deepening
--   depth-first search. The levels are returned to you in a compressed
--   format.
--   
--   This is similar to <a>levels</a>, but retains the index of the
--   original <a>IndexedTraversal</a>, so you can access it when traversing
--   the levels later on.
--   
--   <pre>
--   &gt;&gt;&gt; ["dog","cat"]^@..ilevels (traversed&lt;.&gt;traversed).itraversed
--   [((0,0),'d'),((0,1),'o'),((1,0),'c'),((0,2),'g'),((1,1),'a'),((1,2),'t')]
--   </pre>
--   
--   The resulting <a>Traversal</a> of the levels which is indexed by the
--   depth of each <a>Level</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ["dog","cat"]^@..ilevels (traversed&lt;.&gt;traversed)&lt;.&gt;itraversed
--   [((2,(0,0)),'d'),((3,(0,1)),'o'),((3,(1,0)),'c'),((4,(0,2)),'g'),((4,(1,1)),'a'),((5,(1,2)),'t')]
--   </pre>
--   
--   <i>Note:</i> Internally this is implemented by using an illegal
--   <a>Applicative</a>, as it extracts information in an order that
--   violates the <a>Applicative</a> laws.
ilevels :: AnIndexedTraversal i s t a b -> IndexedTraversal Int s t (Level i a) (Level j b)


-- | This module provides internal types and functions used in the
--   implementation of <tt>Control.Lens.Zipper</tt>. You shouldn't need to
--   import it directly, and the exported types can be used to break
--   <a>Zipper</a> invariants.
module Control.Lens.Internal.Zipper

-- | A <a>Jacket</a> is used to store the contents of a <a>Traversal</a> in
--   a way that we do not have to re-asocciate the elements. This enables
--   us to more gracefully deal with infinite traversals.
data Jacket i a
Ap :: Int -> Bool -> Bool -> (Last i) -> (Jacket i a) -> (Jacket i a) -> Jacket i a
Leaf :: i -> a -> Jacket i a
Pure :: Jacket i a

-- | Return the number of children in a jacket
size :: Jacket i a -> Int

-- | This is an internal function used to check from left-to-right if a
--   <a>Jacket</a> has any <a>Leaf</a> nots or not.
nullLeft :: Jacket i a -> Bool

-- | This is an internal function used to check from right-to-left if a
--   <a>Jacket</a> has any <a>Leaf</a> nots or not.
nullRight :: Jacket i a -> Bool

-- | This is used to extract the maximal key from a <a>Jacket</a>. This is
--   used by <a>moveTo</a> and <a>moveToward</a> to seek specific keys,
--   borrowing the asympotic guarantees of the original structure in many
--   cases!
maximal :: Jacket i a -> Last i

-- | Construct a <a>Jacket</a> from a <a>Bazaar</a>
jacketIns :: Bazaar (Indexed i) a b t -> Jacket i a

-- | Once we've updated a <a>Zipper</a> we need to put the values back into
--   the original shape. <a>Flow</a> is an illegal <a>Applicative</a> that
--   is used to put the values back.
newtype Flow i b a
Flow :: (Jacket i b -> a) -> Flow i b a
runFlow :: Flow i b a -> Jacket i b -> a

-- | Given a <a>Bazaar</a> and a <a>Jacket</a> build from that
--   <a>Bazaar</a> with <a>jacketIns</a>, refill the <a>Bazaar</a> with its
--   new contents.
jacketOuts :: Bazaar (Indexed i) a b t -> Jacket j b -> t

-- | This is only a valid <a>Lens</a> if you don't change the shape of the
--   <a>Jacket</a>!
jacket :: AnIndexedTraversal i s t a b -> Lens s t (Jacket i a) (Jacket j b)

-- | A <a>Path</a> into a <a>Jacket</a> that ends at a <a>Leaf</a>.
data Path i a
ApL :: Int -> Bool -> Bool -> (Last i) -> !(Path i a) -> !(Jacket i a) -> Path i a
ApR :: Int -> Bool -> Bool -> (Last i) -> !(Jacket i a) -> !(Path i a) -> Path i a
Start :: Path i a

-- | Calculate the absolute position of the <a>Leaf</a> targeted by a
--   <a>Path</a>.
--   
--   This can be quite expensive for right-biased traversals such as you
--   receive from a list.
offset :: Path i a -> Int

-- | Return the total number of children in the <a>Jacket</a> by walking
--   the <a>Path</a> to the root.
pathsize :: Path i a -> Int

-- | Reconstruct a <a>Jacket</a> from a <a>Path</a>.
recompress :: Path i a -> i -> a -> Jacket i a

-- | Walk down the tree to the leftmost child.
startl :: Path i a -> Jacket i a -> r -> (Path i a -> i -> a -> r) -> r

-- | Walk down the tree to the rightmost child.
startr :: Path i a -> Jacket i a -> r -> (Path i a -> i -> a -> r) -> r

-- | Move left one <a>Leaf</a>.
movel :: Path i a -> Jacket i a -> r -> (Path i a -> i -> a -> r) -> r

-- | Move right one <a>Leaf</a>.
mover :: Path i a -> Jacket i a -> r -> (Path i a -> i -> a -> r) -> r

-- | This is used to represent the <a>Top</a> of the <a>Zipper</a>.
--   
--   Every <a>Zipper</a> starts with <a>Top</a>.
--   
--   <i>e.g.</i> <tt><a>Top</a> <a>:&gt;&gt;</a> a</tt> is the type of the
--   trivial <a>Zipper</a>.
data Top

-- | This is the type of a <a>Zipper</a>. It visually resembles a
--   "breadcrumb trail" as used in website navigation. Each breadcrumb in
--   the trail represents a level you can move up to.
--   
--   This type operator associates to the left, so you can use a type like
--   
--   <pre>
--   <a>Top</a> <a>:&gt;&gt;</a> (<a>String</a>,<a>Double</a>) <a>:&gt;&gt;</a> <a>String</a> <a>:&gt;&gt;</a> <a>Char</a>
--   </pre>
--   
--   to represent a <a>Zipper</a> from
--   <tt>(<a>String</a>,<a>Double</a>)</tt> down to <a>Char</a> that has an
--   intermediate crumb for the <a>String</a> containing the <a>Char</a>.
--   
--   You can construct a <a>Zipper</a> into *any* data structure with
--   <a>zipper</a>.
--   
--   You can repackage up the contents of a <a>Zipper</a> with
--   <a>rezip</a>.
--   
--   <pre>
--   &gt;&gt;&gt; rezip $ zipper 42
--   42
--   </pre>
--   
--   The combinators in this module provide lot of things you can do to the
--   <a>Zipper</a> while you have it open.
--   
--   Note that a value of type <tt>h <a>:&gt;</a> s <a>:&gt;</a> a</tt>
--   doesn't actually contain a value of type <tt>h <a>:&gt;</a> s</tt> --
--   as we descend into a level, the previous level is unpacked and stored
--   in <a>Coil</a> form. Only one value of type <tt>_ <a>:&gt;</a> _</tt>
--   exists at any particular time for any particular <a>Zipper</a>.
data Zipper h i a
Zipper :: !(Coil h i a) -> Int -> !Int -> !(Path i a) -> i -> a -> Zipper h i a

-- | An empty data type, used to represent the pairing of a position in a
--   <a>Zipper</a> with an index. See <a>:&gt;</a>.
data (:@) a i

-- | This type family represents a <a>Zipper</a> with the <tt>p</tt>
--   variable abstracting over the position and the index, in terms of
--   <a>:@</a>. You can visually see it in type signatures as:
--   
--   <pre>
--   h <a>:&gt;</a> (a <a>:@</a> i) = <a>Zipper</a> h i a
--   </pre>

-- | Many zippers are indexed by Int keys. This type alias is convenient
--   for reducing syntactic noise for talking about these boring indices.
type (:>>) h a = Zipper h Int a

-- | This represents the type a <a>Zipper</a> will have when it is fully
--   <a>Zipped</a> back up.

-- | A <a>Coil</a> is a linked list of the levels above the current one.
--   The length of a <a>Coil</a> is known at compile time.
--   
--   This is part of the internal structure of a <a>Zipper</a>. You
--   shouldn't need to manipulate this directly.
data Coil t i a
Coil :: Coil Top Int a
Snoc :: !(Coil h j s) -> AnIndexedTraversal' i s a -> Int -> !Int -> !(Path j s) -> j -> (Jacket i a -> s) -> Coil (Zipper h j s) i a

-- | This <a>Lens</a> views the current target of the <a>Zipper</a>.
focus :: IndexedLens' i (Zipper h i a) a

-- | Construct a <a>Zipper</a> that can explore anything, and start it at
--   the <a>Top</a>.
zipper :: a -> Top :>> a

-- | Return the index of the focus.
focalPoint :: Zipper h i a -> i

-- | Return the index into the current <a>Traversal</a> within the current
--   level of the <a>Zipper</a>.
--   
--   <pre>
--   <a>jerkTo</a> (<a>tooth</a> l) l = <a>Just</a>
--   </pre>
--   
--   Mnemonically, zippers have a number of <a>teeth</a> within each level.
--   This is which <a>tooth</a> you are currently at.
--   
--   This is based on ordinal position regardless of the underlying index
--   type. It may be excessively expensive for a list.
--   
--   <a>focalPoint</a> may be much cheaper if you have a <a>Traversal</a>
--   indexed by ordinal position!
tooth :: Zipper h i a -> Int

-- | Move the <a>Zipper</a> <a>upward</a>, closing the current level and
--   focusing on the parent element.
--   
--   NB: Attempts to move upward from the <a>Top</a> of the <a>Zipper</a>
--   will fail to typecheck.
upward :: Ord j => (h :> (s :@ j)) :> (a :@ i) -> h :> (s :@ j)

-- | Jerk the <a>Zipper</a> one <a>tooth</a> to the <a>rightward</a> within
--   the current <a>Lens</a> or <a>Traversal</a>.
--   
--   Attempts to move past the start of the current <a>Traversal</a> (or
--   trivially, the current <a>Lens</a>) will return <a>Nothing</a>.
--   
--   <pre>
--   &gt;&gt;&gt; isNothing $ zipper "hello" &amp; rightward
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; zipper "hello" &amp; fromWithin traverse &amp; rightward &lt;&amp;&gt; view focus
--   'e'
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; zipper "hello" &amp; fromWithin traverse &amp; rightward &lt;&amp;&gt; focus .~ 'u' &lt;&amp;&gt; rezip
--   "hullo"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; rezip $ zipper (1,2) &amp; fromWithin both &amp; tug rightward &amp; focus .~ 3
--   (1,3)
--   </pre>
rightward :: MonadPlus m => h :> (a :@ i) -> m (h :> (a :@ i))

-- | Jerk the <a>Zipper</a> <a>leftward</a> one <a>tooth</a> within the
--   current <a>Lens</a> or <a>Traversal</a>.
--   
--   Attempts to move past the end of the current <a>Traversal</a> (or
--   trivially, the current <a>Lens</a>) will return <a>Nothing</a>.
--   
--   <pre>
--   &gt;&gt;&gt; isNothing $ zipper "hello" &amp; leftward
--   True
--   </pre>
leftward :: MonadPlus m => h :> (a :@ i) -> m (h :> (a :@ i))

-- | Move to the leftmost position of the current <a>Traversal</a>.
--   
--   This is just a convenient alias for <tt><a>farthest</a>
--   <a>leftward</a></tt>.
--   
--   <pre>
--   &gt;&gt;&gt; zipper "hello" &amp; fromWithin traverse &amp; leftmost &amp; focus .~ 'a' &amp; rezip
--   "aello"
--   </pre>
leftmost :: a :> (b :@ i) -> a :> (b :@ i)

-- | Move to the rightmost position of the current <a>Traversal</a>.
--   
--   This is just a convenient alias for <tt><a>farthest</a>
--   <a>rightward</a></tt>.
--   
--   <pre>
--   &gt;&gt;&gt; zipper "hello" &amp; fromWithin traverse &amp; rightmost &amp; focus .~ 'y' &amp; leftmost &amp; focus .~ 'j' &amp; rezip
--   "jelly"
--   </pre>
rightmost :: a :> (b :@ i) -> a :> (b :@ i)

-- | This allows you to safely <a>tug</a> <a>leftward</a> or <a>tug</a>
--   <a>rightward</a> on a <a>Zipper</a>. This will attempt the move, and
--   stay where it was if it fails.
--   
--   The more general signature allows its use in other circumstances,
--   however.
--   
--   <pre>
--   <a>tug</a> f x ≡ <a>fromMaybe</a> a (f a)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; fmap rezip $ zipper "hello" &amp; within traverse &lt;&amp;&gt; tug leftward &lt;&amp;&gt; focus .~ 'j'
--   "jello"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; fmap rezip $ zipper "hello" &amp; within traverse &lt;&amp;&gt; tug rightward &lt;&amp;&gt; focus .~ 'u'
--   "hullo"
--   </pre>
tug :: (a -> Maybe a) -> a -> a

-- | This allows you to safely <tt><a>tug</a> <a>leftward</a></tt> or
--   <tt><a>tug</a> <a>rightward</a></tt> multiple times on a
--   <a>Zipper</a>, moving multiple steps in a given direction and stopping
--   at the last place you couldn't move from. This lets you safely move a
--   <a>Zipper</a>, because it will stop at either end.
--   
--   <pre>
--   &gt;&gt;&gt; fmap rezip $ zipper "stale" &amp; within traverse &lt;&amp;&gt; tugs rightward 2 &lt;&amp;&gt; focus .~ 'y'
--   "style"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; rezip $ zipper "want" &amp; fromWithin traverse &amp; tugs rightward 2 &amp; focus .~ 'r' &amp; tugs leftward 100 &amp; focus .~ 'c'
--   "cart"
--   </pre>
tugs :: (a -> Maybe a) -> Int -> a -> a

-- | Move in a direction as far as you can go, then stop there.
--   
--   This repeatedly applies a function until it returns <a>Nothing</a>,
--   and then returns the last answer.
--   
--   <pre>
--   &gt;&gt;&gt; fmap rezip $ zipper ("hello","world") &amp; downward _1 &amp; within traverse &lt;&amp;&gt; rightmost &lt;&amp;&gt; focus .~ 'a'
--   ("hella","world")
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; rezip $ zipper ("hello","there") &amp; fromWithin (both.traverse) &amp; rightmost &amp; focus .~ 'm'
--   ("hello","therm")
--   </pre>
farthest :: (a -> Maybe a) -> a -> a

-- | This allows for you to repeatedly pull a <a>Zipper</a> in a given
--   direction, failing if it falls off the end.
--   
--   <pre>
--   &gt;&gt;&gt; isNothing $ zipper "hello" &amp; within traverse &gt;&gt;= jerks rightward 10
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; fmap rezip $ zipper "silly" &amp; within traverse &gt;&gt;= jerks rightward 3 &lt;&amp;&gt; focus .~ 'k'
--   "silky"
--   </pre>
jerks :: Monad m => (a -> m a) -> Int -> a -> m a

-- | Returns the number of siblings at the current level in the
--   <a>Zipper</a>.
--   
--   <pre>
--   <a>teeth</a> z <a>&gt;=</a> 1
--   </pre>
--   
--   <i>NB:</i> If the current <a>Traversal</a> targets an infinite number
--   of elements then this may not terminate.
--   
--   This is also a particularly expensive operation to perform on an
--   unbalanced tree.
--   
--   <pre>
--   &gt;&gt;&gt; zipper ("hello","world") &amp; teeth
--   1
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; zipper ("hello","world") &amp; fromWithin both &amp; teeth
--   2
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; zipper ("hello","world") &amp; downward _1 &amp; teeth
--   1
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; zipper ("hello","world") &amp; downward _1 &amp; fromWithin traverse &amp; teeth
--   5
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; zipper ("hello","world") &amp; fromWithin (_1.traverse) &amp; teeth
--   5
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; zipper ("hello","world") &amp; fromWithin (both.traverse) &amp; teeth
--   10
--   </pre>
teeth :: h :> (a :@ i) -> Int

-- | Move the <a>Zipper</a> horizontally to the element in the <tt>n</tt>th
--   position in the current level, absolutely indexed, starting with the
--   <a>farthest</a> <a>leftward</a> as <tt>0</tt>.
--   
--   This returns <a>Nothing</a> if the target element doesn't exist.
--   
--   <pre>
--   <a>jerkTo</a> n ≡ <a>jerks</a> <a>rightward</a> n <a>.</a> <a>farthest</a> <a>leftward</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; isNothing $ zipper "not working." &amp; jerkTo 20
--   True
--   </pre>
jerkTo :: MonadPlus m => Int -> (h :> (a :@ i)) -> m (h :> (a :@ i))

-- | Move the <a>Zipper</a> horizontally to the element in the <tt>n</tt>th
--   position of the current level, absolutely indexed, starting with the
--   <a>farthest</a> <a>leftward</a> as <tt>0</tt>.
--   
--   If the element at that position doesn't exist, then this will clamp to
--   the range <tt>0 <a>&lt;=</a> n <a>&lt;</a> <a>teeth</a></tt>.
--   
--   <pre>
--   <a>tugTo</a> n ≡ <a>tugs</a> <a>rightward</a> n <a>.</a> <a>farthest</a> <a>leftward</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; rezip $ zipper "not working." &amp; fromWithin traverse &amp; tugTo 100 &amp; focus .~ '!' &amp; tugTo 1 &amp; focus .~ 'u'
--   "nut working!"
--   </pre>
tugTo :: Int -> h :> (a :@ i) -> h :> (a :@ i)

-- | Move towards a particular index in the current <a>Traversal</a>.
moveToward :: i -> h :> (a :@ i) -> h :> (a :@ i)

-- | Move horizontally to a particular index <tt>i</tt> in the current
--   <a>Traversal</a>. In the case of simple zippers, the index is
--   <a>Int</a> and we can move between traversals fairly easily:
--   
--   <pre>
--   &gt;&gt;&gt; zipper (42, 32) &amp; fromWithin both &amp; moveTo 0 &lt;&amp;&gt; view focus
--   42
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; zipper (42, 32) &amp; fromWithin both &amp; moveTo 1 &lt;&amp;&gt; view focus
--   32
--   </pre>
moveTo :: MonadPlus m => i -> h :> (a :@ i) -> m (h :> (a :@ i))

-- | Construct an <a>IndexedLens</a> from <a>ALens</a> where the index is
--   fixed to <tt>0</tt>.
lensed :: ALens' s a -> IndexedLens' Int s a

-- | Step down into a <a>Lens</a>. This is a constrained form of
--   <a>fromWithin</a> for when you know there is precisely one target that
--   can never fail.
--   
--   <pre>
--   <a>downward</a> :: <a>Lens'</a> s a -&gt; (h <a>:&gt;</a> s) -&gt; h <a>:&gt;</a> s <a>:&gt;</a> a
--   <a>downward</a> :: <a>Iso'</a> s a  -&gt; (h <a>:&gt;</a> s) -&gt; h <a>:&gt;</a> s <a>:&gt;</a> a
--   </pre>
downward :: ALens' s a -> h :> (s :@ j) -> (h :> (s :@ j)) :>> a

-- | Step down into a <a>IndexedLens</a>. This is a constrained form of
--   <a>ifromWithin</a> for when you know there is precisely one target
--   that can never fail.
--   
--   <pre>
--   <a>idownward</a> :: <a>IndexedLens'</a> i s a -&gt; (h <a>:&gt;</a> s:@j) -&gt; h <a>:&gt;</a> s:@j <a>:&gt;</a> a:@i
--   </pre>
idownward :: Ord i => AnIndexedLens' i s a -> h :> (s :@ j) -> (h :> (s :@ j)) :> (a :@ i)

-- | Step down into the <a>leftmost</a> entry of a <a>Traversal</a>.
--   
--   <pre>
--   <a>within</a> :: <a>Traversal'</a> s a -&gt; (h <a>:&gt;</a> s:@j) -&gt; <a>Maybe</a> (h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a)
--   <a>within</a> :: <a>Prism'</a> s a     -&gt; (h <a>:&gt;</a> s:@j) -&gt; <a>Maybe</a> (h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a)
--   <a>within</a> :: <a>Lens'</a> s a      -&gt; (h <a>:&gt;</a> s:@j) -&gt; <a>Maybe</a> (h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a)
--   <a>within</a> :: <a>Iso'</a> s a       -&gt; (h <a>:&gt;</a> s:@j) -&gt; <a>Maybe</a> (h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a)
--   </pre>
--   
--   <pre>
--   <a>within</a> :: <a>MonadPlus</a> m =&gt; <a>ATraversal'</a> s a -&gt; (h <a>:&gt;</a> s:@j) -&gt; m (h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a)
--   </pre>
within :: MonadPlus m => LensLike' (Indexing (Bazaar' (Indexed Int) a)) s a -> (h :> (s :@ j)) -> m ((h :> (s :@ j)) :>> a)

-- | Step down into the <a>leftmost</a> entry of an
--   <a>IndexedTraversal</a>.
--   
--   <i>Note:</i> The index is assumed to be ordered and must increase
--   monotonically or else you cannot (safely) <a>moveTo</a> or
--   <a>moveToward</a> or use tapes.
--   
--   <pre>
--   <a>iwithin</a> :: <a>IndexedTraversal'</a> i s a -&gt; (h <a>:&gt;</a> s:@j) -&gt; <a>Maybe</a> (h <a>:&gt;</a> s:@j <a>:&gt;</a> a:@i)
--   <a>iwithin</a> :: <a>IndexedLens'</a> i s a      -&gt; (h <a>:&gt;</a> s:@j) -&gt; <a>Maybe</a> (h <a>:&gt;</a> s:@j <a>:&gt;</a> a:@i)
--   </pre>
--   
--   <pre>
--   <a>iwithin</a> :: <a>MonadPlus</a> m =&gt; <a>ATraversal'</a> s a -&gt; (h <a>:&gt;</a> s:@j) -&gt; m (h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a)
--   </pre>
iwithin :: (MonadPlus m, Ord i) => AnIndexedTraversal' i s a -> (h :> (s :@ j)) -> m ((h :> (s :@ j)) :> (a :@ i))

-- | Step down into every entry of a <a>Traversal</a> simultaneously.
--   
--   <pre>
--   &gt;&gt;&gt; zipper ("hello","world") &amp; withins both &gt;&gt;= leftward &gt;&gt;= withins traverse &gt;&gt;= rightward &lt;&amp;&gt; focus %~ toUpper &lt;&amp;&gt; rezip :: [(String,String)]
--   [("hEllo","world"),("heLlo","world"),("helLo","world"),("hellO","world")]
--   </pre>
--   
--   <pre>
--   <a>withins</a> :: <a>Traversal'</a> s a -&gt; (h <a>:&gt;</a> s:@j) -&gt; [h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a]
--   <a>withins</a> :: <a>Lens'</a> s a      -&gt; (h <a>:&gt;</a> s:@j) -&gt; [h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a]
--   <a>withins</a> :: <a>Iso'</a> s a       -&gt; (h <a>:&gt;</a> s:@j) -&gt; [h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a]
--   </pre>
withins :: MonadPlus m => LensLike' (Indexing (Bazaar' (Indexed Int) a)) s a -> (h :> (s :@ j)) -> m ((h :> (s :@ j)) :>> a)

-- | Step down into every entry of an <a>IndexedTraversal</a>
--   simultaneously.
--   
--   <i>Note:</i> The index is assumed to be ordered and must increase
--   monotonically or else you cannot (safely) <a>moveTo</a> or
--   <a>moveToward</a> or use tapes.
--   
--   <pre>
--   <a>iwithins</a> :: <a>IndexedTraversal'</a> i s a -&gt; (h <a>:&gt;</a> s:@j) -&gt; [h <a>:&gt;</a> s:@j <a>:&gt;</a> a:@i]
--   <a>iwithins</a> :: <a>IndexedLens'</a> i s a      -&gt; (h <a>:&gt;</a> s:@j) -&gt; [h <a>:&gt;</a> s:@j <a>:&gt;</a> a:@i]
--   </pre>
iwithins :: (MonadPlus m, Ord i) => AnIndexedTraversal' i s a -> (h :> (s :@ j)) -> m ((h :> (s :@ j)) :> (a :@ i))

-- | Unsafely step down into a <a>Traversal</a> that is <i>assumed</i> to
--   be non-empty.
--   
--   If this invariant is not met then this will usually result in an
--   error!
--   
--   <pre>
--   <a>fromWithin</a> :: <a>Traversal'</a> s a -&gt; (h <a>:&gt;</a> s:@j) -&gt; h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a
--   <a>fromWithin</a> :: <a>Lens'</a> s a      -&gt; (h <a>:&gt;</a> s:@j) -&gt; h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a
--   <a>fromWithin</a> :: <a>Iso'</a> s a       -&gt; (h <a>:&gt;</a> s:@j) -&gt; h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a
--   </pre>
--   
--   You can reason about this function as if the definition was:
--   
--   <pre>
--   <a>fromWithin</a> l ≡ <a>fromJust</a> <a>.</a> <a>within</a> l
--   </pre>
fromWithin :: LensLike' (Indexing (Bazaar' (Indexed Int) a)) s a -> (h :> (s :@ j)) -> (h :> (s :@ j)) :>> a

-- | Unsafey step down into an <a>IndexedTraversal</a> that is
--   <i>assumed</i> to be non-empty
--   
--   If this invariant is not met then this will usually result in an
--   error!
--   
--   <pre>
--   <a>ifromWithin</a> :: <a>IndexedTraversal'</a> i s a -&gt; (h <a>:&gt;</a> s:@j) -&gt; h <a>:&gt;</a> s:@j <a>:&gt;</a> a:@i
--   <a>ifromWithin</a> :: <a>IndexedLens'</a> i s a      -&gt; (h <a>:&gt;</a> s:@j) -&gt; h <a>:&gt;</a> s:@j <a>:&gt;</a> a:@i
--   </pre>
--   
--   You can reason about this function as if the definition was:
--   
--   <pre>
--   <a>fromWithin</a> l ≡ <a>fromJust</a> <a>.</a> <a>within</a> l
--   </pre>
ifromWithin :: Ord i => AnIndexedTraversal' i s a -> (h :> (s :@ j)) -> (h :> (s :@ j)) :> (a :@ i)

-- | This enables us to pull the <a>Zipper</a> back up to the <a>Top</a>.
class Zipping h a
recoil :: Zipping h a => Coil h i a -> Jacket i a -> Zipped h a

-- | Close something back up that you opened as a <a>Zipper</a>.
rezip :: Zipping h a => (h :> (a :@ i)) -> Zipped h a

-- | Extract the current <a>focus</a> from a <a>Zipper</a> as a
--   <a>Pretext</a>, with access to the current index.
focusedContext :: (Indexable i p, Zipping h a) => (h :> (a :@ i)) -> Pretext p a a (Zipped h a)

-- | A <a>Tape</a> is a recorded path through the (indexed)
--   <a>Traversal</a> chain of a <a>Zipper</a>.
data Tape h i a
Tape :: Track h i a -> i -> Tape h i a

-- | Save the current path as as a <a>Tape</a> we can play back later.
saveTape :: Zipper h i a -> Tape h i a

-- | Restore ourselves to a previously recorded position precisely.
--   
--   If the position does not exist, then fail.
restoreTape :: MonadPlus m => Tape h i a -> Zipped h a -> m (Zipper h i a)

-- | Restore ourselves to a location near our previously recorded position.
--   
--   When moving left to right through a <a>Traversal</a>, if this will
--   clamp at each level to the range <tt>0 <a>&lt;=</a> k <a>&lt;</a>
--   <a>teeth</a></tt>, so the only failures will occur when one of the
--   sequence of downward traversals find no targets.
restoreNearTape :: MonadPlus m => Tape h i a -> Zipped h a -> m (Zipper h i a)

-- | Restore ourselves to a previously recorded position.
--   
--   This *assumes* that nothing has been done in the meantime to affect
--   the existence of anything on the entire path.
--   
--   Motions <a>leftward</a> or <a>rightward</a> are clamped, but all
--   traversals included on the <a>Tape</a> are assumed to be non-empty.
--   
--   Violate these assumptions at your own risk!
unsafelyRestoreTape :: Tape h i a -> Zipped h a -> Zipper h i a

-- | This is used to peel off the path information from a <a>Coil</a> for
--   use when saving the current path for later replay.
peel :: Coil h i a -> Track h i a

-- | The <a>Track</a> forms the bulk of a <a>Tape</a>.
data Track t i a
Track :: Track Top Int a
Fork :: Track h j s -> j -> AnIndexedTraversal' i s a -> Track (Zipper h j s) i a

-- | Restore ourselves to a previously recorded position precisely.
--   
--   If the position does not exist, then fail.
restoreTrack :: MonadPlus m => Track h i a -> Zipped h a -> m (Zipper h i a)

-- | Restore ourselves to a location near our previously recorded position.
--   
--   When moving <a>leftward</a> to <a>rightward</a> through a
--   <a>Traversal</a>, if this will clamp at each level to the range <tt>0
--   <a>&lt;=</a> k <a>&lt;</a> <a>teeth</a></tt>, so the only failures
--   will occur when one of the sequence of downward traversals find no
--   targets.
restoreNearTrack :: MonadPlus m => Track h i a -> Zipped h a -> m (Zipper h i a)

-- | Restore ourselves to a previously recorded position.
--   
--   This *assumes* that nothing has been done in the meantime to affect
--   the existence of anything on the entire <a>Path</a>.
--   
--   Motions <a>leftward</a> or <a>rightward</a> are clamped, but all
--   traversals included on the <a>Tape</a> are assumed to be non-empty.
--   
--   Violate these assumptions at your own risk!
unsafelyRestoreTrack :: Track h i a -> Zipped h a -> Zipper h i a
instance (Show i, Show a) => Show (Jacket i a)
instance (Show i, Show a) => Show (Path i a)
instance Zipping h s => Zipping (Zipper h i s) a
instance Zipping Top a
instance Functor (Path i)
instance Applicative (Flow i b)
instance Apply (Flow i b)
instance Functor (Flow i b)
instance Monoid (Jacket i a)
instance TraversableWithIndex i (Jacket i)
instance FoldableWithIndex i (Jacket i)
instance FunctorWithIndex i (Jacket i)
instance Traversable (Jacket i)
instance Foldable (Jacket i)
instance Functor (Jacket i)


-- | This module provides a <a>Zipper</a> with fairly strong type checking
--   guarantees.
--   
--   The code here is inspired by Brandon Simmons' <tt>zippo</tt> package,
--   but uses a different approach to represent the <a>Zipper</a> that
--   makes the whole thing look like his breadcrumb trail, and can move
--   side-to-side through traversals.
--   
--   Some examples types:
--   
--   <ul>
--   <li><i><tt><a>Top</a> <a>:&gt;&gt;</a> a</tt></i> represents a trivial
--   <a>Zipper</a> with its focus at the root.</li>
--   <li><i><tt><a>Top</a> <a>:&gt;&gt;</a> <a>Tree</a> a <a>:&gt;&gt;</a>
--   a</tt></i> represents a <a>Zipper</a> that starts with a <a>Tree</a>
--   and descends in a single step to values of type <tt>a</tt>.</li>
--   <li><i><tt><a>Top</a> <a>:&gt;&gt;</a> <a>Tree</a> a <a>:&gt;&gt;</a>
--   <a>Tree</a> a <a>:&gt;&gt;</a> <a>Tree</a> a</tt></i> represents a
--   <a>Zipper</a> into a <a>Tree</a> with an intermediate bookmarked
--   <a>Tree</a>, focusing in yet another <a>Tree</a>.</li>
--   </ul>
--   
--   Since individual levels of a <a>Zipper</a> are managed by an arbitrary
--   <a>IndexedTraversal</a>, you can move left and right through the
--   <a>IndexedTraversal</a> selecting neighboring elements.
--   
--   <pre>
--   &gt;&gt;&gt; zipper ("hello","world") &amp; downward _1 &amp; fromWithin traverse &amp; focus .~ 'J' &amp; rightmost &amp; focus .~ 'y' &amp; rezip
--   ("Jelly","world")
--   </pre>
--   
--   This is particularly powerful when compiled with <a>plate</a>,
--   <a>uniplate</a> or <a>biplate</a> for walking down into self-similar
--   children in syntax trees and other structures.
--   
--   Given keys in ascending order you can jump directly to a given key
--   with <a>moveTo</a>. When used with traversals for balanced tree-like
--   structures such as an <a>IntMap</a> or <a>Map</a>, searching for a key
--   with <a>moveTo</a> can be done in logarithmic time.
module Control.Lens.Zipper

-- | This is used to represent the <a>Top</a> of the <a>Zipper</a>.
--   
--   Every <a>Zipper</a> starts with <a>Top</a>.
--   
--   <i>e.g.</i> <tt><a>Top</a> <a>:&gt;&gt;</a> a</tt> is the type of the
--   trivial <a>Zipper</a>.
data Top

-- | This type family represents a <a>Zipper</a> with the <tt>p</tt>
--   variable abstracting over the position and the index, in terms of
--   <a>:@</a>. You can visually see it in type signatures as:
--   
--   <pre>
--   h <a>:&gt;</a> (a <a>:@</a> i) = <a>Zipper</a> h i a
--   </pre>

-- | Many zippers are indexed by Int keys. This type alias is convenient
--   for reducing syntactic noise for talking about these boring indices.
type (:>>) h a = Zipper h Int a

-- | An empty data type, used to represent the pairing of a position in a
--   <a>Zipper</a> with an index. See <a>:&gt;</a>.
data (:@) a i

-- | This is the type of a <a>Zipper</a>. It visually resembles a
--   "breadcrumb trail" as used in website navigation. Each breadcrumb in
--   the trail represents a level you can move up to.
--   
--   This type operator associates to the left, so you can use a type like
--   
--   <pre>
--   <a>Top</a> <a>:&gt;&gt;</a> (<a>String</a>,<a>Double</a>) <a>:&gt;&gt;</a> <a>String</a> <a>:&gt;&gt;</a> <a>Char</a>
--   </pre>
--   
--   to represent a <a>Zipper</a> from
--   <tt>(<a>String</a>,<a>Double</a>)</tt> down to <a>Char</a> that has an
--   intermediate crumb for the <a>String</a> containing the <a>Char</a>.
--   
--   You can construct a <a>Zipper</a> into *any* data structure with
--   <a>zipper</a>.
--   
--   You can repackage up the contents of a <a>Zipper</a> with
--   <a>rezip</a>.
--   
--   <pre>
--   &gt;&gt;&gt; rezip $ zipper 42
--   42
--   </pre>
--   
--   The combinators in this module provide lot of things you can do to the
--   <a>Zipper</a> while you have it open.
--   
--   Note that a value of type <tt>h <a>:&gt;</a> s <a>:&gt;</a> a</tt>
--   doesn't actually contain a value of type <tt>h <a>:&gt;</a> s</tt> --
--   as we descend into a level, the previous level is unpacked and stored
--   in <a>Coil</a> form. Only one value of type <tt>_ <a>:&gt;</a> _</tt>
--   exists at any particular time for any particular <a>Zipper</a>.
data Zipper h i a

-- | Construct a <a>Zipper</a> that can explore anything, and start it at
--   the <a>Top</a>.
zipper :: a -> Top :>> a

-- | This <a>Lens</a> views the current target of the <a>Zipper</a>.
focus :: IndexedLens' i (Zipper h i a) a

-- | Extract the current <a>focus</a> from a <a>Zipper</a> as a
--   <a>Pretext</a>, with access to the current index.
focusedContext :: (Indexable i p, Zipping h a) => (h :> (a :@ i)) -> Pretext p a a (Zipped h a)

-- | Move the <a>Zipper</a> <a>upward</a>, closing the current level and
--   focusing on the parent element.
--   
--   NB: Attempts to move upward from the <a>Top</a> of the <a>Zipper</a>
--   will fail to typecheck.
upward :: Ord j => (h :> (s :@ j)) :> (a :@ i) -> h :> (s :@ j)

-- | Step down into a <a>Lens</a>. This is a constrained form of
--   <a>fromWithin</a> for when you know there is precisely one target that
--   can never fail.
--   
--   <pre>
--   <a>downward</a> :: <a>Lens'</a> s a -&gt; (h <a>:&gt;</a> s) -&gt; h <a>:&gt;</a> s <a>:&gt;</a> a
--   <a>downward</a> :: <a>Iso'</a> s a  -&gt; (h <a>:&gt;</a> s) -&gt; h <a>:&gt;</a> s <a>:&gt;</a> a
--   </pre>
downward :: ALens' s a -> h :> (s :@ j) -> (h :> (s :@ j)) :>> a

-- | Step down into a <a>IndexedLens</a>. This is a constrained form of
--   <a>ifromWithin</a> for when you know there is precisely one target
--   that can never fail.
--   
--   <pre>
--   <a>idownward</a> :: <a>IndexedLens'</a> i s a -&gt; (h <a>:&gt;</a> s:@j) -&gt; h <a>:&gt;</a> s:@j <a>:&gt;</a> a:@i
--   </pre>
idownward :: Ord i => AnIndexedLens' i s a -> h :> (s :@ j) -> (h :> (s :@ j)) :> (a :@ i)

-- | Step down into the <a>leftmost</a> entry of a <a>Traversal</a>.
--   
--   <pre>
--   <a>within</a> :: <a>Traversal'</a> s a -&gt; (h <a>:&gt;</a> s:@j) -&gt; <a>Maybe</a> (h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a)
--   <a>within</a> :: <a>Prism'</a> s a     -&gt; (h <a>:&gt;</a> s:@j) -&gt; <a>Maybe</a> (h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a)
--   <a>within</a> :: <a>Lens'</a> s a      -&gt; (h <a>:&gt;</a> s:@j) -&gt; <a>Maybe</a> (h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a)
--   <a>within</a> :: <a>Iso'</a> s a       -&gt; (h <a>:&gt;</a> s:@j) -&gt; <a>Maybe</a> (h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a)
--   </pre>
--   
--   <pre>
--   <a>within</a> :: <a>MonadPlus</a> m =&gt; <a>ATraversal'</a> s a -&gt; (h <a>:&gt;</a> s:@j) -&gt; m (h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a)
--   </pre>
within :: MonadPlus m => LensLike' (Indexing (Bazaar' (Indexed Int) a)) s a -> (h :> (s :@ j)) -> m ((h :> (s :@ j)) :>> a)

-- | Step down into the <a>leftmost</a> entry of an
--   <a>IndexedTraversal</a>.
--   
--   <i>Note:</i> The index is assumed to be ordered and must increase
--   monotonically or else you cannot (safely) <a>moveTo</a> or
--   <a>moveToward</a> or use tapes.
--   
--   <pre>
--   <a>iwithin</a> :: <a>IndexedTraversal'</a> i s a -&gt; (h <a>:&gt;</a> s:@j) -&gt; <a>Maybe</a> (h <a>:&gt;</a> s:@j <a>:&gt;</a> a:@i)
--   <a>iwithin</a> :: <a>IndexedLens'</a> i s a      -&gt; (h <a>:&gt;</a> s:@j) -&gt; <a>Maybe</a> (h <a>:&gt;</a> s:@j <a>:&gt;</a> a:@i)
--   </pre>
--   
--   <pre>
--   <a>iwithin</a> :: <a>MonadPlus</a> m =&gt; <a>ATraversal'</a> s a -&gt; (h <a>:&gt;</a> s:@j) -&gt; m (h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a)
--   </pre>
iwithin :: (MonadPlus m, Ord i) => AnIndexedTraversal' i s a -> (h :> (s :@ j)) -> m ((h :> (s :@ j)) :> (a :@ i))

-- | Step down into every entry of a <a>Traversal</a> simultaneously.
--   
--   <pre>
--   &gt;&gt;&gt; zipper ("hello","world") &amp; withins both &gt;&gt;= leftward &gt;&gt;= withins traverse &gt;&gt;= rightward &lt;&amp;&gt; focus %~ toUpper &lt;&amp;&gt; rezip :: [(String,String)]
--   [("hEllo","world"),("heLlo","world"),("helLo","world"),("hellO","world")]
--   </pre>
--   
--   <pre>
--   <a>withins</a> :: <a>Traversal'</a> s a -&gt; (h <a>:&gt;</a> s:@j) -&gt; [h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a]
--   <a>withins</a> :: <a>Lens'</a> s a      -&gt; (h <a>:&gt;</a> s:@j) -&gt; [h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a]
--   <a>withins</a> :: <a>Iso'</a> s a       -&gt; (h <a>:&gt;</a> s:@j) -&gt; [h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a]
--   </pre>
withins :: MonadPlus m => LensLike' (Indexing (Bazaar' (Indexed Int) a)) s a -> (h :> (s :@ j)) -> m ((h :> (s :@ j)) :>> a)

-- | Step down into every entry of an <a>IndexedTraversal</a>
--   simultaneously.
--   
--   <i>Note:</i> The index is assumed to be ordered and must increase
--   monotonically or else you cannot (safely) <a>moveTo</a> or
--   <a>moveToward</a> or use tapes.
--   
--   <pre>
--   <a>iwithins</a> :: <a>IndexedTraversal'</a> i s a -&gt; (h <a>:&gt;</a> s:@j) -&gt; [h <a>:&gt;</a> s:@j <a>:&gt;</a> a:@i]
--   <a>iwithins</a> :: <a>IndexedLens'</a> i s a      -&gt; (h <a>:&gt;</a> s:@j) -&gt; [h <a>:&gt;</a> s:@j <a>:&gt;</a> a:@i]
--   </pre>
iwithins :: (MonadPlus m, Ord i) => AnIndexedTraversal' i s a -> (h :> (s :@ j)) -> m ((h :> (s :@ j)) :> (a :@ i))

-- | Jerk the <a>Zipper</a> <a>leftward</a> one <a>tooth</a> within the
--   current <a>Lens</a> or <a>Traversal</a>.
--   
--   Attempts to move past the end of the current <a>Traversal</a> (or
--   trivially, the current <a>Lens</a>) will return <a>Nothing</a>.
--   
--   <pre>
--   &gt;&gt;&gt; isNothing $ zipper "hello" &amp; leftward
--   True
--   </pre>
leftward :: MonadPlus m => h :> (a :@ i) -> m (h :> (a :@ i))

-- | Jerk the <a>Zipper</a> one <a>tooth</a> to the <a>rightward</a> within
--   the current <a>Lens</a> or <a>Traversal</a>.
--   
--   Attempts to move past the start of the current <a>Traversal</a> (or
--   trivially, the current <a>Lens</a>) will return <a>Nothing</a>.
--   
--   <pre>
--   &gt;&gt;&gt; isNothing $ zipper "hello" &amp; rightward
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; zipper "hello" &amp; fromWithin traverse &amp; rightward &lt;&amp;&gt; view focus
--   'e'
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; zipper "hello" &amp; fromWithin traverse &amp; rightward &lt;&amp;&gt; focus .~ 'u' &lt;&amp;&gt; rezip
--   "hullo"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; rezip $ zipper (1,2) &amp; fromWithin both &amp; tug rightward &amp; focus .~ 3
--   (1,3)
--   </pre>
rightward :: MonadPlus m => h :> (a :@ i) -> m (h :> (a :@ i))

-- | Move to the leftmost position of the current <a>Traversal</a>.
--   
--   This is just a convenient alias for <tt><a>farthest</a>
--   <a>leftward</a></tt>.
--   
--   <pre>
--   &gt;&gt;&gt; zipper "hello" &amp; fromWithin traverse &amp; leftmost &amp; focus .~ 'a' &amp; rezip
--   "aello"
--   </pre>
leftmost :: a :> (b :@ i) -> a :> (b :@ i)

-- | Move to the rightmost position of the current <a>Traversal</a>.
--   
--   This is just a convenient alias for <tt><a>farthest</a>
--   <a>rightward</a></tt>.
--   
--   <pre>
--   &gt;&gt;&gt; zipper "hello" &amp; fromWithin traverse &amp; rightmost &amp; focus .~ 'y' &amp; leftmost &amp; focus .~ 'j' &amp; rezip
--   "jelly"
--   </pre>
rightmost :: a :> (b :@ i) -> a :> (b :@ i)

-- | This allows you to safely <a>tug</a> <a>leftward</a> or <a>tug</a>
--   <a>rightward</a> on a <a>Zipper</a>. This will attempt the move, and
--   stay where it was if it fails.
--   
--   The more general signature allows its use in other circumstances,
--   however.
--   
--   <pre>
--   <a>tug</a> f x ≡ <a>fromMaybe</a> a (f a)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; fmap rezip $ zipper "hello" &amp; within traverse &lt;&amp;&gt; tug leftward &lt;&amp;&gt; focus .~ 'j'
--   "jello"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; fmap rezip $ zipper "hello" &amp; within traverse &lt;&amp;&gt; tug rightward &lt;&amp;&gt; focus .~ 'u'
--   "hullo"
--   </pre>
tug :: (a -> Maybe a) -> a -> a

-- | This allows you to safely <tt><a>tug</a> <a>leftward</a></tt> or
--   <tt><a>tug</a> <a>rightward</a></tt> multiple times on a
--   <a>Zipper</a>, moving multiple steps in a given direction and stopping
--   at the last place you couldn't move from. This lets you safely move a
--   <a>Zipper</a>, because it will stop at either end.
--   
--   <pre>
--   &gt;&gt;&gt; fmap rezip $ zipper "stale" &amp; within traverse &lt;&amp;&gt; tugs rightward 2 &lt;&amp;&gt; focus .~ 'y'
--   "style"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; rezip $ zipper "want" &amp; fromWithin traverse &amp; tugs rightward 2 &amp; focus .~ 'r' &amp; tugs leftward 100 &amp; focus .~ 'c'
--   "cart"
--   </pre>
tugs :: (a -> Maybe a) -> Int -> a -> a

-- | This allows for you to repeatedly pull a <a>Zipper</a> in a given
--   direction, failing if it falls off the end.
--   
--   <pre>
--   &gt;&gt;&gt; isNothing $ zipper "hello" &amp; within traverse &gt;&gt;= jerks rightward 10
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; fmap rezip $ zipper "silly" &amp; within traverse &gt;&gt;= jerks rightward 3 &lt;&amp;&gt; focus .~ 'k'
--   "silky"
--   </pre>
jerks :: Monad m => (a -> m a) -> Int -> a -> m a

-- | Move in a direction as far as you can go, then stop there.
--   
--   This repeatedly applies a function until it returns <a>Nothing</a>,
--   and then returns the last answer.
--   
--   <pre>
--   &gt;&gt;&gt; fmap rezip $ zipper ("hello","world") &amp; downward _1 &amp; within traverse &lt;&amp;&gt; rightmost &lt;&amp;&gt; focus .~ 'a'
--   ("hella","world")
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; rezip $ zipper ("hello","there") &amp; fromWithin (both.traverse) &amp; rightmost &amp; focus .~ 'm'
--   ("hello","therm")
--   </pre>
farthest :: (a -> Maybe a) -> a -> a

-- | Return the index into the current <a>Traversal</a> within the current
--   level of the <a>Zipper</a>.
--   
--   <pre>
--   <a>jerkTo</a> (<a>tooth</a> l) l = <a>Just</a>
--   </pre>
--   
--   Mnemonically, zippers have a number of <a>teeth</a> within each level.
--   This is which <a>tooth</a> you are currently at.
--   
--   This is based on ordinal position regardless of the underlying index
--   type. It may be excessively expensive for a list.
--   
--   <a>focalPoint</a> may be much cheaper if you have a <a>Traversal</a>
--   indexed by ordinal position!
tooth :: Zipper h i a -> Int

-- | Returns the number of siblings at the current level in the
--   <a>Zipper</a>.
--   
--   <pre>
--   <a>teeth</a> z <a>&gt;=</a> 1
--   </pre>
--   
--   <i>NB:</i> If the current <a>Traversal</a> targets an infinite number
--   of elements then this may not terminate.
--   
--   This is also a particularly expensive operation to perform on an
--   unbalanced tree.
--   
--   <pre>
--   &gt;&gt;&gt; zipper ("hello","world") &amp; teeth
--   1
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; zipper ("hello","world") &amp; fromWithin both &amp; teeth
--   2
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; zipper ("hello","world") &amp; downward _1 &amp; teeth
--   1
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; zipper ("hello","world") &amp; downward _1 &amp; fromWithin traverse &amp; teeth
--   5
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; zipper ("hello","world") &amp; fromWithin (_1.traverse) &amp; teeth
--   5
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; zipper ("hello","world") &amp; fromWithin (both.traverse) &amp; teeth
--   10
--   </pre>
teeth :: h :> (a :@ i) -> Int

-- | Move the <a>Zipper</a> horizontally to the element in the <tt>n</tt>th
--   position in the current level, absolutely indexed, starting with the
--   <a>farthest</a> <a>leftward</a> as <tt>0</tt>.
--   
--   This returns <a>Nothing</a> if the target element doesn't exist.
--   
--   <pre>
--   <a>jerkTo</a> n ≡ <a>jerks</a> <a>rightward</a> n <a>.</a> <a>farthest</a> <a>leftward</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; isNothing $ zipper "not working." &amp; jerkTo 20
--   True
--   </pre>
jerkTo :: MonadPlus m => Int -> (h :> (a :@ i)) -> m (h :> (a :@ i))

-- | Move the <a>Zipper</a> horizontally to the element in the <tt>n</tt>th
--   position of the current level, absolutely indexed, starting with the
--   <a>farthest</a> <a>leftward</a> as <tt>0</tt>.
--   
--   If the element at that position doesn't exist, then this will clamp to
--   the range <tt>0 <a>&lt;=</a> n <a>&lt;</a> <a>teeth</a></tt>.
--   
--   <pre>
--   <a>tugTo</a> n ≡ <a>tugs</a> <a>rightward</a> n <a>.</a> <a>farthest</a> <a>leftward</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; rezip $ zipper "not working." &amp; fromWithin traverse &amp; tugTo 100 &amp; focus .~ '!' &amp; tugTo 1 &amp; focus .~ 'u'
--   "nut working!"
--   </pre>
tugTo :: Int -> h :> (a :@ i) -> h :> (a :@ i)

-- | Move horizontally to a particular index <tt>i</tt> in the current
--   <a>Traversal</a>. In the case of simple zippers, the index is
--   <a>Int</a> and we can move between traversals fairly easily:
--   
--   <pre>
--   &gt;&gt;&gt; zipper (42, 32) &amp; fromWithin both &amp; moveTo 0 &lt;&amp;&gt; view focus
--   42
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; zipper (42, 32) &amp; fromWithin both &amp; moveTo 1 &lt;&amp;&gt; view focus
--   32
--   </pre>
moveTo :: MonadPlus m => i -> h :> (a :@ i) -> m (h :> (a :@ i))

-- | Move towards a particular index in the current <a>Traversal</a>.
moveToward :: i -> h :> (a :@ i) -> h :> (a :@ i)

-- | Close something back up that you opened as a <a>Zipper</a>.
rezip :: Zipping h a => (h :> (a :@ i)) -> Zipped h a

-- | This represents the type a <a>Zipper</a> will have when it is fully
--   <a>Zipped</a> back up.

-- | This enables us to pull the <a>Zipper</a> back up to the <a>Top</a>.
class Zipping h a

-- | A <a>Tape</a> is a recorded path through the (indexed)
--   <a>Traversal</a> chain of a <a>Zipper</a>.
data Tape h i a

-- | Save the current path as as a <a>Tape</a> we can play back later.
saveTape :: Zipper h i a -> Tape h i a

-- | Restore ourselves to a previously recorded position precisely.
--   
--   If the position does not exist, then fail.
restoreTape :: MonadPlus m => Tape h i a -> Zipped h a -> m (Zipper h i a)

-- | Restore ourselves to a location near our previously recorded position.
--   
--   When moving left to right through a <a>Traversal</a>, if this will
--   clamp at each level to the range <tt>0 <a>&lt;=</a> k <a>&lt;</a>
--   <a>teeth</a></tt>, so the only failures will occur when one of the
--   sequence of downward traversals find no targets.
restoreNearTape :: MonadPlus m => Tape h i a -> Zipped h a -> m (Zipper h i a)

-- | Unsafely step down into a <a>Traversal</a> that is <i>assumed</i> to
--   be non-empty.
--   
--   If this invariant is not met then this will usually result in an
--   error!
--   
--   <pre>
--   <a>fromWithin</a> :: <a>Traversal'</a> s a -&gt; (h <a>:&gt;</a> s:@j) -&gt; h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a
--   <a>fromWithin</a> :: <a>Lens'</a> s a      -&gt; (h <a>:&gt;</a> s:@j) -&gt; h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a
--   <a>fromWithin</a> :: <a>Iso'</a> s a       -&gt; (h <a>:&gt;</a> s:@j) -&gt; h <a>:&gt;</a> s:@j <a>:&gt;&gt;</a> a
--   </pre>
--   
--   You can reason about this function as if the definition was:
--   
--   <pre>
--   <a>fromWithin</a> l ≡ <a>fromJust</a> <a>.</a> <a>within</a> l
--   </pre>
fromWithin :: LensLike' (Indexing (Bazaar' (Indexed Int) a)) s a -> (h :> (s :@ j)) -> (h :> (s :@ j)) :>> a

-- | Unsafey step down into an <a>IndexedTraversal</a> that is
--   <i>assumed</i> to be non-empty
--   
--   If this invariant is not met then this will usually result in an
--   error!
--   
--   <pre>
--   <a>ifromWithin</a> :: <a>IndexedTraversal'</a> i s a -&gt; (h <a>:&gt;</a> s:@j) -&gt; h <a>:&gt;</a> s:@j <a>:&gt;</a> a:@i
--   <a>ifromWithin</a> :: <a>IndexedLens'</a> i s a      -&gt; (h <a>:&gt;</a> s:@j) -&gt; h <a>:&gt;</a> s:@j <a>:&gt;</a> a:@i
--   </pre>
--   
--   You can reason about this function as if the definition was:
--   
--   <pre>
--   <a>fromWithin</a> l ≡ <a>fromJust</a> <a>.</a> <a>within</a> l
--   </pre>
ifromWithin :: Ord i => AnIndexedTraversal' i s a -> (h :> (s :@ j)) -> (h :> (s :@ j)) :> (a :@ i)

-- | Restore ourselves to a previously recorded position.
--   
--   This *assumes* that nothing has been done in the meantime to affect
--   the existence of anything on the entire path.
--   
--   Motions <a>leftward</a> or <a>rightward</a> are clamped, but all
--   traversals included on the <a>Tape</a> are assumed to be non-empty.
--   
--   Violate these assumptions at your own risk!
unsafelyRestoreTape :: Tape h i a -> Zipped h a -> Zipper h i a


-- | This module is designed to be imported qualified.
module Control.Lens.Internal.Deque

-- | A Banker's deque based on Chris Okasaki's "Purely Functional Data
--   Structures"
data Deque a
BD :: !Int -> [a] -> !Int -> [a] -> Deque a

-- | <i>O(1)</i>. Calculate the size of a <a>Deque</a>
--   
--   <pre>
--   &gt;&gt;&gt; size (fromList [1,4,6])
--   3
--   </pre>
size :: Deque a -> Int

-- | <i>O(n)</i> amortized. Construct a <a>Deque</a> from a list of values.
--   
--   <pre>
--   &gt;&gt;&gt; fromList [1,2]
--   BD 1 [1] 1 [2]
--   </pre>
fromList :: [a] -> Deque a

-- | <i>O(1)</i>. Determine of a <a>Deque</a> is <a>empty</a>.
--   
--   <pre>
--   &gt;&gt;&gt; null empty
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; null (singleton 1)
--   False
--   </pre>
null :: Deque a -> Bool

-- | <i>O(1)</i>. Generate a singleton <a>Deque</a>
--   
--   <pre>
--   &gt;&gt;&gt; singleton 1
--   BD 1 [1] 0 []
--   </pre>
singleton :: a -> Deque a
instance Show a => Show (Deque a)
instance (Choice p, Applicative f) => Snoc p f (Deque a) (Deque b) a b
instance (Choice p, Applicative f) => Cons p f (Deque a) (Deque b) a b
instance Monoid (Deque a)
instance Semigroup (Deque a)
instance TraversableWithIndex Int Deque
instance Traversable Deque
instance FoldableWithIndex Int Deque
instance Foldable Deque
instance MonadPlus Deque
instance Monad Deque
instance Bind Deque
instance Reversing (Deque a)
instance Alternative Deque
instance Plus Deque
instance Alt Deque
instance Applicative Deque
instance Apply Deque
instance FunctorWithIndex Int Deque
instance Functor Deque
instance Ord a => Ord (Deque a)
instance Eq a => Eq (Deque a)


module Control.Lens.Each

-- | This is a common <a>Index</a> type shared by <a>Each</a>, <a>At</a>,
--   <a>Contains</a> and <a>Ixed</a>.

-- | Extract <a>each</a> element of a (potentially monomorphic) container.
--   
--   Notably, when applied to a tuple, this generalizes <a>both</a> to
--   arbitrary homogeneous tuples.
--   
--   <pre>
--   &gt;&gt;&gt; (1,2,3) &amp; each *~ 10
--   (10,20,30)
--   </pre>
--   
--   It can also be used on monomorphic containers like <a>Text</a> or
--   <a>ByteString</a>.
--   
--   <pre>
--   &gt;&gt;&gt; over each Char.toUpper ("hello"^.Text.packed)
--   "HELLO"
--   </pre>
--   
--   <a>each</a> is an <a>IndexedTraversal</a>, so it can be used to access
--   keys in many containers:
--   
--   <pre>
--   &gt;&gt;&gt; itoListOf each $ Map.fromList [("hello",2),("world",4)]
--   [("hello",2),("world",4)]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world") &amp; each.each %~ Char.toUpper
--   ("HELLO","WORLD")
--   </pre>
class (Functor f, Index s ~ Index t) => Each f s t a b | s -> a, t -> b, s b -> t, t a -> s where each = traversed
each :: Each f s t a b => IndexedLensLike (Index s) f s t a b
instance Settable f => Each f (i -> a) (i -> b) a b
instance (Applicative f, Ix i, IArray UArray a, IArray UArray b) => Each f (UArray i a) (UArray i b) a b
instance (Applicative f, Ix i) => Each f (Array i a) (Array i b) a b
instance Applicative f => Each f ByteString ByteString Word8 Word8
instance Applicative f => Each f ByteString ByteString Word8 Word8
instance Applicative f => Each f Text Text Char Char
instance Applicative f => Each f Text Text Char Char
instance (Applicative f, Unbox a, Unbox b) => Each f (Vector a) (Vector b) a b
instance (Applicative f, Storable a, Storable b) => Each f (Vector a) (Vector b) a b
instance (Applicative f, Prim a, Prim b) => Each f (Vector a) (Vector b) a b
instance Applicative f => Each f (Vector a) (Vector b) a b
instance Applicative f => Each f (Tree a) (Tree b) a b
instance Applicative f => Each f (Seq a) (Seq b) a b
instance Applicative f => Each f (Maybe a) (Maybe b) a b
instance Functor f => Each f (Identity a) (Identity b) a b
instance Applicative f => Each f [a] [b] a b
instance Applicative f => Each f (HashMap c a) (HashMap c b) a b
instance Applicative f => Each f (IntMap a) (IntMap b) a b
instance Applicative f => Each f (Map c a) (Map c b) a b
instance Applicative f => Each f (Complex a) (Complex b) a b
instance (Applicative f, a ~ a2, a ~ a3, a ~ a4, a ~ a5, a ~ a6, a ~ a7, a ~ a8, a ~ a9, b ~ b2, b ~ b3, b ~ b4, b ~ b5, b ~ b6, b ~ b7, b ~ b8, b ~ b9) => Each f (a, a2, a3, a4, a5, a6, a7, a8, a9) (b, b2, b3, b4, b5, b6, b7, b8, b9) a b
instance (Applicative f, a ~ a2, a ~ a3, a ~ a4, a ~ a5, a ~ a6, a ~ a7, a ~ a8, b ~ b2, b ~ b3, b ~ b4, b ~ b5, b ~ b6, b ~ b7, b ~ b8) => Each f (a, a2, a3, a4, a5, a6, a7, a8) (b, b2, b3, b4, b5, b6, b7, b8) a b
instance (Applicative f, a ~ a2, a ~ a3, a ~ a4, a ~ a5, a ~ a6, a ~ a7, b ~ b2, b ~ b3, b ~ b4, b ~ b5, b ~ b6, b ~ b7) => Each f (a, a2, a3, a4, a5, a6, a7) (b, b2, b3, b4, b5, b6, b7) a b
instance (Applicative f, a ~ a2, a ~ a3, a ~ a4, a ~ a5, a ~ a6, b ~ b2, b ~ b3, b ~ b4, b ~ b5, b ~ b6) => Each f (a, a2, a3, a4, a5, a6) (b, b2, b3, b4, b5, b6) a b
instance (Applicative f, a ~ a2, a ~ a3, a ~ a4, a ~ a5, b ~ b2, b ~ b3, b ~ b4, b ~ b5) => Each f (a, a2, a3, a4, a5) (b, b2, b3, b4, b5) a b
instance (Applicative f, a ~ a2, a ~ a3, a ~ a4, b ~ b2, b ~ b3, b ~ b4) => Each f (a, a2, a3, a4) (b, b2, b3, b4) a b
instance (Applicative f, a ~ a2, a ~ a3, b ~ b2, b ~ b3) => Each f (a, a2, a3) (b, b2, b3) a b
instance (Applicative f, a ~ a', b ~ b') => Each f (a, a') (b, b') a b


-- | This module exists for users who like to work with qualified imports
--   but want access to the operators from Lens.
--   
--   <pre>
--   import qualified Control.Lens as L
--   import Control.Lens.Operators
--   </pre>
module Control.Lens.Operators

-- | Passes the result of the left side to the function on the right side
--   (forward pipe operator).
--   
--   This is the flipped version of (<a>$</a>), which is more common in
--   languages like F# as (<tt>|&gt;</tt>) where it is needed for
--   inference. Here it is supplied for notational convenience and given a
--   precedence that allows it to be nested inside uses of (<a>$</a>).
--   
--   <pre>
--   &gt;&gt;&gt; a &amp; f
--   f a
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "hello" &amp; length &amp; succ
--   6
--   </pre>
--   
--   This combinator is commonly used when applying multiple <a>Lens</a>
--   operations in sequence.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world") &amp; _1.element 0 .~ 'j' &amp; _1.element 4 .~ 'y'
--   ("jelly","world")
--   </pre>
--   
--   This reads somewhat similar to:
--   
--   <pre>
--   &gt;&gt;&gt; flip execState ("hello","world") $ do _1.element 0 .= 'j'; _1.element 4 .= 'y'
--   ("jelly","world")
--   </pre>
(&) :: a -> (a -> b) -> b

-- | Infix flipped <a>fmap</a>.
--   
--   <pre>
--   (<a>&lt;&amp;&gt;</a>) = <a>flip</a> <a>fmap</a>
--   </pre>
(<&>) :: Functor f => f a -> (a -> b) -> f b

-- | This is convenient to <a>flip</a> argument order of composite
--   functions.
--   
--   <pre>
--   &gt;&gt;&gt; over _2 ?? ("hello","world") $ length
--   ("hello",5)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over ?? length ?? ("hello","world") $ _2
--   ("hello",5)
--   </pre>
(??) :: Functor f => f (a -> b) -> a -> f b

-- | View the value pointed to by a <a>Getter</a> or <a>Lens</a> or the
--   result of folding over all the results of a <a>Fold</a> or
--   <a>Traversal</a> that points at a monoidal values.
--   
--   This is the same operation as <a>view</a> with the arguments flipped.
--   
--   The fixity and semantics are such that subsequent field accesses can
--   be performed with (<a>.</a>).
--   
--   <pre>
--   &gt;&gt;&gt; (a,b)^._2
--   b
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world")^._2
--   "world"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; import Data.Complex
--   
--   &gt;&gt;&gt; ((0, 1 :+ 2), 3)^._1._2.to magnitude
--   2.23606797749979
--   </pre>
--   
--   <pre>
--   (<a>^.</a>) ::             s -&gt; <a>Getter</a> s a     -&gt; a
--   (<a>^.</a>) :: <a>Monoid</a> m =&gt; s -&gt; <a>Fold</a> s m       -&gt; m
--   (<a>^.</a>) ::             s -&gt; <a>Iso'</a> s a       -&gt; a
--   (<a>^.</a>) ::             s -&gt; <a>Lens'</a> s a      -&gt; a
--   (<a>^.</a>) :: <a>Monoid</a> m =&gt; s -&gt; <a>Traversal'</a> s m -&gt; m
--   </pre>
(^.) :: s -> Getting a s a -> a

-- | View the value pointed to by a <a>Getter</a> or <a>Lens</a>.
--   
--   This is the same operation as <a>iview</a> with the arguments flipped.
--   
--   The fixity and semantics are such that subsequent field accesses can
--   be performed with (<a>.</a>).
--   
--   <pre>
--   &gt;&gt;&gt; (a,b,c,d)^@._2
--   (1,b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world","!!!")^@._2
--   (1,"world")
--   </pre>
--   
--   <pre>
--   (<a>^@.</a>) :: s -&gt; <a>IndexedGetter</a> i s a -&gt; (i, a)
--   (<a>^@.</a>) :: s -&gt; <a>IndexedLens'</a> i s a  -&gt; (i, a)
--   </pre>
--   
--   The result probably doesn't have much meaning when applied to an
--   <a>IndexedFold</a>.
(^@.) :: s -> IndexedGetting i (i, a) s a -> (i, a)

-- | A version of (<a>^.</a>) that works on <a>ALens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world")^#_2
--   "world"
--   </pre>
(^#) :: s -> ALens s t a b -> a

-- | Perform an <a>Action</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ["hello","world"]^!folded.act putStrLn
--   hello
--   world
--   </pre>
(^!) :: Monad m => s -> Acting m a s t a b -> m a

-- | Perform an <a>IndexedAction</a>.
(^@!) :: Monad m => s -> IndexedActing i m (i, a) s t a b -> m (i, a)

-- | Perform a <a>MonadicFold</a> and collect all of the results in a list.
--   
--   <pre>
--   &gt;&gt;&gt; ["ab","cd","ef"]^!!folded.acts
--   ["ace","acf","ade","adf","bce","bcf","bde","bdf"]
--   </pre>
(^!!) :: Monad m => s -> Acting m [a] s t a b -> m [a]

-- | Obtain a list of all of the results of an <a>IndexedMonadicFold</a>.
(^@!!) :: Monad m => s -> IndexedActing i m [(i, a)] s t a b -> m [(i, a)]

-- | Perform a <a>MonadicFold</a> and collect the leftmost result.
--   
--   <i>Note:</i> this still causes all effects for all elements.
--   
--   <pre>
--   &gt;&gt;&gt; [Just 1, Just 2, Just 3]^!?folded.acts
--   Just (Just 1)
--   
--   &gt;&gt;&gt; [Just 1, Nothing]^!?folded.acts
--   Nothing
--   </pre>
(^!?) :: Monad m => s -> Acting m (Leftmost a) s t a b -> m (Maybe a)

-- | Perform an <a>IndexedMonadicFold</a> and collect the <a>Leftmost</a>
--   result.
--   
--   <i>Note:</i> this still causes all effects for all elements.
(^@!?) :: Monad m => s -> IndexedActing i m (Leftmost (i, a)) s t a b -> m (Maybe (i, a))

-- | A convenient infix (flipped) version of <a>toListOf</a>.
--   
--   <pre>
--   &gt;&gt;&gt; [[1,2],[3]]^..traverse.traverse
--   [1,2,3]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (1,2)^..both
--   [1,2]
--   </pre>
--   
--   <pre>
--   <a>toList</a> xs ≡ xs <a>^..</a> <a>folded</a>
--   (<a>^..</a>) ≡ <a>flip</a> <a>toListOf</a>
--   </pre>
--   
--   <pre>
--   (<a>^..</a>) :: s -&gt; <a>Getter</a> s a     -&gt; [a]
--   (<a>^..</a>) :: s -&gt; <a>Fold</a> s a       -&gt; [a]
--   (<a>^..</a>) :: s -&gt; <a>Lens'</a> s a      -&gt; [a]
--   (<a>^..</a>) :: s -&gt; <a>Iso'</a> s a       -&gt; [a]
--   (<a>^..</a>) :: s -&gt; <a>Traversal'</a> s a -&gt; [a]
--   (<a>^..</a>) :: s -&gt; <a>Prism'</a> s a     -&gt; [a]
--   </pre>
(^..) :: s -> Getting (Endo [a]) s a -> [a]

-- | An infix version of <a>itoListOf</a>.
(^@..) :: s -> IndexedGetting i (Endo [(i, a)]) s a -> [(i, a)]

-- | Perform a safe <a>head</a> of a <a>Fold</a> or <a>Traversal</a> or
--   retrieve <a>Just</a> the result from a <a>Getter</a> or <a>Lens</a>.
--   
--   When using a <a>Traversal</a> as a partial <a>Lens</a>, or a
--   <a>Fold</a> as a partial <a>Getter</a> this can be a convenient way to
--   extract the optional value.
--   
--   Note: if you get stack overflows due to this, you may want to use
--   <a>firstOf</a> instead, which can deal more gracefully with heavily
--   left-biased trees.
--   
--   <pre>
--   &gt;&gt;&gt; Left 4 ^?_Left
--   Just 4
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Right 4 ^?_Left
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "world" ^? ix 3
--   Just 'l'
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "world" ^? ix 20
--   Nothing
--   </pre>
--   
--   <pre>
--   (<a>^?</a>) ≡ <a>flip</a> <a>preview</a>
--   </pre>
--   
--   <pre>
--   (<a>^?</a>) :: s -&gt; <a>Getter</a> s a     -&gt; <a>Maybe</a> a
--   (<a>^?</a>) :: s -&gt; <a>Fold</a> s a       -&gt; <a>Maybe</a> a
--   (<a>^?</a>) :: s -&gt; <a>Lens'</a> s a      -&gt; <a>Maybe</a> a
--   (<a>^?</a>) :: s -&gt; <a>Iso'</a> s a       -&gt; <a>Maybe</a> a
--   (<a>^?</a>) :: s -&gt; <a>Traversal'</a> s a -&gt; <a>Maybe</a> a
--   </pre>
(^?) :: s -> Getting (First a) s a -> Maybe a

-- | Perform a safe <a>head</a> (with index) of an <a>IndexedFold</a> or
--   <a>IndexedTraversal</a> or retrieve <a>Just</a> the index and result
--   from an <a>IndexedGetter</a> or <a>IndexedLens</a>.
--   
--   When using a <a>IndexedTraversal</a> as a partial <a>IndexedLens</a>,
--   or an <a>IndexedFold</a> as a partial <a>IndexedGetter</a> this can be
--   a convenient way to extract the optional value.
--   
--   <pre>
--   (<a>^@?</a>) :: s -&gt; <a>IndexedGetter</a> i s a     -&gt; <a>Maybe</a> (i, a)
--   (<a>^@?</a>) :: s -&gt; <a>IndexedFold</a> i s a       -&gt; <a>Maybe</a> (i, a)
--   (<a>^@?</a>) :: s -&gt; <a>IndexedLens'</a> i s a      -&gt; <a>Maybe</a> (i, a)
--   (<a>^@?</a>) :: s -&gt; <a>IndexedTraversal'</a> i s a -&gt; <a>Maybe</a> (i, a)
--   </pre>
(^@?) :: s -> IndexedGetting i (Endo (Maybe (i, a))) s a -> Maybe (i, a)

-- | Perform an *UNSAFE* <a>head</a> of a <a>Fold</a> or <a>Traversal</a>
--   assuming that it is there.
--   
--   <pre>
--   &gt;&gt;&gt; Left 4 ^?! _Left
--   4
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "world" ^?! ix 3
--   'l'
--   </pre>
--   
--   <pre>
--   (<a>^?!</a>) :: s -&gt; <a>Getter</a> s a     -&gt; a
--   (<a>^?!</a>) :: s -&gt; <a>Fold</a> s a       -&gt; a
--   (<a>^?!</a>) :: s -&gt; <a>Lens'</a> s a      -&gt; a
--   (<a>^?!</a>) :: s -&gt; <a>Iso'</a> s a       -&gt; a
--   (<a>^?!</a>) :: s -&gt; <a>Traversal'</a> s a -&gt; a
--   </pre>
(^?!) :: s -> Getting (Endo a) s a -> a

-- | Perform an *UNSAFE* <a>head</a> (with index) of an <a>IndexedFold</a>
--   or <a>IndexedTraversal</a> assuming that it is there.
--   
--   <pre>
--   (<a>^@?!</a>) :: s -&gt; <a>IndexedGetter</a> i s a     -&gt; (i, a)
--   (<a>^@?!</a>) :: s -&gt; <a>IndexedFold</a> i s a       -&gt; (i, a)
--   (<a>^@?!</a>) :: s -&gt; <a>IndexedLens'</a> i s a      -&gt; (i, a)
--   (<a>^@?!</a>) :: s -&gt; <a>IndexedTraversal'</a> i s a -&gt; (i, a)
--   </pre>
(^@?!) :: s -> IndexedGetting i (Endo (i, a)) s a -> (i, a)

-- | An infix alias for <a>review</a>.
--   
--   <pre>
--   <a>unto</a> f # x ≡ f x
--   l # x ≡ x <a>^.</a> <a>re</a> l
--   </pre>
--   
--   This is commonly used when using a <a>Prism</a> as a smart
--   constructor.
--   
--   <pre>
--   &gt;&gt;&gt; _Left # 4
--   Left 4
--   </pre>
--   
--   But it can be used for any <a>Prism</a>
--   
--   <pre>
--   &gt;&gt;&gt; base 16 # 123
--   "7b"
--   </pre>
--   
--   <pre>
--   (#) :: <a>Iso'</a>      s a -&gt; a -&gt; s
--   (#) :: <a>Prism'</a>    s a -&gt; a -&gt; s
--   (#) :: <a>Review'</a>   s a -&gt; a -&gt; s
--   (#) :: <a>Equality'</a> s a -&gt; a -&gt; s
--   </pre>
(#) :: AReview s t a b -> b -> t

-- | Replace the target of a <a>Lens</a> or all of the targets of a
--   <a>Setter</a> or <a>Traversal</a> with a constant value.
--   
--   This is an infix version of <a>set</a>, provided for consistency with
--   (<a>.=</a>).
--   
--   <pre>
--   f <a>&lt;$</a> a ≡ <a>mapped</a> <a>.~</a> f <a>$</a> a
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b,c,d) &amp; _4 .~ e
--   (a,b,c,e)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (42,"world") &amp; _1 .~ "hello"
--   ("hello","world")
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; both .~ c
--   (c,c)
--   </pre>
--   
--   <pre>
--   (<a>.~</a>) :: <a>Setter</a> s t a b    -&gt; b -&gt; s -&gt; t
--   (<a>.~</a>) :: <a>Iso</a> s t a b       -&gt; b -&gt; s -&gt; t
--   (<a>.~</a>) :: <a>Lens</a> s t a b      -&gt; b -&gt; s -&gt; t
--   (<a>.~</a>) :: <a>Traversal</a> s t a b -&gt; b -&gt; s -&gt; t
--   </pre>
(.~) :: ASetter s t a b -> b -> s -> t

-- | Replace the target of a <a>Lens</a> or all of the targets of a
--   <a>Setter</a> or <a>Traversal</a> in our monadic state with a new
--   value, irrespective of the old.
--   
--   This is an infix version of <a>assign</a>.
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 .= c; _2 .= d) (a,b)
--   (c,d)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; execState (both .= c) (a,b)
--   (c,c)
--   </pre>
--   
--   <pre>
--   (<a>.=</a>) :: <a>MonadState</a> s m =&gt; <a>Iso'</a> s a       -&gt; a -&gt; m ()
--   (<a>.=</a>) :: <a>MonadState</a> s m =&gt; <a>Lens'</a> s a      -&gt; a -&gt; m ()
--   (<a>.=</a>) :: <a>MonadState</a> s m =&gt; <a>Traversal'</a> s a -&gt; a -&gt; m ()
--   (<a>.=</a>) :: <a>MonadState</a> s m =&gt; <a>Setter'</a> s a    -&gt; a -&gt; m ()
--   </pre>
--   
--   <a>It puts the state in the monad or it gets the hose again.</a>
(.=) :: MonadState s m => ASetter s s a b -> b -> m ()

-- | Set with pass-through.
--   
--   This is mostly present for consistency, but may be useful for for
--   chaining assignments.
--   
--   If you do not need a copy of the intermediate result, then using <tt>l
--   <a>.~</a> t</tt> directly is a good idea.
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; _1 &lt;.~ c
--   (c,(c,b))
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ("good","morning","vietnam") &amp; _3 &lt;.~ "world"
--   ("world",("good","morning","world"))
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (42,Map.fromList [("goodnight","gracie")]) &amp; _2.at "hello" &lt;.~ Just "world"
--   (Just "world",(42,fromList [("goodnight","gracie"),("hello","world")]))
--   </pre>
--   
--   <pre>
--   (<a>&lt;.~</a>) :: <a>Setter</a> s t a b    -&gt; b -&gt; s -&gt; (b, t)
--   (<a>&lt;.~</a>) :: <a>Iso</a> s t a b       -&gt; b -&gt; s -&gt; (b, t)
--   (<a>&lt;.~</a>) :: <a>Lens</a> s t a b      -&gt; b -&gt; s -&gt; (b, t)
--   (<a>&lt;.~</a>) :: <a>Traversal</a> s t a b -&gt; b -&gt; s -&gt; (b, t)
--   </pre>
(<.~) :: ASetter s t a b -> b -> s -> (b, t)

-- | Set with pass-through
--   
--   This is useful for chaining assignment without round-tripping through
--   your <a>Monad</a> stack.
--   
--   <pre>
--   do x &lt;- <a>_2</a> <a>&lt;.=</a> ninety_nine_bottles_of_beer_on_the_wall
--   </pre>
--   
--   If you do not need a copy of the intermediate result, then using <tt>l
--   <a>.=</a> d</tt> will avoid unused binding warnings.
--   
--   <pre>
--   (<a>&lt;.=</a>) :: <a>MonadState</a> s m =&gt; <a>Setter</a> s s a b    -&gt; b -&gt; m b
--   (<a>&lt;.=</a>) :: <a>MonadState</a> s m =&gt; <a>Iso</a> s s a b       -&gt; b -&gt; m b
--   (<a>&lt;.=</a>) :: <a>MonadState</a> s m =&gt; <a>Lens</a> s s a b      -&gt; b -&gt; m b
--   (<a>&lt;.=</a>) :: <a>MonadState</a> s m =&gt; <a>Traversal</a> s s a b -&gt; b -&gt; m b
--   </pre>
(<.=) :: MonadState s m => ASetter s s a b -> b -> m b

-- | Modify the target of a <a>Lens</a>, but return the old value.
--   
--   When you do not need the old value, (<a>%~</a>) is more flexible.
--   
--   <pre>
--   (<a>&lt;&lt;.~</a>) ::             <a>Lens</a> s t a b      -&gt; b -&gt; s -&gt; (a, t)
--   (<a>&lt;&lt;.~</a>) ::             <a>Iso</a> s t a b       -&gt; b -&gt; s -&gt; (a, t)
--   (<a>&lt;&lt;.~</a>) :: <a>Monoid</a> a =&gt; <a>Traversal</a> s t a b -&gt; b -&gt; s -&gt; (a, t)
--   </pre>
(<<.~) :: Overloading (->) q ((,) a) s t a b -> b -> q s (a, t)

-- | Modify the target of a <a>Lens</a> into your 'Monad'\'s state by a
--   user supplied function and return the <i>old</i> value that was
--   replaced.
--   
--   When applied to a <a>Traversal</a>, it this will return a monoidal
--   summary of all of the old values present.
--   
--   When you do not need the result of the operation, (<a>%=</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;&lt;%=</a>) :: <a>MonadState</a> s m             =&gt; <a>Lens'</a> s a      -&gt; (a -&gt; a) -&gt; m a
--   (<a>&lt;&lt;%=</a>) :: <a>MonadState</a> s m             =&gt; <a>Iso'</a> s a       -&gt; (a -&gt; a) -&gt; m a
--   (<a>&lt;&lt;%=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> t) =&gt; <a>Traversal'</a> s a -&gt; (a -&gt; a) -&gt; m a
--   </pre>
(<<.=) :: MonadState s m => LensLike ((,) a) s s a b -> b -> m a

-- | A version of (<a>.~</a>) that works on <a>ALens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","there") &amp; _2 #~ "world"
--   ("hello","world")
--   </pre>
(#~) :: ALens s t a b -> b -> s -> t

-- | A version of (<a>.=</a>) that works on <a>ALens</a>.
(#=) :: MonadState s m => ALens s s a b -> b -> m ()

-- | A version of (<a>&lt;.~</a>) that works on <a>ALens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","there") &amp; _2 &lt;#~ "world"
--   ("world",("hello","world"))
--   </pre>
(<#~) :: ALens s t a b -> b -> s -> (b, t)

-- | A version of (<a>&lt;#=</a>) that works on <a>ALens</a>.
(<#=) :: MonadState s m => ALens s s a b -> b -> m b

-- | Set the target of a <a>Lens</a>, <a>Traversal</a> or <a>Setter</a> to
--   <a>Just</a> a value.
--   
--   <pre>
--   l <a>?~</a> t ≡ <a>set</a> l (<a>Just</a> t)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Nothing &amp; id ?~ a
--   Just a
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Map.empty &amp; at 3 ?~ x
--   fromList [(3,x)]
--   </pre>
--   
--   <pre>
--   (<a>?~</a>) :: <a>Setter</a> s t a (<a>Maybe</a> b)    -&gt; b -&gt; s -&gt; t
--   (<a>?~</a>) :: <a>Iso</a> s t a (<a>Maybe</a> b)       -&gt; b -&gt; s -&gt; t
--   (<a>?~</a>) :: <a>Lens</a> s t a (<a>Maybe</a> b)      -&gt; b -&gt; s -&gt; t
--   (<a>?~</a>) :: <a>Traversal</a> s t a (<a>Maybe</a> b) -&gt; b -&gt; s -&gt; t
--   </pre>
(?~) :: ASetter s t a (Maybe b) -> b -> s -> t

-- | Replace the target of a <a>Lens</a> or all of the targets of a
--   <a>Setter</a> or <a>Traversal</a> in our monadic state with
--   <a>Just</a> a new value, irrespective of the old.
--   
--   <pre>
--   &gt;&gt;&gt; execState (do at 1 ?= a; at 2 ?= b) Map.empty
--   fromList [(1,a),(2,b)]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 ?= b; _2 ?= c) (Just a, Nothing)
--   (Just b,Just c)
--   </pre>
--   
--   <pre>
--   (<a>?=</a>) :: <a>MonadState</a> s m =&gt; <a>Iso'</a> s (<a>Maybe</a> a)       -&gt; a -&gt; m ()
--   (<a>?=</a>) :: <a>MonadState</a> s m =&gt; <a>Lens'</a> s (<a>Maybe</a> a)      -&gt; a -&gt; m ()
--   (<a>?=</a>) :: <a>MonadState</a> s m =&gt; <a>Traversal'</a> s (<a>Maybe</a> a) -&gt; a -&gt; m ()
--   (<a>?=</a>) :: <a>MonadState</a> s m =&gt; <a>Setter'</a> s (<a>Maybe</a> a)    -&gt; a -&gt; m ()
--   </pre>
(?=) :: MonadState s m => ASetter s s a (Maybe b) -> b -> m ()

-- | Set to <a>Just</a> a value with pass-through.
--   
--   This is mostly present for consistency, but may be useful for for
--   chaining assignments.
--   
--   If you do not need a copy of the intermediate result, then using <tt>l
--   <a>?~</a> d</tt> directly is a good idea.
--   
--   <pre>
--   &gt;&gt;&gt; import Data.Map as Map
--   
--   &gt;&gt;&gt; _2.at "hello" &lt;?~ "world" $ (42,Map.fromList [("goodnight","gracie")])
--   ("world",(42,fromList [("goodnight","gracie"),("hello","world")]))
--   </pre>
--   
--   <pre>
--   (<a>&lt;?~</a>) :: <a>Setter</a> s t a (<a>Maybe</a> b)    -&gt; b -&gt; s -&gt; (b, t)
--   (<a>&lt;?~</a>) :: <a>Iso</a> s t a (<a>Maybe</a> b)       -&gt; b -&gt; s -&gt; (b, t)
--   (<a>&lt;?~</a>) :: <a>Lens</a> s t a (<a>Maybe</a> b)      -&gt; b -&gt; s -&gt; (b, t)
--   (<a>&lt;?~</a>) :: <a>Traversal</a> s t a (<a>Maybe</a> b) -&gt; b -&gt; s -&gt; (b, t)
--   </pre>
(<?~) :: ASetter s t a (Maybe b) -> b -> s -> (b, t)

-- | Set <a>Just</a> a value with pass-through
--   
--   This is useful for chaining assignment without round-tripping through
--   your <a>Monad</a> stack.
--   
--   <pre>
--   do x &lt;- <a>at</a> <a>foo</a> <a>&lt;?=</a> ninety_nine_bottles_of_beer_on_the_wall
--   </pre>
--   
--   If you do not need a copy of the intermediate result, then using <tt>l
--   <a>?=</a> d</tt> will avoid unused binding warnings.
--   
--   <pre>
--   (<a>&lt;?=</a>) :: <a>MonadState</a> s m =&gt; <a>Setter</a> s s a (<a>Maybe</a> b)    -&gt; b -&gt; m b
--   (<a>&lt;?=</a>) :: <a>MonadState</a> s m =&gt; <a>Iso</a> s s a (<a>Maybe</a> b)       -&gt; b -&gt; m b
--   (<a>&lt;?=</a>) :: <a>MonadState</a> s m =&gt; <a>Lens</a> s s a (<a>Maybe</a> b)      -&gt; b -&gt; m b
--   (<a>&lt;?=</a>) :: <a>MonadState</a> s m =&gt; <a>Traversal</a> s s a (<a>Maybe</a> b) -&gt; b -&gt; m b
--   </pre>
(<?=) :: MonadState s m => ASetter s s a (Maybe b) -> b -> m b

-- | Modifies the target of a <a>Lens</a> or all of the targets of a
--   <a>Setter</a> or <a>Traversal</a> with a user supplied function.
--   
--   This is an infix version of <a>over</a>.
--   
--   <pre>
--   <a>fmap</a> f ≡ <a>mapped</a> <a>%~</a> f
--   <a>fmapDefault</a> f ≡ <a>traverse</a> <a>%~</a> f
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b,c) &amp; _3 %~ f
--   (a,b,f c)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; both %~ f
--   (f a,f b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; _2 %~ length $ (1,"hello")
--   (1,5)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; traverse %~ f $ [a,b,c]
--   [f a,f b,f c]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; traverse %~ even $ [1,2,3]
--   [False,True,False]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; traverse.traverse %~ length $ [["hello","world"],["!!!"]]
--   [[5,5],[3]]
--   </pre>
--   
--   <pre>
--   (<a>%~</a>) :: <a>Setter</a> s t a b    -&gt; (a -&gt; b) -&gt; s -&gt; t
--   (<a>%~</a>) :: <a>Iso</a> s t a b       -&gt; (a -&gt; b) -&gt; s -&gt; t
--   (<a>%~</a>) :: <a>Lens</a> s t a b      -&gt; (a -&gt; b) -&gt; s -&gt; t
--   (<a>%~</a>) :: <a>Traversal</a> s t a b -&gt; (a -&gt; b) -&gt; s -&gt; t
--   </pre>
(%~) :: Profunctor p => Setting p s t a b -> p a b -> s -> t

-- | Map over the target of a <a>Lens</a> or all of the targets of a
--   <a>Setter</a> or <a>Traversal</a> in our monadic state.
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 %= f;_2 %= g) (a,b)
--   (f a,g b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; execState (do both %= f) (a,b)
--   (f a,f b)
--   </pre>
--   
--   <pre>
--   (<a>%=</a>) :: <a>MonadState</a> s m =&gt; <a>Iso'</a> s a       -&gt; (a -&gt; a) -&gt; m ()
--   (<a>%=</a>) :: <a>MonadState</a> s m =&gt; <a>Lens'</a> s a      -&gt; (a -&gt; a) -&gt; m ()
--   (<a>%=</a>) :: <a>MonadState</a> s m =&gt; <a>Traversal'</a> s a -&gt; (a -&gt; a) -&gt; m ()
--   (<a>%=</a>) :: <a>MonadState</a> s m =&gt; <a>Setter'</a> s a    -&gt; (a -&gt; a) -&gt; m ()
--   </pre>
--   
--   <pre>
--   (<a>%=</a>) :: <a>MonadState</a> s m =&gt; <a>ASetter</a> s s a b -&gt; (a -&gt; b) -&gt; m ()
--   </pre>
(%=) :: (Profunctor p, MonadState s m) => Setting p s s a b -> p a b -> m ()

-- | Modify the target of a <a>Lens</a> and return the result.
--   
--   When you do not need the result of the addition, (<a>%~</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;%~</a>) ::             <a>Lens</a> s t a b      -&gt; (a -&gt; b) -&gt; s -&gt; (b, t)
--   (<a>&lt;%~</a>) ::             <a>Iso</a> s t a b       -&gt; (a -&gt; b) -&gt; s -&gt; (b, t)
--   (<a>&lt;%~</a>) :: <a>Monoid</a> b =&gt; <a>Traversal</a> s t a b -&gt; (a -&gt; b) -&gt; s -&gt; (b, t)
--   </pre>
(<%~) :: Profunctor p => Overloading p q ((,) b) s t a b -> p a b -> q s (b, t)

-- | Modify the target of a <a>Lens</a> into your 'Monad'\'s state by a
--   user supplied function and return the result.
--   
--   When applied to a <a>Traversal</a>, it this will return a monoidal
--   summary of all of the intermediate results.
--   
--   When you do not need the result of the operation, (<a>%=</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;%=</a>) :: <a>MonadState</a> s m             =&gt; <a>Lens'</a> s a      -&gt; (a -&gt; a) -&gt; m a
--   (<a>&lt;%=</a>) :: <a>MonadState</a> s m             =&gt; <a>Iso'</a> s a       -&gt; (a -&gt; a) -&gt; m a
--   (<a>&lt;%=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> a) =&gt; <a>Traversal'</a> s a -&gt; (a -&gt; a) -&gt; m a
--   </pre>
(<%=) :: (Profunctor p, MonadState s m) => Overloading p (->) ((,) b) s s a b -> p a b -> m b

-- | Modify the target of a <a>Lens</a>, but return the old value.
--   
--   When you do not need the result of the addition, (<a>%~</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;&lt;%~</a>) ::             <a>Lens</a> s t a b      -&gt; (a -&gt; b) -&gt; s -&gt; (a, t)
--   (<a>&lt;&lt;%~</a>) ::             <a>Iso</a> s t a b       -&gt; (a -&gt; b) -&gt; s -&gt; (a, t)
--   (<a>&lt;&lt;%~</a>) :: <a>Monoid</a> a =&gt; <a>Traversal</a> s t a b -&gt; (a -&gt; b) -&gt; s -&gt; (a, t)
--   </pre>
(<<%~) :: Strong p => Overloading p q ((,) a) s t a b -> p a b -> q s (a, t)

-- | Modify the target of a <a>Lens</a> into your 'Monad'\'s state by a
--   user supplied function and return the <i>old</i> value that was
--   replaced.
--   
--   When applied to a <a>Traversal</a>, it this will return a monoidal
--   summary of all of the old values present.
--   
--   When you do not need the result of the operation, (<a>%=</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;&lt;%=</a>) :: <a>MonadState</a> s m             =&gt; <a>Lens'</a> s a      -&gt; (a -&gt; a) -&gt; m a
--   (<a>&lt;&lt;%=</a>) :: <a>MonadState</a> s m             =&gt; <a>Iso'</a> s a       -&gt; (a -&gt; a) -&gt; m a
--   (<a>&lt;&lt;%=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> b) =&gt; <a>Traversal'</a> s a -&gt; (a -&gt; a) -&gt; m a
--   </pre>
--   
--   <pre>
--   (<a>&lt;&lt;%=</a>) :: <a>MonadState</a> s m =&gt; <a>LensLike</a> ((,)a) s s a b -&gt; (a -&gt; b) -&gt; m a
--   </pre>
(<<%=) :: (Strong p, MonadState s m) => Overloading p (->) ((,) a) s s a b -> p a b -> m a

-- | A version of (<a>%~</a>) that works on <a>ALens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world") &amp; _2 #%~ length
--   ("hello",5)
--   </pre>
(#%~) :: ALens s t a b -> (a -> b) -> s -> t

-- | A version of (<a>%=</a>) that works on <a>ALens</a>.
(#%=) :: MonadState s m => ALens s s a b -> (a -> b) -> m ()

-- | A version of (<a>&lt;%~</a>) that works on <a>ALens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world") &amp; _2 &lt;#%~ length
--   (5,("hello",5))
--   </pre>
(<#%~) :: ALens s t a b -> (a -> b) -> s -> (b, t)

-- | A version of (<a>&lt;%=</a>) that works on <a>ALens</a>.
(<#%=) :: MonadState s m => ALens s s a b -> (a -> b) -> m b

-- | Adjust every target of an <a>IndexedSetter</a>, <a>IndexedLens</a> or
--   <a>IndexedTraversal</a> with access to the index.
--   
--   <pre>
--   (<a>%@~</a>) ≡ <a>imapOf</a>
--   </pre>
--   
--   When you do not need access to the index then (<a>%@~</a>) is more
--   liberal in what it can accept.
--   
--   <pre>
--   l <a>%~</a> f ≡ l <a>%@~</a> <a>const</a> f
--   </pre>
--   
--   <pre>
--   (<a>%@~</a>) :: <a>IndexedSetter</a> i s t a b    -&gt; (i -&gt; a -&gt; b) -&gt; s -&gt; t
--   (<a>%@~</a>) :: <a>IndexedLens</a> i s t a b      -&gt; (i -&gt; a -&gt; b) -&gt; s -&gt; t
--   (<a>%@~</a>) :: <a>IndexedTraversal</a> i s t a b -&gt; (i -&gt; a -&gt; b) -&gt; s -&gt; t
--   </pre>
(%@~) :: AnIndexedSetter i s t a b -> (i -> a -> b) -> s -> t

-- | Adjust every target in the current state of an <a>IndexedSetter</a>,
--   <a>IndexedLens</a> or <a>IndexedTraversal</a> with access to the
--   index.
--   
--   When you do not need access to the index then (<a>%=</a>) is more
--   liberal in what it can accept.
--   
--   <pre>
--   l <a>%=</a> f ≡ l <a>%@=</a> <a>const</a> f
--   </pre>
--   
--   <pre>
--   (<a>%@=</a>) :: <a>MonadState</a> s m =&gt; <a>IndexedSetter</a> i s s a b    -&gt; (i -&gt; a -&gt; b) -&gt; m ()
--   (<a>%@=</a>) :: <a>MonadState</a> s m =&gt; <a>IndexedLens</a> i s s a b      -&gt; (i -&gt; a -&gt; b) -&gt; m ()
--   (<a>%@=</a>) :: <a>MonadState</a> s m =&gt; <a>IndexedTraversal</a> i s t a b -&gt; (i -&gt; a -&gt; b) -&gt; m ()
--   </pre>
(%@=) :: MonadState s m => AnIndexedSetter i s s a b -> (i -> a -> b) -> m ()

-- | Adjust the target of an <a>IndexedLens</a> returning the intermediate
--   result, or adjust all of the targets of an <a>IndexedTraversal</a> and
--   return a monoidal summary along with the answer.
--   
--   <pre>
--   l <a>&lt;%~</a> f ≡ l <a>&lt;%@~</a> <a>const</a> f
--   </pre>
--   
--   When you do not need access to the index then (<a>&lt;%~</a>) is more
--   liberal in what it can accept.
--   
--   If you do not need the intermediate result, you can use (<a>%@~</a>)
--   or even (<a>%~</a>).
--   
--   <pre>
--   (<a>&lt;%@~</a>) ::             <a>IndexedLens</a> i s t a b      -&gt; (i -&gt; a -&gt; b) -&gt; s -&gt; (b, t)
--   (<a>&lt;%@~</a>) :: <a>Monoid</a> b =&gt; <a>IndexedTraversal</a> i s t a b -&gt; (i -&gt; a -&gt; b) -&gt; s -&gt; (b, t)
--   </pre>
(<%@~) :: Overloading (Indexed i) q ((,) b) s t a b -> (i -> a -> b) -> q s (b, t)

-- | Adjust the target of an <a>IndexedLens</a> returning the intermediate
--   result, or adjust all of the targets of an <a>IndexedTraversal</a>
--   within the current state, and return a monoidal summary of the
--   intermediate results.
--   
--   <pre>
--   (<a>&lt;%@=</a>) :: <a>MonadState</a> s m                 =&gt; <a>IndexedLens</a> i s s a b      -&gt; (i -&gt; a -&gt; b) -&gt; m b
--   (<a>&lt;%@=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> b) =&gt; <a>IndexedTraversal</a> i s s a b -&gt; (i -&gt; a -&gt; b) -&gt; m b
--   </pre>
(<%@=) :: MonadState s m => IndexedLensLike i ((,) b) s s a b -> (i -> a -> b) -> m b

-- | Adjust the target of an <a>IndexedLens</a> returning the old value, or
--   adjust all of the targets of an <a>IndexedTraversal</a> and return a
--   monoidal summary of the old values along with the answer.
--   
--   <pre>
--   (<a>&lt;&lt;%@~</a>) ::             <a>IndexedLens</a> i s t a b      -&gt; (i -&gt; a -&gt; b) -&gt; s -&gt; (a, t)
--   (<a>&lt;&lt;%@~</a>) :: <a>Monoid</a> a =&gt; <a>IndexedTraversal</a> i s t a b -&gt; (i -&gt; a -&gt; b) -&gt; s -&gt; (a, t)
--   </pre>
(<<%@~) :: Overloading (Indexed i) q ((,) a) s t a b -> (i -> a -> b) -> q s (a, t)

-- | Adjust the target of an <a>IndexedLens</a> returning the old value, or
--   adjust all of the targets of an <a>IndexedTraversal</a> within the
--   current state, and return a monoidal summary of the old values.
--   
--   <pre>
--   (<a>&lt;&lt;%@=</a>) :: <a>MonadState</a> s m                 =&gt; <a>IndexedLens</a> i s s a b      -&gt; (i -&gt; a -&gt; b) -&gt; m a
--   (<a>&lt;&lt;%@=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> b) =&gt; <a>IndexedTraversal</a> i s s a b -&gt; (i -&gt; a -&gt; b) -&gt; m a
--   </pre>
(<<%@=) :: MonadState s m => IndexedLensLike i ((,) a) s s a b -> (i -> a -> b) -> m a

-- | (<a>%%~</a>) can be used in one of two scenarios:
--   
--   When applied to a <a>Lens</a>, it can edit the target of the
--   <a>Lens</a> in a structure, extracting a functorial result.
--   
--   When applied to a <a>Traversal</a>, it can edit the targets of the
--   traversals, extracting an applicative summary of its actions.
--   
--   For all that the definition of this combinator is just:
--   
--   <pre>
--   (<a>%%~</a>) ≡ <a>id</a>
--   </pre>
--   
--   It may be beneficial to think about it as if it had these even more
--   restricted types, however:
--   
--   <pre>
--   (<a>%%~</a>) :: <a>Functor</a> f =&gt;     <a>Iso</a> s t a b       -&gt; (a -&gt; f b) -&gt; s -&gt; f t
--   (<a>%%~</a>) :: <a>Functor</a> f =&gt;     <a>Lens</a> s t a b      -&gt; (a -&gt; f b) -&gt; s -&gt; f t
--   (<a>%%~</a>) :: <a>Applicative</a> f =&gt; <a>Traversal</a> s t a b -&gt; (a -&gt; f b) -&gt; s -&gt; f t
--   </pre>
--   
--   When applied to a <a>Traversal</a>, it can edit the targets of the
--   traversals, extracting a supplemental monoidal summary of its actions,
--   by choosing <tt>f = ((,) m)</tt>
--   
--   <pre>
--   (<a>%%~</a>) ::             <a>Iso</a> s t a b       -&gt; (a -&gt; (r, b)) -&gt; s -&gt; (r, t)
--   (<a>%%~</a>) ::             <a>Lens</a> s t a b      -&gt; (a -&gt; (r, b)) -&gt; s -&gt; (r, t)
--   (<a>%%~</a>) :: <a>Monoid</a> m =&gt; <a>Traversal</a> s t a b -&gt; (a -&gt; (m, b)) -&gt; s -&gt; (m, t)
--   </pre>
(%%~) :: Overloading p q f s t a b -> p a (f b) -> q s (f t)

-- | Modify the target of a <a>Lens</a> in the current state returning some
--   extra information of type <tt>r</tt> or modify all targets of a
--   <a>Traversal</a> in the current state, extracting extra information of
--   type <tt>r</tt> and return a monoidal summary of the changes.
--   
--   <pre>
--   &gt;&gt;&gt; runState (_1 %%= \x -&gt; (f x, g x)) (a,b)
--   (f a,(g a,b))
--   </pre>
--   
--   <pre>
--   (<a>%%=</a>) ≡ (<a>state</a> <a>.</a>)
--   </pre>
--   
--   It may be useful to think of (<a>%%=</a>), instead, as having either
--   of the following more restricted type signatures:
--   
--   <pre>
--   (<a>%%=</a>) :: <a>MonadState</a> s m             =&gt; <a>Iso</a> s s a b       -&gt; (a -&gt; (r, b)) -&gt; m r
--   (<a>%%=</a>) :: <a>MonadState</a> s m             =&gt; <a>Lens</a> s s a b      -&gt; (a -&gt; (r, b)) -&gt; m r
--   (<a>%%=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> r) =&gt; <a>Traversal</a> s s a b -&gt; (a -&gt; (r, b)) -&gt; m r
--   </pre>
(%%=) :: MonadState s m => Overloading p (->) ((,) r) s s a b -> p a (r, b) -> m r

-- | A version of (<a>%%~</a>) that works on <a>ALens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world") &amp; _2 #%%~ \x -&gt; (length x, x ++ "!")
--   (5,("hello","world!"))
--   </pre>
(#%%~) :: Functor f => ALens s t a b -> (a -> f b) -> s -> f t

-- | A version of (<a>%%=</a>) that works on <a>ALens</a>.
(#%%=) :: MonadState s m => ALens s s a b -> (a -> (r, b)) -> m r

-- | Adjust the target of an <a>IndexedLens</a> returning a supplementary
--   result, or adjust all of the targets of an <a>IndexedTraversal</a> and
--   return a monoidal summary of the supplementary results and the answer.
--   
--   <pre>
--   (<a>%%@~</a>) ≡ <a>withIndex</a>
--   </pre>
--   
--   <pre>
--   (<a>%%@~</a>) :: <a>Functor</a> f =&gt; <a>IndexedLens</a> i s t a b      -&gt; (i -&gt; a -&gt; f b) -&gt; s -&gt; f t
--   (<a>%%@~</a>) :: <a>Applicative</a> f =&gt; <a>IndexedTraversal</a> i s t a b -&gt; (i -&gt; a -&gt; f b) -&gt; s -&gt; f t
--   </pre>
--   
--   In particular, it is often useful to think of this function as having
--   one of these even more restricted type signatures:
--   
--   <pre>
--   (<a>%%@~</a>) ::             <a>IndexedLens</a> i s t a b      -&gt; (i -&gt; a -&gt; (r, b)) -&gt; s -&gt; (r, t)
--   (<a>%%@~</a>) :: <a>Monoid</a> r =&gt; <a>IndexedTraversal</a> i s t a b -&gt; (i -&gt; a -&gt; (r, b)) -&gt; s -&gt; (r, t)
--   </pre>
(%%@~) :: IndexedLensLike i f s t a b -> (i -> a -> f b) -> s -> f t

-- | Adjust the target of an <a>IndexedLens</a> returning a supplementary
--   result, or adjust all of the targets of an <a>IndexedTraversal</a>
--   within the current state, and return a monoidal summary of the
--   supplementary results.
--   
--   <pre>
--   l <a>%%@=</a> f ≡ <a>state</a> (l <a>%%@~</a> f)
--   </pre>
--   
--   <pre>
--   (<a>%%@=</a>) :: <a>MonadState</a> s m                 =&gt; <a>IndexedLens</a> i s s a b      -&gt; (i -&gt; a -&gt; (r, b)) -&gt; s -&gt; m r
--   (<a>%%@=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> r) =&gt; <a>IndexedTraversal</a> i s s a b -&gt; (i -&gt; a -&gt; (r, b)) -&gt; s -&gt; m r
--   </pre>
(%%@=) :: MonadState s m => IndexedLensLike i ((,) r) s s a b -> (i -> a -> (r, b)) -> m r

-- | Increment the target(s) of a numerically valued <a>Lens</a>,
--   <a>Setter</a> or <a>Traversal</a>.
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; _1 +~ c
--   (a + c,b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; both +~ c
--   (a + c,b + c)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (1,2) &amp; _2 +~ 1
--   (1,3)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [(a,b),(c,d)] &amp; traverse.both +~ e
--   [(a + e,b + e),(c + e,d + e)]
--   </pre>
--   
--   <pre>
--   (<a>+~</a>) :: <a>Num</a> a =&gt; <a>Setter'</a> s a    -&gt; a -&gt; s -&gt; s
--   (<a>+~</a>) :: <a>Num</a> a =&gt; <a>Iso'</a> s a       -&gt; a -&gt; s -&gt; s
--   (<a>+~</a>) :: <a>Num</a> a =&gt; <a>Lens'</a> s a      -&gt; a -&gt; s -&gt; s
--   (<a>+~</a>) :: <a>Num</a> a =&gt; <a>Traversal'</a> s a -&gt; a -&gt; s -&gt; s
--   </pre>
(+~) :: Num a => ASetter s t a a -> a -> s -> t

-- | Modify the target(s) of a <a>Lens'</a>, <a>Iso</a>, <a>Setter</a> or
--   <a>Traversal</a> by adding a value.
--   
--   Example:
--   
--   <pre>
--   <tt>fresh</tt> :: <a>MonadState</a> <a>Int</a> m =&gt; m <a>Int</a>
--   <tt>fresh</tt> = do
--     <a>id</a> <a>+=</a> 1
--     <a>use</a> <a>id</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 += c; _2 += d) (a,b)
--   (a + c,b + d)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1.at 1.non 0 += 10) (Map.fromList [(2,100)],"hello")
--   (fromList [(1,10),(2,100)],"hello")
--   </pre>
--   
--   <pre>
--   (<a>+=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Setter'</a> s a    -&gt; a -&gt; m ()
--   (<a>+=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Iso'</a> s a       -&gt; a -&gt; m ()
--   (<a>+=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Lens'</a> s a      -&gt; a -&gt; m ()
--   (<a>+=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Traversal'</a> s a -&gt; a -&gt; m ()
--   </pre>
(+=) :: (MonadState s m, Num a) => ASetter' s a -> a -> m ()

-- | Increment the target of a numerically valued <a>Lens</a> and return
--   the result.
--   
--   When you do not need the result of the addition, (<a>+~</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;+~</a>) :: <a>Num</a> a =&gt; <a>Lens'</a> s a -&gt; a -&gt; s -&gt; (a, s)
--   (<a>&lt;+~</a>) :: <a>Num</a> a =&gt; <a>Iso'</a> s a  -&gt; a -&gt; s -&gt; (a, s)
--   </pre>
(<+~) :: Num a => Overloading (->) q ((,) a) s t a a -> a -> q s (a, t)

-- | Add to the target of a numerically valued <a>Lens</a> into your
--   'Monad'\'s state and return the result.
--   
--   When you do not need the result of the addition, (<a>+=</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;+=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Lens'</a> s a -&gt; a -&gt; m a
--   (<a>&lt;+=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Iso'</a> s a -&gt; a -&gt; m a
--   </pre>
(<+=) :: (MonadState s m, Num a) => LensLike' ((,) a) s a -> a -> m a

-- | Decrement the target(s) of a numerically valued <a>Lens</a>,
--   <a>Iso</a>, <a>Setter</a> or <a>Traversal</a>.
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; _1 -~ c
--   (a - c,b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; both -~ c
--   (a - c,b - c)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; _1 -~ 2 $ (1,2)
--   (-1,2)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; mapped.mapped -~ 1 $ [[4,5],[6,7]]
--   [[3,4],[5,6]]
--   </pre>
--   
--   <pre>
--   (<a>-~</a>) :: <a>Num</a> a =&gt; <a>Setter'</a> s a    -&gt; a -&gt; s -&gt; s
--   (<a>-~</a>) :: <a>Num</a> a =&gt; <a>Iso'</a> s a       -&gt; a -&gt; s -&gt; s
--   (<a>-~</a>) :: <a>Num</a> a =&gt; <a>Lens'</a> s a      -&gt; a -&gt; s -&gt; s
--   (<a>-~</a>) :: <a>Num</a> a =&gt; <a>Traversal'</a> s a -&gt; a -&gt; s -&gt; s
--   </pre>
(-~) :: Num a => ASetter s t a a -> a -> s -> t

-- | Modify the target(s) of a <a>Lens'</a>, <a>Iso</a>, <a>Setter</a> or
--   <a>Traversal</a> by subtracting a value.
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 -= c; _2 -= d) (a,b)
--   (a - c,b - d)
--   </pre>
--   
--   <pre>
--   (<a>-=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Setter'</a> s a    -&gt; a -&gt; m ()
--   (<a>-=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Iso'</a> s a       -&gt; a -&gt; m ()
--   (<a>-=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Lens'</a> s a      -&gt; a -&gt; m ()
--   (<a>-=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Traversal'</a> s a -&gt; a -&gt; m ()
--   </pre>
(-=) :: (MonadState s m, Num a) => ASetter' s a -> a -> m ()

-- | Decrement the target of a numerically valued <a>Lens</a> and return
--   the result.
--   
--   When you do not need the result of the subtraction, (<a>-~</a>) is
--   more flexible.
--   
--   <pre>
--   (<a>&lt;-~</a>) :: <a>Num</a> a =&gt; <a>Lens'</a> s a -&gt; a -&gt; s -&gt; (a, s)
--   (<a>&lt;-~</a>) :: <a>Num</a> a =&gt; <a>Iso'</a> s a  -&gt; a -&gt; s -&gt; (a, s)
--   </pre>
(<-~) :: Num a => Overloading (->) q ((,) a) s t a a -> a -> q s (a, t)

-- | Subtract from the target of a numerically valued <a>Lens</a> into your
--   'Monad'\'s state and return the result.
--   
--   When you do not need the result of the subtraction, (<a>-=</a>) is
--   more flexible.
--   
--   <pre>
--   (<a>&lt;-=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Lens'</a> s a -&gt; a -&gt; m a
--   (<a>&lt;-=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Iso'</a> s a -&gt; a -&gt; m a
--   </pre>
(<-=) :: (MonadState s m, Num a) => LensLike' ((,) a) s a -> a -> m a

-- | Multiply the target(s) of a numerically valued <a>Lens</a>,
--   <a>Iso</a>, <a>Setter</a> or <a>Traversal</a>.
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; _1 *~ c
--   (a * c,b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; both *~ c
--   (a * c,b * c)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (1,2) &amp; _2 *~ 4
--   (1,8)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Just 24 &amp; mapped *~ 2
--   Just 48
--   </pre>
--   
--   <pre>
--   (<a>*~</a>) :: <a>Num</a> a =&gt; <a>Setter'</a> s a    -&gt; a -&gt; s -&gt; s
--   (<a>*~</a>) :: <a>Num</a> a =&gt; <a>Iso'</a> s a       -&gt; a -&gt; s -&gt; s
--   (<a>*~</a>) :: <a>Num</a> a =&gt; <a>Lens'</a> s a      -&gt; a -&gt; s -&gt; s
--   (<a>*~</a>) :: <a>Num</a> a =&gt; <a>Traversal'</a> s a -&gt; a -&gt; s -&gt; s
--   </pre>
(*~) :: Num a => ASetter s t a a -> a -> s -> t

-- | Modify the target(s) of a <a>Lens'</a>, <a>Iso</a>, <a>Setter</a> or
--   <a>Traversal</a> by multiplying by value.
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 *= c; _2 *= d) (a,b)
--   (a * c,b * d)
--   </pre>
--   
--   <pre>
--   (<a>*=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Setter'</a> s a    -&gt; a -&gt; m ()
--   (<a>*=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Iso'</a> s a       -&gt; a -&gt; m ()
--   (<a>*=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Lens'</a> s a      -&gt; a -&gt; m ()
--   (<a>*=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Traversal'</a> s a -&gt; a -&gt; m ()
--   </pre>
(*=) :: (MonadState s m, Num a) => ASetter' s a -> a -> m ()

-- | Multiply the target of a numerically valued <a>Lens</a> and return the
--   result.
--   
--   When you do not need the result of the multiplication, (<a>*~</a>) is
--   more flexible.
--   
--   <pre>
--   (<a>&lt;*~</a>) :: <a>Num</a> a =&gt; <a>Lens'</a> s a -&gt; a -&gt; s -&gt; (a, s)
--   (<a>&lt;*~</a>) :: <a>Num</a> a =&gt; <a>Iso'</a>  s a -&gt; a -&gt; s -&gt; (a, s)
--   </pre>
(<*~) :: Num a => Overloading (->) q ((,) a) s t a a -> a -> q s (a, t)

-- | Multiply the target of a numerically valued <a>Lens</a> into your
--   'Monad'\'s state and return the result.
--   
--   When you do not need the result of the multiplication, (<a>*=</a>) is
--   more flexible.
--   
--   <pre>
--   (<a>&lt;*=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Lens'</a> s a -&gt; a -&gt; m a
--   (<a>&lt;*=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a) =&gt; <a>Iso'</a> s a -&gt; a -&gt; m a
--   </pre>
(<*=) :: (MonadState s m, Num a) => LensLike' ((,) a) s a -> a -> m a

-- | Divide the target(s) of a numerically valued <a>Lens</a>, <a>Iso</a>,
--   <a>Setter</a> or <a>Traversal</a>.
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; _1 //~ c
--   (a / c,b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; both //~ c
--   (a / c,b / c)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ("Hawaii",10) &amp; _2 //~ 2
--   ("Hawaii",5.0)
--   </pre>
--   
--   <pre>
--   (<a>//~</a>) :: <a>Fractional</a> a =&gt; <a>Setter'</a> s a    -&gt; a -&gt; s -&gt; s
--   (<a>//~</a>) :: <a>Fractional</a> a =&gt; <a>Iso'</a> s a       -&gt; a -&gt; s -&gt; s
--   (<a>//~</a>) :: <a>Fractional</a> a =&gt; <a>Lens'</a> s a      -&gt; a -&gt; s -&gt; s
--   (<a>//~</a>) :: <a>Fractional</a> a =&gt; <a>Traversal'</a> s a -&gt; a -&gt; s -&gt; s
--   </pre>
(//~) :: Fractional a => ASetter s t a a -> a -> s -> t

-- | Modify the target(s) of a <a>Lens'</a>, <a>Iso</a>, <a>Setter</a> or
--   <a>Traversal</a> by dividing by a value.
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 //= c; _2 //= d) (a,b)
--   (a / c,b / d)
--   </pre>
--   
--   <pre>
--   (<a>//=</a>) :: (<a>MonadState</a> s m, <a>Fractional</a> a) =&gt; <a>Setter'</a> s a    -&gt; a -&gt; m ()
--   (<a>//=</a>) :: (<a>MonadState</a> s m, <a>Fractional</a> a) =&gt; <a>Iso'</a> s a       -&gt; a -&gt; m ()
--   (<a>//=</a>) :: (<a>MonadState</a> s m, <a>Fractional</a> a) =&gt; <a>Lens'</a> s a      -&gt; a -&gt; m ()
--   (<a>//=</a>) :: (<a>MonadState</a> s m, <a>Fractional</a> a) =&gt; <a>Traversal'</a> s a -&gt; a -&gt; m ()
--   </pre>
(//=) :: (MonadState s m, Fractional a) => ASetter' s a -> a -> m ()

-- | Divide the target of a fractionally valued <a>Lens</a> and return the
--   result.
--   
--   When you do not need the result of the division, (<a>//~</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;//~</a>) :: <a>Fractional</a> a =&gt; <a>Lens'</a> s a -&gt; a -&gt; s -&gt; (a, s)
--   (<a>&lt;//~</a>) :: <a>Fractional</a> a =&gt; <a>Iso'</a>  s a -&gt; a -&gt; s -&gt; (a, s)
--   </pre>
(<//~) :: Fractional a => Overloading (->) q ((,) a) s t a a -> a -> q s (a, t)

-- | Divide the target of a fractionally valued <a>Lens</a> into your
--   'Monad'\'s state and return the result.
--   
--   When you do not need the result of the division, (<a>//=</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;//=</a>) :: (<a>MonadState</a> s m, <a>Fractional</a> a) =&gt; <a>Lens'</a> s a -&gt; a -&gt; m a
--   (<a>&lt;//=</a>) :: (<a>MonadState</a> s m, <a>Fractional</a> a) =&gt; <a>Iso'</a> s a -&gt; a -&gt; m a
--   </pre>
(<//=) :: (MonadState s m, Fractional a) => LensLike' ((,) a) s a -> a -> m a

-- | Raise the target(s) of a numerically valued <a>Lens</a>, <a>Setter</a>
--   or <a>Traversal</a> to a non-negative integral power.
--   
--   <pre>
--   &gt;&gt;&gt; (1,3) &amp; _2 ^~ 2
--   (1,9)
--   </pre>
--   
--   <pre>
--   (<a>^~</a>) :: (<a>Num</a> a, <a>Integral</a> e) =&gt; <a>Setter'</a> s a    -&gt; e -&gt; s -&gt; s
--   (<a>^~</a>) :: (<a>Num</a> a, <a>Integral</a> e) =&gt; <a>Iso'</a> s a       -&gt; e -&gt; s -&gt; s
--   (<a>^~</a>) :: (<a>Num</a> a, <a>Integral</a> e) =&gt; <a>Lens'</a> s a      -&gt; e -&gt; s -&gt; s
--   (<a>^~</a>) :: (<a>Num</a> a, <a>Integral</a> e) =&gt; <a>Traversal'</a> s a -&gt; e -&gt; s -&gt; s
--   </pre>
(^~) :: (Num a, Integral e) => ASetter s t a a -> e -> s -> t

-- | Raise the target(s) of a numerically valued <a>Lens</a>, <a>Setter</a>
--   or <a>Traversal</a> to a non-negative integral power.
--   
--   <pre>
--   (<a>^=</a>) ::  (<a>MonadState</a> s m, <a>Num</a> a, <a>Integral</a> e) =&gt; <a>Setter'</a> s a    -&gt; e -&gt; m ()
--   (<a>^=</a>) ::  (<a>MonadState</a> s m, <a>Num</a> a, <a>Integral</a> e) =&gt; <a>Iso'</a> s a       -&gt; e -&gt; m ()
--   (<a>^=</a>) ::  (<a>MonadState</a> s m, <a>Num</a> a, <a>Integral</a> e) =&gt; <a>Lens'</a> s a      -&gt; e -&gt; m ()
--   (<a>^=</a>) ::  (<a>MonadState</a> s m, <a>Num</a> a, <a>Integral</a> e) =&gt; <a>Traversal'</a> s a -&gt; e -&gt; m ()
--   </pre>
(^=) :: (MonadState s m, Num a, Integral e) => ASetter' s a -> e -> m ()

-- | Raise the target of a numerically valued <a>Lens</a> to a non-negative
--   <a>Integral</a> power and return the result.
--   
--   When you do not need the result of the division, (<a>^~</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;^~</a>) :: (<a>Num</a> a, <a>Integral</a> e) =&gt; <a>Lens'</a> s a -&gt; e -&gt; s -&gt; (a, s)
--   (<a>&lt;^~</a>) :: (<a>Num</a> a, <a>Integral</a> e) =&gt; <a>Iso'</a> s a -&gt; e -&gt; s -&gt; (a, s)
--   </pre>
(<^~) :: (Num a, Integral e) => Overloading (->) q ((,) a) s t a a -> e -> q s (a, t)

-- | Raise the target of a numerically valued <a>Lens</a> into your
--   'Monad'\'s state to a non-negative <a>Integral</a> power and return
--   the result.
--   
--   When you do not need the result of the operation, (<a>**=</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;^=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a, <a>Integral</a> e) =&gt; <a>Lens'</a> s a -&gt; e -&gt; m a
--   (<a>&lt;^=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a, <a>Integral</a> e) =&gt; <a>Iso'</a> s a -&gt; e -&gt; m a
--   </pre>
(<^=) :: (MonadState s m, Num a, Integral e) => LensLike' ((,) a) s a -> e -> m a

-- | Raise the target(s) of a fractionally valued <a>Lens</a>,
--   <a>Setter</a> or <a>Traversal</a> to an integral power.
--   
--   <pre>
--   &gt;&gt;&gt; (1,2) &amp; _2 ^^~ (-1)
--   (1,0.5)
--   </pre>
--   
--   <pre>
--   (<a>^^~</a>) :: (<a>Fractional</a> a, <a>Integral</a> e) =&gt; <a>Setter'</a> s a    -&gt; e -&gt; s -&gt; s
--   (<a>^^~</a>) :: (<a>Fractional</a> a, <a>Integral</a> e) =&gt; <a>Iso'</a> s a       -&gt; e -&gt; s -&gt; s
--   (<a>^^~</a>) :: (<a>Fractional</a> a, <a>Integral</a> e) =&gt; <a>Lens'</a> s a      -&gt; e -&gt; s -&gt; s
--   (<a>^^~</a>) :: (<a>Fractional</a> a, <a>Integral</a> e) =&gt; <a>Traversal'</a> s a -&gt; e -&gt; s -&gt; s
--   </pre>
(^^~) :: (Fractional a, Integral e) => ASetter s t a a -> e -> s -> t

-- | Raise the target(s) of a numerically valued <a>Lens</a>, <a>Setter</a>
--   or <a>Traversal</a> to an integral power.
--   
--   <pre>
--   (<a>^^=</a>) ::  (<a>MonadState</a> s m, <a>Fractional</a> a, <a>Integral</a> e) =&gt; <a>Setter'</a> s a    -&gt; e -&gt; m ()
--   (<a>^^=</a>) ::  (<a>MonadState</a> s m, <a>Fractional</a> a, <a>Integral</a> e) =&gt; <a>Iso'</a> s a       -&gt; e -&gt; m ()
--   (<a>^^=</a>) ::  (<a>MonadState</a> s m, <a>Fractional</a> a, <a>Integral</a> e) =&gt; <a>Lens'</a> s a      -&gt; e -&gt; m ()
--   (<a>^^=</a>) ::  (<a>MonadState</a> s m, <a>Fractional</a> a, <a>Integral</a> e) =&gt; <a>Traversal'</a> s a -&gt; e -&gt; m ()
--   </pre>
(^^=) :: (MonadState s m, Fractional a, Integral e) => ASetter' s a -> e -> m ()

-- | Raise the target of a fractionally valued <a>Lens</a> to an
--   <a>Integral</a> power and return the result.
--   
--   When you do not need the result of the division, (<a>^^~</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;^^~</a>) :: (<a>Fractional</a> a, <a>Integral</a> e) =&gt; <a>Lens'</a> s a -&gt; e -&gt; s -&gt; (a, s)
--   (<a>&lt;^^~</a>) :: (<a>Fractional</a> a, <a>Integral</a> e) =&gt; <a>Iso'</a> s a -&gt; e -&gt; s -&gt; (a, s)
--   </pre>
(<^^~) :: (Fractional a, Integral e) => Overloading (->) q ((,) a) s t a a -> e -> q s (a, t)

-- | Raise the target of a fractionally valued <a>Lens</a> into your
--   'Monad'\'s state to an <a>Integral</a> power and return the result.
--   
--   When you do not need the result of the operation, (<a>^^=</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;^^=</a>) :: (<a>MonadState</a> s m, <a>Fractional</a> b, <a>Integral</a> e) =&gt; <a>Lens'</a> s a -&gt; e -&gt; m a
--   (<a>&lt;^^=</a>) :: (<a>MonadState</a> s m, <a>Fractional</a> b, <a>Integral</a> e) =&gt; <a>Iso'</a> s a  -&gt; e -&gt; m a
--   </pre>
(<^^=) :: (MonadState s m, Fractional a, Integral e) => LensLike' ((,) a) s a -> e -> m a

-- | Raise the target(s) of a floating-point valued <a>Lens</a>,
--   <a>Setter</a> or <a>Traversal</a> to an arbitrary power.
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; _1 **~ c
--   (a**c,b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; both **~ c
--   (a**c,b**c)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; _2 **~ 10 $ (3,2)
--   (3,1024.0)
--   </pre>
--   
--   <pre>
--   (<a>**~</a>) :: <a>Floating</a> a =&gt; <a>Setter'</a> s a    -&gt; a -&gt; s -&gt; s
--   (<a>**~</a>) :: <a>Floating</a> a =&gt; <a>Iso'</a> s a       -&gt; a -&gt; s -&gt; s
--   (<a>**~</a>) :: <a>Floating</a> a =&gt; <a>Lens'</a> s a      -&gt; a -&gt; s -&gt; s
--   (<a>**~</a>) :: <a>Floating</a> a =&gt; <a>Traversal'</a> s a -&gt; a -&gt; s -&gt; s
--   </pre>
(**~) :: Floating a => ASetter s t a a -> a -> s -> t

-- | Raise the target(s) of a numerically valued <a>Lens</a>, <a>Setter</a>
--   or <a>Traversal</a> to an arbitrary power
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 **= c; _2 **= d) (a,b)
--   (a**c,b**d)
--   </pre>
--   
--   <pre>
--   (<a>**=</a>) ::  (<a>MonadState</a> s m, <a>Floating</a> a) =&gt; <a>Setter'</a> s a    -&gt; a -&gt; m ()
--   (<a>**=</a>) ::  (<a>MonadState</a> s m, <a>Floating</a> a) =&gt; <a>Iso'</a> s a       -&gt; a -&gt; m ()
--   (<a>**=</a>) ::  (<a>MonadState</a> s m, <a>Floating</a> a) =&gt; <a>Lens'</a> s a      -&gt; a -&gt; m ()
--   (<a>**=</a>) ::  (<a>MonadState</a> s m, <a>Floating</a> a) =&gt; <a>Traversal'</a> s a -&gt; a -&gt; m ()
--   </pre>
(**=) :: (MonadState s m, Floating a) => ASetter' s a -> a -> m ()

-- | Raise the target of a floating-point valued <a>Lens</a> to an
--   arbitrary power and return the result.
--   
--   When you do not need the result of the division, (<a>**~</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;**~</a>) :: <a>Floating</a> a =&gt; <a>Lens'</a> s a -&gt; a -&gt; s -&gt; (a, s)
--   (<a>&lt;**~</a>) :: <a>Floating</a> a =&gt; <a>Iso'</a> s a  -&gt; a -&gt; s -&gt; (a, s)
--   </pre>
(<**~) :: Floating a => Overloading (->) q ((,) a) s t a a -> a -> q s (a, t)

-- | Raise the target of a floating-point valued <a>Lens</a> into your
--   'Monad'\'s state to an arbitrary power and return the result.
--   
--   When you do not need the result of the operation, (<a>**=</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;**=</a>) :: (<a>MonadState</a> s m, <a>Floating</a> a) =&gt; <a>Lens'</a> s a -&gt; a -&gt; m a
--   (<a>&lt;**=</a>) :: (<a>MonadState</a> s m, <a>Floating</a> a) =&gt; <a>Iso'</a> s a -&gt; a -&gt; m a
--   </pre>
(<**=) :: (MonadState s m, Floating a) => LensLike' ((,) a) s a -> a -> m a

-- | Logically <a>||</a> the target(s) of a <a>Bool</a>-valued <a>Lens</a>
--   or <a>Setter</a>.
--   
--   <pre>
--   &gt;&gt;&gt; both ||~ True $ (False,True)
--   (True,True)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; both ||~ False $ (False,True)
--   (False,True)
--   </pre>
--   
--   <pre>
--   (<a>||~</a>) :: <a>Setter'</a> s <a>Bool</a>    -&gt; <a>Bool</a> -&gt; s -&gt; s
--   (<a>||~</a>) :: <a>Iso'</a> s <a>Bool</a>       -&gt; <a>Bool</a> -&gt; s -&gt; s
--   (<a>||~</a>) :: <a>Lens'</a> s <a>Bool</a>      -&gt; <a>Bool</a> -&gt; s -&gt; s
--   (<a>||~</a>) :: <a>Traversal'</a> s <a>Bool</a> -&gt; <a>Bool</a> -&gt; s -&gt; s
--   </pre>
(||~) :: ASetter s t Bool Bool -> Bool -> s -> t

-- | Modify the target(s) of a <a>Lens'</a>, 'Iso, <a>Setter</a> or
--   <a>Traversal</a> by taking their logical <a>||</a> with a value.
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 ||= True; _2 ||= False; _3 ||= True; _4 ||= False) (True,True,False,False)
--   (True,True,True,False)
--   </pre>
--   
--   <pre>
--   (<a>||=</a>) :: <a>MonadState</a> s m =&gt; <a>Setter'</a> s <a>Bool</a>    -&gt; <a>Bool</a> -&gt; m ()
--   (<a>||=</a>) :: <a>MonadState</a> s m =&gt; <a>Iso'</a> s <a>Bool</a>       -&gt; <a>Bool</a> -&gt; m ()
--   (<a>||=</a>) :: <a>MonadState</a> s m =&gt; <a>Lens'</a> s <a>Bool</a>      -&gt; <a>Bool</a> -&gt; m ()
--   (<a>||=</a>) :: <a>MonadState</a> s m =&gt; <a>Traversal'</a> s <a>Bool</a> -&gt; <a>Bool</a> -&gt; m ()
--   </pre>
(||=) :: MonadState s m => ASetter' s Bool -> Bool -> m ()

-- | Logically <a>||</a> a Boolean valued <a>Lens</a> and return the
--   result.
--   
--   When you do not need the result of the operation, (<a>||~</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;||~</a>) :: <a>Lens'</a> s <a>Bool</a> -&gt; <a>Bool</a> -&gt; s -&gt; (<a>Bool</a>, s)
--   (<a>&lt;||~</a>) :: <a>Iso'</a> s <a>Bool</a>  -&gt; <a>Bool</a> -&gt; s -&gt; (<a>Bool</a>, s)
--   </pre>
(<||~) :: Overloading (->) q ((,) Bool) s t Bool Bool -> Bool -> q s (Bool, t)

-- | Logically <a>||</a> a Boolean valued <a>Lens</a> into your 'Monad'\'s
--   state and return the result.
--   
--   When you do not need the result of the operation, (<a>||=</a>) is more
--   flexible.
--   
--   <pre>
--   (<a>&lt;||=</a>) :: <a>MonadState</a> s m =&gt; <a>Lens'</a> s <a>Bool</a> -&gt; <a>Bool</a> -&gt; m <a>Bool</a>
--   (<a>&lt;||=</a>) :: <a>MonadState</a> s m =&gt; <a>Iso'</a> s <a>Bool</a>  -&gt; <a>Bool</a> -&gt; m <a>Bool</a>
--   </pre>
(<||=) :: MonadState s m => LensLike' ((,) Bool) s Bool -> Bool -> m Bool

-- | Logically <a>&amp;&amp;</a> the target(s) of a <a>Bool</a>-valued
--   <a>Lens</a> or <a>Setter</a>.
--   
--   <pre>
--   &gt;&gt;&gt; both &amp;&amp;~ True $ (False, True)
--   (False,True)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; both &amp;&amp;~ False $ (False, True)
--   (False,False)
--   </pre>
--   
--   <pre>
--   (<a>&amp;&amp;~</a>) :: <a>Setter'</a> s <a>Bool</a>    -&gt; <a>Bool</a> -&gt; s -&gt; s
--   (<a>&amp;&amp;~</a>) :: <a>Iso'</a> s <a>Bool</a>       -&gt; <a>Bool</a> -&gt; s -&gt; s
--   (<a>&amp;&amp;~</a>) :: <a>Lens'</a> s <a>Bool</a>      -&gt; <a>Bool</a> -&gt; s -&gt; s
--   (<a>&amp;&amp;~</a>) :: <a>Traversal'</a> s <a>Bool</a> -&gt; <a>Bool</a> -&gt; s -&gt; s
--   </pre>
(&&~) :: ASetter s t Bool Bool -> Bool -> s -> t

-- | Modify the target(s) of a <a>Lens'</a>, <a>Iso</a>, <a>Setter</a> or
--   <a>Traversal</a> by taking their logical <a>&amp;&amp;</a> with a
--   value.
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 &amp;&amp;= True; _2 &amp;&amp;= False; _3 &amp;&amp;= True; _4 &amp;&amp;= False) (True,True,False,False)
--   (True,False,False,False)
--   </pre>
--   
--   <pre>
--   (<a>&amp;&amp;=</a>) :: <a>MonadState</a> s m =&gt; <a>Setter'</a> s <a>Bool</a>    -&gt; <a>Bool</a> -&gt; m ()
--   (<a>&amp;&amp;=</a>) :: <a>MonadState</a> s m =&gt; <a>Iso'</a> s <a>Bool</a>       -&gt; <a>Bool</a> -&gt; m ()
--   (<a>&amp;&amp;=</a>) :: <a>MonadState</a> s m =&gt; <a>Lens'</a> s <a>Bool</a>      -&gt; <a>Bool</a> -&gt; m ()
--   (<a>&amp;&amp;=</a>) :: <a>MonadState</a> s m =&gt; <a>Traversal'</a> s <a>Bool</a> -&gt; <a>Bool</a> -&gt; m ()
--   </pre>
(&&=) :: MonadState s m => ASetter' s Bool -> Bool -> m ()

-- | Logically <a>&amp;&amp;</a> a Boolean valued <a>Lens</a> and return
--   the result.
--   
--   When you do not need the result of the operation, (<a>&amp;&amp;~</a>)
--   is more flexible.
--   
--   <pre>
--   (<a>&lt;&amp;&amp;~</a>) :: <a>Lens'</a> s <a>Bool</a> -&gt; <a>Bool</a> -&gt; s -&gt; (<a>Bool</a>, s)
--   (<a>&lt;&amp;&amp;~</a>) :: <a>Iso'</a> s <a>Bool</a>  -&gt; <a>Bool</a> -&gt; s -&gt; (<a>Bool</a>, s)
--   </pre>
(<&&~) :: Overloading (->) q ((,) Bool) s t Bool Bool -> Bool -> q s (Bool, t)

-- | Logically <a>&amp;&amp;</a> a Boolean valued <a>Lens</a> into your
--   'Monad'\'s state and return the result.
--   
--   When you do not need the result of the operation, (<a>&amp;&amp;=</a>)
--   is more flexible.
--   
--   <pre>
--   (<a>&lt;&amp;&amp;=</a>) :: <a>MonadState</a> s m =&gt; <a>Lens'</a> s <a>Bool</a> -&gt; <a>Bool</a> -&gt; m <a>Bool</a>
--   (<a>&lt;&amp;&amp;=</a>) :: <a>MonadState</a> s m =&gt; <a>Iso'</a> s <a>Bool</a>  -&gt; <a>Bool</a> -&gt; m <a>Bool</a>
--   </pre>
(<&&=) :: MonadState s m => LensLike' ((,) Bool) s Bool -> Bool -> m Bool

-- | Modify the target of a monoidally valued by <a>mappend</a>ing another
--   value.
--   
--   <pre>
--   &gt;&gt;&gt; (Sum a,b) &amp; _1 &lt;&gt;~ Sum c
--   (Sum {getSum = a + c},b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (Sum a,Sum b) &amp; both &lt;&gt;~ Sum c
--   (Sum {getSum = a + c},Sum {getSum = b + c})
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; both &lt;&gt;~ "!!!" $ ("hello","world")
--   ("hello!!!","world!!!")
--   </pre>
--   
--   <pre>
--   (<a>&lt;&gt;~</a>) :: <a>Monoid</a> a =&gt; <a>Setter</a> s t a a    -&gt; a -&gt; s -&gt; t
--   (<a>&lt;&gt;~</a>) :: <a>Monoid</a> a =&gt; <a>Iso</a> s t a a       -&gt; a -&gt; s -&gt; t
--   (<a>&lt;&gt;~</a>) :: <a>Monoid</a> a =&gt; <a>Lens</a> s t a a      -&gt; a -&gt; s -&gt; t
--   (<a>&lt;&gt;~</a>) :: <a>Monoid</a> a =&gt; <a>Traversal</a> s t a a -&gt; a -&gt; s -&gt; t
--   </pre>
(<>~) :: Monoid a => ASetter s t a a -> a -> s -> t

-- | Modify the target(s) of a <a>Lens'</a>, <a>Iso</a>, <a>Setter</a> or
--   <a>Traversal</a> by <a>mappend</a>ing a value.
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 &lt;&gt;= Sum c; _2 &lt;&gt;= Product d) (Sum a,Product b)
--   (Sum {getSum = a + c},Product {getProduct = b * d})
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; execState (both &lt;&gt;= "!!!") ("hello","world")
--   ("hello!!!","world!!!")
--   </pre>
--   
--   <pre>
--   (<a>&lt;&gt;=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> a) =&gt; <a>Setter'</a> s a -&gt; a -&gt; m ()
--   (<a>&lt;&gt;=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> a) =&gt; <a>Iso'</a> s a -&gt; a -&gt; m ()
--   (<a>&lt;&gt;=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> a) =&gt; <a>Lens'</a> s a -&gt; a -&gt; m ()
--   (<a>&lt;&gt;=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> a) =&gt; <a>Traversal'</a> s a -&gt; a -&gt; m ()
--   </pre>
(<>=) :: (MonadState s m, Monoid a) => ASetter' s a -> a -> m ()

-- | <a>mappend</a> a monoidal value onto the end of the target of a
--   <a>Lens</a> and return the result.
--   
--   When you do not need the result of the operation, (<a>&lt;&gt;~</a>)
--   is more flexible.
(<<>~) :: Monoid m => Overloading (->) q ((,) m) s t m m -> m -> q s (m, t)

-- | <a>mappend</a> a monoidal value onto the end of the target of a
--   <a>Lens</a> into your 'Monad'\'s state and return the result.
--   
--   When you do not need the result of the operation, (<a>&lt;&gt;=</a>)
--   is more flexible.
(<<>=) :: (MonadState s m, Monoid r) => LensLike' ((,) r) s r -> r -> m r

-- | Composition of <a>Indexed</a> functions.
--   
--   Mnemonically, the <tt>&lt;</tt> and <tt>&gt;</tt> points to the fact
--   that we want to preserve the indices.
(<.>) :: Indexable (i, j) p => (Indexed i s t -> r) -> (Indexed j a b -> s -> t) -> p a b -> r

-- | Compose an <a>Indexed</a> function with a non-indexed function.
--   
--   Mnemonically, the <tt>&lt;</tt> points to the indexing we want to
--   preserve.
(<.) :: Indexable i p => (Indexed i s t -> r) -> ((a -> b) -> s -> t) -> p a b -> r

-- | Compose a non-indexed function with an <a>Indexed</a> function.
--   
--   Mnemonically, the <tt>&gt;</tt> points to the indexing we want to
--   preserve.
--   
--   This is the same as <tt>(<a>.</a>)</tt>.
--   
--   <tt>f <a>.</a> g</tt> (and <tt>f <a>.&gt;</a> g</tt>) gives you the
--   index of <tt>g</tt> unless <tt>g</tt> is index-preserving, like a
--   <a>Prism</a>, <a>Iso</a> or <a>Equality</a>, in which case it'll pass
--   through the index of <tt>f</tt>.
(.>) :: (st -> r) -> (kab -> st) -> kab -> r

-- | Run a monadic action, and set all of the targets of a <a>Lens</a>,
--   <a>Setter</a> or <a>Traversal</a> to its result.
--   
--   <pre>
--   (<a>&lt;~</a>) :: <a>MonadState</a> s m =&gt; <a>Iso</a> s s a b       -&gt; m b -&gt; m ()
--   (<a>&lt;~</a>) :: <a>MonadState</a> s m =&gt; <a>Lens</a> s s a b      -&gt; m b -&gt; m ()
--   (<a>&lt;~</a>) :: <a>MonadState</a> s m =&gt; <a>Traversal</a> s s a b -&gt; m b -&gt; m ()
--   (<a>&lt;~</a>) :: <a>MonadState</a> s m =&gt; <a>Setter</a> s s a b    -&gt; m b -&gt; m ()
--   </pre>
--   
--   As a reasonable mnemonic, this lets you store the result of a monadic
--   action in a <a>Lens</a> rather than in a local variable.
--   
--   <pre>
--   do foo &lt;- bar
--      ...
--   </pre>
--   
--   will store the result in a variable, while
--   
--   <pre>
--   do foo <a>&lt;~</a> bar
--      ...
--   </pre>
--   
--   will store the result in a <a>Lens</a>, <a>Setter</a>, or
--   <a>Traversal</a>.
(<~) :: MonadState s m => ASetter s s a b -> m b -> m ()

-- | Run a monadic action, and set the target of <a>Lens</a> to its result.
--   
--   <pre>
--   (<a>&lt;&lt;~</a>) :: <a>MonadState</a> s m =&gt; <a>Iso</a> s s a b   -&gt; m b -&gt; m b
--   (<a>&lt;&lt;~</a>) :: <a>MonadState</a> s m =&gt; <a>Lens</a> s s a b  -&gt; m b -&gt; m b
--   </pre>
--   
--   NB: This is limited to taking an actual <a>Lens</a> than admitting a
--   <a>Traversal</a> because there are potential loss of state issues
--   otherwise.
(<<~) :: MonadState s m => ALens s s a b -> m b -> m b

-- | This type family represents a <a>Zipper</a> with the <tt>p</tt>
--   variable abstracting over the position and the index, in terms of
--   <a>:@</a>. You can visually see it in type signatures as:
--   
--   <pre>
--   h <a>:&gt;</a> (a <a>:@</a> i) = <a>Zipper</a> h i a
--   </pre>

-- | Many zippers are indexed by Int keys. This type alias is convenient
--   for reducing syntactic noise for talking about these boring indices.
type (:>>) h a = Zipper h Int a

-- | <a>cons</a> an element onto a container.
--   
--   This is an infix alias for <a>cons</a>.
(<|) :: Cons Reviewed Identity s s a a => a -> s -> s

-- | <a>snoc</a> an element onto the end of a container.
--   
--   This is an infix alias for <a>snoc</a>.
(|>) :: Snoc Reviewed Identity s s a a => s -> a -> s


-- | Smart and naïve generic traversals given <a>Data</a> instances.
--   
--   <a>template</a>, <a>uniplate</a>, and <a>biplate</a> each build up
--   information about what types can be contained within another type to
--   speed up <a>Traversal</a>.
module Data.Data.Lens

-- | Find every occurrence of a given type <tt>a</tt> recursively that
--   doesn't require passing through something of type <tt>a</tt> using
--   <a>Data</a>, while avoiding traversal of areas that cannot contain a
--   value of type <tt>a</tt>.
--   
--   This is <a>uniplate</a> with a more liberal signature.
template :: (Data s, Typeable a) => Traversal' s a

-- | Naïve <a>Traversal</a> using <a>Data</a>. This does not attempt to
--   optimize the traversal.
--   
--   This is primarily useful when the children are immediately obvious,
--   and for benchmarking.
tinplate :: (Data s, Typeable a) => Traversal' s a

-- | Find descendants of type <tt>a</tt> non-transitively, while avoiding
--   computation of areas that cannot contain values of type <tt>a</tt>
--   using <a>Data</a>.
--   
--   <a>uniplate</a> is a useful default definition for <a>plate</a>
uniplate :: Data a => Traversal' a a

-- | <a>biplate</a> performs like <a>template</a>, except when <tt>s ~
--   a</tt>, it returns itself and nothing else.
biplate :: (Data s, Typeable a) => Traversal' s a

-- | This automatically constructs a <a>Traversal'</a> from an function.
--   
--   <pre>
--   &gt;&gt;&gt; (2,4) &amp; upon fst *~ 5
--   (10,4)
--   </pre>
--   
--   There are however, caveats on how this function can be used!
--   
--   First, the user supplied function must access only one field of the
--   specified type. That is to say the target must be a single element
--   that would be visited by <tt><tt>holesOnOf</tt> <a>template</a>
--   <a>uniplate</a></tt>
--   
--   Note: this even permits a number of functions to be used directly.
--   
--   <pre>
--   &gt;&gt;&gt; [1,2,3,4] &amp; upon head .~ 0
--   [0,2,3,4]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [1,2,3,4] &amp; upon last .~ 5
--   [1,2,3,5]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [1,2,3,4] ^? upon tail
--   Just [2,3,4]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "" ^? upon tail
--   Nothing
--   </pre>
--   
--   Accessing parents on the way down to children is okay:
--   
--   <pre>
--   &gt;&gt;&gt; [1,2,3,4] &amp; upon (tail.tail) .~ [10,20]
--   [1,2,10,20]
--   </pre>
--   
--   Second, the structure must not contain strict or unboxed fields of the
--   same type that will be visited by <a>Data</a>
--   
--   <pre>
--   <a>upon</a> :: (<a>Data</a> s, <a>Data</a> a) =&gt; (s -&gt; a) -&gt; <a>IndexedTraversal'</a> [Int] s a
--   </pre>
upon :: (Indexable [Int] p, Applicative f, Data s, Data a) => (s -> a) -> p a (f a) -> s -> f s

-- | The design of <a>onceUpon'</a> doesn't allow it to search inside of
--   values of type <tt>a</tt> for other values of type <tt>a</tt>.
--   <a>upon'</a> provides this additional recursion.
--   
--   Like <a>onceUpon'</a>, <a>upon'</a> trusts the user supplied function
--   more than <a>upon</a> using it directly as the accessor. This enables
--   reading from the resulting <a>Lens</a> to be considerably faster at
--   the risk of generating an illegal lens.
--   
--   <pre>
--   &gt;&gt;&gt; upon' (tail.tail) .~ [10,20] $ [1,2,3,4]
--   [1,2,10,20]
--   </pre>
upon' :: (Data s, Data a) => (s -> a) -> IndexedLens' [Int] s a

-- | This automatically constructs a <a>Traversal'</a> from a field
--   accessor.
--   
--   The index of the <a>Traversal</a> can be used as an offset into
--   <tt><a>elementOf</a> (<a>indexing</a> <a>template</a>)</tt> or into
--   the list returned by <tt><a>holesOf</a> <a>template</a></tt>.
--   
--   The design of <a>onceUpon</a> doesn't allow it to search inside of
--   values of type <tt>a</tt> for other values of type <tt>a</tt>.
--   <a>upon</a> provides this additional recursion, but at the expense of
--   performance.
--   
--   <pre>
--   &gt;&gt;&gt; onceUpon (tail.tail) .~ [10,20] $ [1,2,3,4] -- BAD
--   [1,10,20]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; upon (tail.tail) .~ [10,20] $ [1,2,3,4] -- GOOD
--   [1,2,10,20]
--   </pre>
--   
--   When in doubt, use <a>upon</a> instead.
onceUpon :: (Data s, Typeable a) => (s -> a) -> IndexedTraversal' Int s a

-- | This more trusting version of <a>upon</a> uses your function directly
--   as the getter for a <a>Lens</a>.
--   
--   This means that reading from <a>upon'</a> is considerably faster than
--   <a>upon</a>.
--   
--   However, you pay for faster access in two ways:
--   
--   <ol>
--   <li>When passed an illegal field accessor, <a>upon'</a> will give you
--   a <a>Lens</a> that quietly violates the laws, unlike <a>upon</a>,
--   which will give you a legal <a>Traversal</a> that avoids modifying the
--   target.</li>
--   <li>Modifying with the lens is slightly slower, since it has to go
--   back and calculate the index after the fact.</li>
--   </ol>
--   
--   When given a legal field accessor, the index of the <a>Lens</a> can be
--   used as an offset into <tt><a>elementOf</a> (<a>indexed</a>
--   <a>template</a>)</tt> or into the list returned by <tt><a>holesOf</a>
--   <a>template</a></tt>.
--   
--   When in doubt, use <a>upon'</a> instead.
onceUpon' :: (Data s, Typeable a) => (s -> a) -> IndexedLens' Int s a

-- | A generic applicative transformation that maps over the immediate
--   subterms.
--   
--   <a>gtraverse</a> is to <a>traverse</a> what <a>gmapM</a> is to
--   <a>mapM</a>
--   
--   This really belongs in <tt>Data.Data</tt>.
gtraverse :: (Applicative f, Data a) => (forall d. Data d => d -> f d) -> a -> f a
instance Typeable1 FieldException
instance Eq a => Eq (Answer a)
instance Ord a => Ord (Answer a)
instance Show a => Show (Answer a)
instance Read a => Read (Answer a)
instance Functor Oracle
instance Functor Answer
instance Typeable a => Exception (FieldException a)
instance Show (FieldException a)


-- | The name "plate" stems originally from "boilerplate", which was the
--   term used by the "Scrap Your Boilerplate" papers, and later inherited
--   by Neil Mitchell's "Uniplate".
--   
--   <a>http://community.haskell.org/~ndm/uniplate/</a>
--   
--   The combinators in here are designed to be compatible with and subsume
--   the <tt>uniplate</tt> API with the notion of a <a>Traversal</a>
--   replacing a <a>uniplate</a> or <a>biplate</a>.
--   
--   By implementing these combinators in terms of <a>plate</a> instead of
--   <a>uniplate</a> additional type safety is gained, as the user is no
--   longer responsible for maintaining invariants such as the number of
--   children they received.
--   
--   Note: The <tt>Biplate</tt> is <i>deliberately</i> excluded from the
--   API here, with the intention that you replace them with either
--   explicit traversals, or by using the <tt>On</tt> variants of the
--   combinators below with <a>biplate</a> from <tt>Data.Data.Lens</tt>. As
--   a design, it forced the user into too many situations where they had
--   to choose between correctness and ease of use, and it was brittle in
--   the face of competing imports.
--   
--   The sensible use of these combinators makes some simple assumptions.
--   Notably, any of the <tt>On</tt> combinators are expecting a
--   <a>Traversal</a>, <a>Setter</a> or <a>Fold</a> to play the role of the
--   <a>biplate</a> combinator, and so when the types of the contents and
--   the container match, they should be the <a>id</a> <a>Traversal</a>,
--   <a>Setter</a> or <a>Fold</a>.
--   
--   It is often beneficial to use the combinators in this module with the
--   combinators from <tt>Data.Data.Lens</tt> or <tt>GHC.Generics.Lens</tt>
--   to make it easier to automatically derive definitions for
--   <a>plate</a>, or to derive custom traversals.
module Control.Lens.Plated

-- | A <a>Plated</a> type is one where we know how to extract its immediate
--   self-similar children.
--   
--   <i>Example 1</i>:
--   
--   <pre>
--   import Control.Applicative
--   import Control.Lens
--   import Control.Lens.Plated
--   import Data.Data
--   import Data.Data.Lens (<a>uniplate</a>)
--   </pre>
--   
--   <pre>
--   data Expr
--     = Val <a>Int</a>
--     | Neg Expr
--     | Add Expr Expr
--     deriving (<a>Eq</a>,<a>Ord</a>,<a>Show</a>,<a>Read</a>,<a>Data</a>,<a>Typeable</a>)
--   </pre>
--   
--   <pre>
--   instance <a>Plated</a> Expr where
--     <a>plate</a> f (Neg e) = Neg <a>&lt;$&gt;</a> f e
--     <a>plate</a> f (Add a b) = Add <a>&lt;$&gt;</a> f a <a>&lt;*&gt;</a> f b
--     <a>plate</a> _ a = <a>pure</a> a
--   </pre>
--   
--   <i>or</i>
--   
--   <pre>
--   instance <a>Plated</a> Expr where
--     <a>plate</a> = <a>uniplate</a>
--   </pre>
--   
--   <i>Example 2</i>:
--   
--   <pre>
--   import Control.Applicative
--   import Control.Lens
--   import Control.Lens.Plated
--   import Data.Data
--   import Data.Data.Lens (<a>uniplate</a>)
--   </pre>
--   
--   <pre>
--   data Tree a
--     = Bin (Tree a) (Tree a)
--     | Tip a
--     deriving (<a>Eq</a>,<a>Ord</a>,<a>Show</a>,<a>Read</a>,<a>Data</a>,<a>Typeable</a>)
--   </pre>
--   
--   <pre>
--   instance <a>Plated</a> (Tree a) where
--     <a>plate</a> f (Bin l r) = Bin <a>&lt;$&gt;</a> f l <a>&lt;*&gt;</a> f r
--     <a>plate</a> _ t = <a>pure</a> t
--   </pre>
--   
--   <i>or</i>
--   
--   <pre>
--   instance <a>Data</a> a =&gt; <a>Plated</a> (Tree a) where
--     <a>plate</a> = <a>uniplate</a>
--   </pre>
--   
--   Note the big distinction between these two implementations.
--   
--   The former will only treat children directly in this tree as
--   descendents, the latter will treat trees contained in the values under
--   the tips also as descendants!
--   
--   When in doubt, pick a <a>Traversal</a> and just use the various
--   <tt>...Of</tt> combinators rather than pollute <a>Plated</a> with
--   orphan instances!
--   
--   If you want to find something unplated and non-recursive with
--   <a>biplate</a> use the <tt>...OnOf</tt> variant with <a>ignored</a>,
--   though those usecases are much better served in most cases by using
--   the existing <a>Lens</a> combinators! e.g.
--   
--   <pre>
--   <a>toListOf</a> <a>biplate</a> ≡ <a>universeOnOf</a> <a>biplate</a> <a>ignored</a>
--   </pre>
--   
--   This same ability to explicitly pass the <a>Traversal</a> in question
--   is why there is no analogue to uniplate's <tt>Biplate</tt>.
--   
--   Moreover, since we can allow custom traversals, we implement
--   reasonable defaults for polymorphic data types, that only
--   <a>traverse</a> into themselves, and <i>not</i> their polymorphic
--   arguments.
class Plated a where plate = uniplate
plate :: Plated a => Traversal' a a

-- | Extract the immediate descendants of a <a>Plated</a> container.
--   
--   <pre>
--   <a>children</a> ≡ <a>toListOf</a> <a>plate</a>
--   </pre>
children :: Plated a => a -> [a]

-- | Rewrite by applying a rule everywhere you can. Ensures that the rule
--   cannot be applied anywhere in the result:
--   
--   <pre>
--   propRewrite r x = <a>all</a> (<a>isNothing</a> <a>.</a> r) (<a>universe</a> (<a>rewrite</a> r x))
--   </pre>
--   
--   Usually <a>transform</a> is more appropriate, but <a>rewrite</a> can
--   give better compositionality. Given two single transformations
--   <tt>f</tt> and <tt>g</tt>, you can construct <tt>a -&gt; f a
--   <tt>mplus</tt> g a</tt> which performs both rewrites until a fixed
--   point.
rewrite :: Plated a => (a -> Maybe a) -> a -> a

-- | Rewrite by applying a rule everywhere you can. Ensures that the rule
--   cannot be applied anywhere in the result:
--   
--   <pre>
--   propRewriteOf l r x = <a>all</a> (<a>isNothing</a> <a>.</a> r) (<a>universeOf</a> l (<a>rewriteOf</a> l r x))
--   </pre>
--   
--   Usually <a>transformOf</a> is more appropriate, but <a>rewriteOf</a>
--   can give better compositionality. Given two single transformations
--   <tt>f</tt> and <tt>g</tt>, you can construct <tt>a -&gt; f a
--   <tt>mplus</tt> g a</tt> which performs both rewrites until a fixed
--   point.
--   
--   <pre>
--   <a>rewriteOf</a> :: <a>Iso'</a> a a       -&gt; (a -&gt; <a>Maybe</a> a) -&gt; a -&gt; a
--   <a>rewriteOf</a> :: <a>Lens'</a> a a      -&gt; (a -&gt; <a>Maybe</a> a) -&gt; a -&gt; a
--   <a>rewriteOf</a> :: <a>Traversal'</a> a a -&gt; (a -&gt; <a>Maybe</a> a) -&gt; a -&gt; a
--   <a>rewriteOf</a> :: <a>Setter'</a> a a    -&gt; (a -&gt; <a>Maybe</a> a) -&gt; a -&gt; a
--   </pre>
rewriteOf :: ASetter' a a -> (a -> Maybe a) -> a -> a

-- | Rewrite recursively over part of a larger structure.
--   
--   <pre>
--   <a>rewriteOn</a> :: <a>Plated</a> a =&gt; <a>Iso'</a> s a       -&gt; (a -&gt; <a>Maybe</a> a) -&gt; s -&gt; s
--   <a>rewriteOn</a> :: <a>Plated</a> a =&gt; <a>Lens'</a> s a      -&gt; (a -&gt; <a>Maybe</a> a) -&gt; s -&gt; s
--   <a>rewriteOn</a> :: <a>Plated</a> a =&gt; <a>Traversal'</a> s a -&gt; (a -&gt; <a>Maybe</a> a) -&gt; s -&gt; s
--   <a>rewriteOn</a> :: <a>Plated</a> a =&gt; <a>ASetter'</a> s a   -&gt; (a -&gt; <a>Maybe</a> a) -&gt; s -&gt; s
--   </pre>
rewriteOn :: Plated a => ASetter s t a a -> (a -> Maybe a) -> s -> t

-- | Rewrite recursively over part of a larger structure using a specified
--   <a>Setter</a>.
--   
--   <pre>
--   <a>rewriteOnOf</a> :: <a>Plated</a> a =&gt; <a>Iso'</a> s a       -&gt; <a>Iso'</a> a a       -&gt; (a -&gt; <a>Maybe</a> a) -&gt; s -&gt; s
--   <a>rewriteOnOf</a> :: <a>Plated</a> a =&gt; <a>Lens'</a> s a      -&gt; <a>Lens'</a> a a      -&gt; (a -&gt; <a>Maybe</a> a) -&gt; s -&gt; s
--   <a>rewriteOnOf</a> :: <a>Plated</a> a =&gt; <a>Traversal'</a> s a -&gt; <a>Traversal'</a> a a -&gt; (a -&gt; <a>Maybe</a> a) -&gt; s -&gt; s
--   <a>rewriteOnOf</a> :: <a>Plated</a> a =&gt; <a>Setter'</a> s a    -&gt; <a>Setter'</a> a a    -&gt; (a -&gt; <a>Maybe</a> a) -&gt; s -&gt; s
--   </pre>
rewriteOnOf :: ASetter s t a a -> ASetter' a a -> (a -> Maybe a) -> s -> t

-- | Rewrite by applying a monadic rule everywhere you can. Ensures that
--   the rule cannot be applied anywhere in the result.
rewriteM :: (Monad m, Plated a) => (a -> m (Maybe a)) -> a -> m a

-- | Rewrite by applying a monadic rule everywhere you recursing with a
--   user-specified <a>Traversal</a>. Ensures that the rule cannot be
--   applied anywhere in the result.
rewriteMOf :: Monad m => LensLike' (WrappedMonad m) a a -> (a -> m (Maybe a)) -> a -> m a

-- | Rewrite by applying a monadic rule everywhere inside of a structure
--   located by a user-specified <a>Traversal</a>. Ensures that the rule
--   cannot be applied anywhere in the result.
rewriteMOn :: (Monad m, Plated a) => LensLike (WrappedMonad m) s t a a -> (a -> m (Maybe a)) -> s -> m t

-- | Rewrite by applying a monadic rule everywhere inside of a structure
--   located by a user-specified <a>Traversal</a>, using a user-specified
--   <a>Traversal</a> for recursion. Ensures that the rule cannot be
--   applied anywhere in the result.
rewriteMOnOf :: Monad m => LensLike (WrappedMonad m) s t a a -> LensLike' (WrappedMonad m) a a -> (a -> m (Maybe a)) -> s -> m t

-- | Retrieve all of the transitive descendants of a <a>Plated</a>
--   container, including itself.
universe :: Plated a => a -> [a]

-- | Given a <a>Fold</a> that knows how to locate immediate children,
--   retrieve all of the transitive descendants of a node, including
--   itself.
--   
--   <pre>
--   <a>universeOf</a> :: <a>Fold</a> a a -&gt; a -&gt; [a]
--   </pre>
universeOf :: Getting [a] a a -> a -> [a]

-- | Given a <a>Fold</a> that knows how to find <a>Plated</a> parts of a
--   container retrieve them and all of their descendants, recursively.
universeOn :: Plated a => Getting [a] s a -> s -> [a]

-- | Given a <a>Fold</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 <a>Fold</a>.
--   
--   <pre>
--   <a>toListOf</a> l ≡ <a>universeOnOf</a> l <a>ignored</a>
--   </pre>
universeOnOf :: Getting [a] s a -> Getting [a] a a -> s -> [a]

-- | Transform every element in the tree, in a bottom-up manner.
--   
--   For example, replacing negative literals with literals:
--   
--   <pre>
--   negLits = <a>transform</a> $ \x -&gt; case x of
--     Neg (Lit i) -&gt; Lit (<a>negate</a> i)
--     _           -&gt; x
--   </pre>
transform :: Plated a => (a -> a) -> a -> a

-- | Transform every element by recursively applying a given <a>Setter</a>
--   in a bottom-up manner.
--   
--   <pre>
--   <a>transformOf</a> :: <a>Traversal'</a> a a -&gt; (a -&gt; a) -&gt; a -&gt; a
--   <a>transformOf</a> :: <a>Setter'</a> a a    -&gt; (a -&gt; a) -&gt; a -&gt; a
--   </pre>
transformOf :: ASetter' a a -> (a -> a) -> a -> a

-- | Transform every element in the tree in a bottom-up manner over a
--   region indicated by a <a>Setter</a>.
--   
--   <pre>
--   <a>transformOn</a> :: <a>Plated</a> a =&gt; <a>Traversal'</a> s a -&gt; (a -&gt; a) -&gt; s -&gt; s
--   <a>transformOn</a> :: <a>Plated</a> a =&gt; <a>Setter'</a> s a    -&gt; (a -&gt; a) -&gt; s -&gt; s
--   </pre>
transformOn :: Plated a => ASetter s t a a -> (a -> a) -> s -> t

-- | Transform every element in a region indicated by a <a>Setter</a> by
--   recursively applying another <a>Setter</a> in a bottom-up manner.
--   
--   <pre>
--   <a>transformOnOf</a> :: <a>Setter'</a> s a -&gt; <a>Traversal'</a> a a -&gt; (a -&gt; a) -&gt; s -&gt; s
--   <a>transformOnOf</a> :: <a>Setter'</a> s a -&gt; <a>Setter'</a> a a    -&gt; (a -&gt; a) -&gt; s -&gt; s
--   </pre>
transformOnOf :: ASetter s t a a -> ASetter' a a -> (a -> a) -> s -> t

-- | Transform every element in the tree, in a bottom-up manner,
--   monadically.
transformM :: (Monad m, Plated a) => (a -> m a) -> a -> m a

-- | Transform every element in a tree using a user supplied
--   <a>Traversal</a> in a bottom-up manner with a monadic effect.
--   
--   <pre>
--   <a>transformMOf</a> :: <a>Monad</a> m =&gt; <a>Traversal'</a> a a -&gt; (a -&gt; m a) -&gt; a -&gt; m a
--   </pre>
transformMOf :: Monad m => LensLike' (WrappedMonad m) a a -> (a -> m a) -> a -> m a

-- | Transform every element in the tree in a region indicated by a
--   supplied <a>Traversal</a>, in a bottom-up manner, monadically.
--   
--   <pre>
--   <a>transformMOn</a> :: (<a>Monad</a> m, <a>Plated</a> a) =&gt; <a>Traversal'</a> s a -&gt; (a -&gt; m a) -&gt; s -&gt; m s
--   </pre>
transformMOn :: (Monad m, Plated a) => LensLike (WrappedMonad m) s t a a -> (a -> m a) -> s -> m t

-- | Transform every element in a tree that lies in a region indicated by a
--   supplied <a>Traversal</a>, walking with a user supplied
--   <a>Traversal</a> in a bottom-up manner with a monadic effect.
--   
--   <pre>
--   <a>transformMOnOf</a> :: <a>Monad</a> m =&gt; <a>Traversal'</a> s a -&gt; <a>Traversal'</a> a a -&gt; (a -&gt; m a) -&gt; s -&gt; m s
--   </pre>
transformMOnOf :: Monad m => LensLike (WrappedMonad m) s t a a -> LensLike' (WrappedMonad m) a a -> (a -> m a) -> s -> m t

-- | Return a list of all of the editable contexts for every location in
--   the structure, recursively.
--   
--   <pre>
--   propUniverse x = <a>universe</a> x <a>==</a> <a>map</a> <a>pos</a> (<a>contexts</a> x)
--   propId x = <a>all</a> (<a>==</a> x) [<a>extract</a> w | w &lt;- <a>contexts</a> x]
--   </pre>
--   
--   <pre>
--   <a>contexts</a> ≡ <a>contextsOf</a> <a>plate</a>
--   </pre>
contexts :: Plated a => a -> [Context a a a]

-- | Return a list of all of the editable contexts for every location in
--   the structure, recursively, using a user-specified <a>Traversal</a> to
--   walk each layer.
--   
--   <pre>
--   propUniverse l x = <a>universeOf</a> l x <a>==</a> <a>map</a> <a>pos</a> (<a>contextsOf</a> l x)
--   propId l x = <a>all</a> (<a>==</a> x) [<a>extract</a> w | w &lt;- <a>contextsOf</a> l x]
--   </pre>
--   
--   <pre>
--   <a>contextsOf</a> :: <a>Traversal'</a> a a -&gt; a -&gt; [<a>Context</a> a a a]
--   </pre>
contextsOf :: ATraversal' a a -> a -> [Context 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
--   <a>Traversal</a>, recursively using <a>plate</a>.
--   
--   <pre>
--   <a>contextsOn</a> b ≡ <a>contextsOnOf</a> b <a>plate</a>
--   </pre>
--   
--   <pre>
--   <a>contextsOn</a> :: <a>Plated</a> a =&gt; <a>Traversal'</a> s a -&gt; s -&gt; [<a>Context</a> a a s]
--   </pre>
contextsOn :: Plated a => ATraversal s t a a -> s -> [Context a a t]

-- | Return a list of all of the editable contexts for every location in
--   the structure in an areas indicated by a user supplied
--   <a>Traversal</a>, recursively using another user-supplied
--   <a>Traversal</a> to walk each layer.
--   
--   <pre>
--   <a>contextsOnOf</a> :: <a>Traversal'</a> s a -&gt; <a>Traversal'</a> a a -&gt; s -&gt; [<a>Context</a> a a s]
--   </pre>
contextsOnOf :: ATraversal s t a a -> ATraversal' a a -> s -> [Context a a t]

-- | The one-level version of <a>context</a>. This extracts a list of the
--   immediate children as editable contexts.
--   
--   Given a context you can use <a>pos</a> to see the values, <a>peek</a>
--   at what the structure would be like with an edited result, or simply
--   <a>extract</a> the original structure.
--   
--   <pre>
--   propChildren x = <a>children</a> l x <a>==</a> <a>map</a> <a>pos</a> (<a>holes</a> l x)
--   propId x = <a>all</a> (<a>==</a> x) [<a>extract</a> w | w &lt;- <a>holes</a> l x]
--   </pre>
--   
--   <pre>
--   <a>holes</a> = <a>holesOf</a> <a>plate</a>
--   </pre>
holes :: Plated a => a -> [Pretext (->) a a a]

-- | An alias for <a>holesOf</a>, provided for consistency with the other
--   combinators.
--   
--   <pre>
--   <a>holesOn</a> ≡ <a>holesOf</a>
--   </pre>
--   
--   <pre>
--   <a>holesOn</a> :: <a>Iso'</a> s a                -&gt; s -&gt; [<a>Pretext</a> (-&gt;) a a s]
--   <a>holesOn</a> :: <a>Lens'</a> s a               -&gt; s -&gt; [<a>Pretext</a> (-&gt;) a a s]
--   <a>holesOn</a> :: <a>Traversal'</a> s a          -&gt; s -&gt; [<a>Pretext</a> (-&gt;) a a s]
--   <a>holesOn</a> :: <a>IndexedLens'</a> i s a      -&gt; s -&gt; [<a>Pretext</a> (<a>Indexed</a> i) a a s]
--   <a>holesOn</a> :: <a>IndexedTraversal'</a> i s a -&gt; s -&gt; [<a>Pretext</a> (<a>Indexed</a> i) a a s]
--   </pre>
holesOn :: Conjoined p => Overloading p (->) (Bazaar p a a) s t a a -> s -> [Pretext p a a t]

-- | Extract one level of <a>holes</a> from a container in a region
--   specified by one <a>Traversal</a>, using another.
--   
--   <pre>
--   <a>holesOnOf</a> b l ≡ <a>holesOf</a> (b <a>.</a> l)
--   </pre>
--   
--   <pre>
--   <a>holesOnOf</a> :: <a>Iso'</a> s a       -&gt; <a>Iso'</a> a a                -&gt; s -&gt; [<a>Pretext</a> (-&gt;) a a s]
--   <a>holesOnOf</a> :: <a>Lens'</a> s a      -&gt; <a>Lens'</a> a a               -&gt; s -&gt; [<a>Pretext</a> (-&gt;) a a s]
--   <a>holesOnOf</a> :: <a>Traversal'</a> s a -&gt; <a>Traversal'</a> a a          -&gt; s -&gt; [<a>Pretext</a> (-&gt;) a a s]
--   <a>holesOnOf</a> :: <a>Lens'</a> s a      -&gt; <a>IndexedLens'</a> i a a      -&gt; s -&gt; [<a>Pretext</a> (<a>Indexed</a> i) a a s]
--   <a>holesOnOf</a> :: <a>Traversal'</a> s a -&gt; <a>IndexedTraversal'</a> i a a -&gt; s -&gt; [<a>Pretext</a> (<a>Indexed</a> i) a a s]
--   </pre>
holesOnOf :: Conjoined p => LensLike (Bazaar p r r) s t a b -> Overloading p (->) (Bazaar p r r) a b r r -> s -> [Pretext p r r t]

-- | Perform a fold-like computation on each value, technically a
--   paramorphism.
--   
--   <pre>
--   <a>para</a> ≡ <a>paraOf</a> <a>plate</a>
--   </pre>
para :: Plated a => (a -> [r] -> r) -> a -> r

-- | Perform a fold-like computation on each value, technically a
--   paramorphism.
--   
--   <pre>
--   <a>paraOf</a> :: <a>Fold</a> a a -&gt; (a -&gt; [r] -&gt; r) -&gt; a -&gt; r
--   </pre>
paraOf :: Getting (Endo [a]) a a -> (a -> [r] -> r) -> a -> r

-- | Fold the immediate children of a <a>Plated</a> container.
--   
--   <pre>
--   <a>composOpFold</a> z c f = <a>foldrOf</a> <a>plate</a> (c <a>.</a> f) z
--   </pre>
composOpFold :: Plated a => b -> (b -> b -> b) -> (a -> b) -> a -> b

-- | The original <tt>uniplate</tt> combinator, implemented in terms of
--   <a>Plated</a> as a <a>Lens</a>.
--   
--   <pre>
--   <a>parts</a> ≡ <a>partsOf</a> <a>plate</a>
--   </pre>
--   
--   The resulting <a>Lens</a> is safer to use as it ignores
--   'over-application' and deals gracefully with under-application, but it
--   is only a proper <a>Lens</a> if you don't change the list
--   <a>length</a>!
parts :: Plated a => Lens' a [a]
instance Plated Pat
instance Plated Stmt
instance Plated Type
instance Plated Con
instance Plated Dec
instance Plated Exp
instance Plated (Tree a)
instance Plated [a]


module Control.Lens.At

-- | <a>At</a> provides a <a>Lens</a> that can be used to read, write or
--   delete the value associated with a key in a <a>Map</a>-like container
--   on an ad hoc basis.
--   
--   An instance of <a>At</a> should satisfy:
--   
--   <pre>
--   <a>ix</a> k ≡ <a>at</a> k <a>&lt;.</a> <a>traverse</a>
--   </pre>
class At m
at :: At m => Index m -> IndexedLens' (Index m) m (Maybe (IxValue m))
sans :: At m => Index m -> m -> m

-- | This provides a common notion of a value at an index that is shared by
--   both <a>Ixed</a> and <a>At</a>.

-- | This simple <a>IndexedTraversal</a> lets you <a>traverse</a> the value
--   at a given key in a <a>Map</a> or element at an ordinal position in a
--   list or <a>Seq</a>.
class Functor f => Ixed f m where ix = ixAt
ix :: Ixed f m => Index m -> IndexedLensLike' (Index m) f m (IxValue m)

-- | A definition of <a>ix</a> for types with an <a>At</a> instance. This
--   is the default if you don't specify a definition for <a>ix</a>.
ixAt :: (Applicative f, At m) => Index m -> IndexedLensLike' (Index m) f m (IxValue m)

-- | A definition of <a>ix</a> for types with an <a>Each</a> instance.
ixEach :: (Applicative f, Eq (Index m), Each f m m (IxValue m) (IxValue m)) => Index m -> IndexedLensLike' (Index m) f m (IxValue m)

-- | This class provides a simple <a>IndexedFold</a> (or
--   <a>IndexedTraversal</a>) that lets you view (and modify) information
--   about whether or not a container contains a given <a>Index</a>.
class Functor f => Contains f m where contains = containsAt
contains :: Contains f m => Index m -> IndexedLensLike' (Index m) f m Bool

-- | A definition of <a>contains</a> for types with an <a>Ix</a> instance.
containsIx :: (Contravariant f, Functor f, Ixed (Accessor Any) m) => Index m -> IndexedLensLike' (Index m) f m Bool

-- | A definition of <a>ix</a> for types with an <a>At</a> instance. This
--   is the default if you don't specify a definition for <a>contains</a>
--   and you are on GHC &gt;= 7.0.2
containsAt :: (Contravariant f, Functor f, At m) => Index m -> IndexedLensLike' (Index m) f m Bool

-- | Construct a <a>contains</a> check based on some notion of
--   <a>length</a> for the container.
containsLength :: (Ord i, Num i) => (s -> i) -> i -> IndexedGetter i s Bool

-- | Construct a <a>contains</a> check for a fixed number of elements.
containsN :: Int -> Int -> IndexedGetter Int s Bool

-- | Construct a <a>contains</a> check that uses an arbitrary test.
containsTest :: (i -> s -> Bool) -> i -> IndexedGetter i s Bool

-- | Construct a <a>contains</a> check that uses an arbitrary <a>lookup</a>
--   function.
containsLookup :: (i -> s -> Maybe a) -> i -> IndexedGetter i s Bool

-- | Deprecated aliases for <a>ix</a>.

-- | <i>Deprecated: use <a>ix</a>. This function will be removed after GHC
--   7.8 is released. </i>
_at :: Ixed f m => Index m -> IndexedLensLike' (Index m) f m (IxValue m)

-- | Deprecated aliases for <a>ix</a>.

-- | <i>Deprecated: use <a>ix</a>. This function will be removed after GHC
--   7.8 is released. </i>
resultAt :: Ixed f m => Index m -> IndexedLensLike' (Index m) f m (IxValue m)
instance (Eq k, Hashable k) => At (HashMap k a)
instance Ord k => At (Map k a)
instance At (IntMap a)
instance (Applicative f, a ~ b, b ~ c, c ~ d, d ~ e, e ~ f', f' ~ g, g ~ h, h ~ i) => Ixed f (a, b, c, d, e, f', g, h, i)
instance (Applicative f, a ~ b, b ~ c, c ~ d, d ~ e, e ~ f', f' ~ g, g ~ h) => Ixed f (a, b, c, d, e, f', g, h)
instance (Applicative f, a ~ b, b ~ c, c ~ d, d ~ e, e ~ f', f' ~ g) => Ixed f (a, b, c, d, e, f', g)
instance (Applicative f, a ~ b, b ~ c, c ~ d, d ~ e, e ~ f') => Ixed f (a, b, c, d, e, f')
instance (Applicative f, a ~ b, b ~ c, c ~ d, d ~ e) => Ixed f (a, b, c, d, e)
instance (Applicative f, a ~ b, b ~ c, c ~ d) => Ixed f (a, b, c, d)
instance (Applicative f, a ~ b, b ~ c) => Ixed f (a, b, c)
instance (Applicative f, a ~ b) => Ixed f (a, b)
instance Applicative f => Ixed f (Complex a)
instance (Functor f, Eq k) => Ixed f (k -> a)
instance Applicative f => Ixed f ByteString
instance Applicative f => Ixed f ByteString
instance Applicative f => Ixed f Text
instance Applicative f => Ixed f Text
instance (Applicative f, Unbox a) => Ixed f (Vector a)
instance (Applicative f, Storable a) => Ixed f (Vector a)
instance (Applicative f, Prim a) => Ixed f (Vector a)
instance Applicative f => Ixed f (Vector a)
instance (Applicative f, IArray UArray e, Ix i) => Ixed f (UArray i e)
instance (Applicative f, Ix i) => Ixed f (Array i e)
instance (Applicative f, Eq k, Hashable k) => Ixed f (HashMap k a)
instance (Applicative f, Ord k) => Ixed f (Map k a)
instance Applicative f => Ixed f (IntMap a)
instance Applicative f => Ixed f (Seq a)
instance Applicative f => Ixed f (Tree a)
instance Functor f => Ixed f (Identity a)
instance Applicative f => Ixed f [a]
instance (Contravariant f, Functor f) => Contains f ByteString
instance (Contravariant f, Functor f) => Contains f ByteString
instance (Contravariant f, Functor f) => Contains f Text
instance (Contravariant f, Functor f) => Contains f Text
instance (Contravariant f, Functor f, Unbox a) => Contains f (Vector a)
instance (Contravariant f, Functor f, Storable a) => Contains f (Vector a)
instance (Contravariant f, Functor f, Prim a) => Contains f (Vector a)
instance (Contravariant f, Functor f) => Contains f (Vector a)
instance (Contravariant f, Functor f, IArray UArray e, Ix i) => Contains f (UArray i e)
instance (Contravariant f, Functor f, Ix i) => Contains f (Array i e)
instance (Contravariant f, Functor f, Eq k, Hashable k) => Contains f (HashMap k a)
instance (Contravariant f, Functor f, Ord k) => Contains f (Map k a)
instance (Contravariant k, Functor k) => Contains k (IntMap a)
instance (Contravariant k, Functor k) => Contains k (a, b, c, d, e, f, g, h, i)
instance (Contravariant k, Functor k) => Contains k (a, b, c, d, e, f, g, h)
instance (Contravariant k, Functor k) => Contains k (a, b, c, d, e, f, g)
instance (Contravariant k, Functor k) => Contains k (a, b, c, d, e, f)
instance (Contravariant k, Functor k) => Contains k (a, b, c, d, e)
instance (Contravariant k, Functor k) => Contains k (a, b, c, d)
instance (Contravariant k, Functor k) => Contains k (a, b, c)
instance (Contravariant k, Functor k) => Contains k (a, b)
instance (Contravariant k, Functor k) => Contains k (Identity a)
instance (Contravariant f, Functor f) => Contains f (Tree a)
instance (Contravariant f, Functor f) => Contains f (Complex a)
instance (Contravariant f, Functor f) => Contains f (Seq a)
instance (Contravariant f, Functor f) => Contains f [a]
instance (Functor f, Eq a, Hashable a) => Contains f (HashSet a)
instance (Functor f, Ord a) => Contains f (Set a)
instance Functor f => Contains f IntSet
instance (Functor f, Contravariant f) => Contains f (e -> a)


-- | Lenses and Traversals for working with Template Haskell
module Language.Haskell.TH.Lens

-- | Has a <a>Name</a>
class HasName t
name :: HasName t => Lens' t Name

-- | Provides for the extraction of free type variables, and alpha
--   renaming.
class HasTypeVars t
typeVarsEx :: HasTypeVars t => Set Name -> Traversal' t Name

-- | Provides substitution for types
class SubstType t
substType :: SubstType t => Map Name Type -> t -> t

-- | Traverse <i>free</i> type variables
typeVars :: HasTypeVars t => Traversal' t Name

-- | Substitute using a map of names in for <i>free</i> type variables
substTypeVars :: HasTypeVars t => Map Name Name -> t -> t

-- | Provides a <a>Traversal</a> of the types of each field of a
--   constructor.
conFields :: Traversal' Con StrictType

-- | <a>Traversal</a> of the types of the <i>named</i> fields of a
--   constructor.
conNamedFields :: Traversal' Con VarStrictType
instance SubstType Pred
instance SubstType t => SubstType [t]
instance SubstType Type
instance HasTypeVars t => HasTypeVars [t]
instance HasTypeVars Con
instance HasTypeVars Pred
instance HasTypeVars Type
instance HasTypeVars Name
instance HasTypeVars TyVarBndr
instance HasName Con
instance HasName Name
instance HasName TyVarBndr


module Control.Lens.TH

-- | Build lenses (and traversals) with a sensible default configuration.
--   
--   <pre>
--   <a>makeLenses</a> = <a>makeLensesWith</a> <a>lensRules</a>
--   </pre>
makeLenses :: Name -> Q [Dec]

-- | Derive lenses and traversals, specifying explicit pairings of
--   <tt>(fieldName, lensName)</tt>.
--   
--   If you map multiple names to the same label, and it is present in the
--   same constructor then this will generate a <a>Traversal</a>.
--   
--   <i>e.g.</i>
--   
--   <pre>
--   <a>makeLensesFor</a> [("_foo", "fooLens"), ("baz", "lbaz")] ''Foo
--   <a>makeLensesFor</a> [("_barX", "bar"), ("_barY", "bar")] ''Bar
--   </pre>
makeLensesFor :: [(String, String)] -> Name -> Q [Dec]

-- | Make lenses and traversals for a type, and create a class when the
--   type has no arguments.
--   
--   <i>e.g.</i>
--   
--   <pre>
--   data Foo = Foo { _fooX, _fooY :: <a>Int</a> }
--   <a>makeClassy</a> ''Foo
--   </pre>
--   
--   will create
--   
--   <pre>
--   class HasFoo t where
--     foo :: <a>Simple</a> <a>Lens</a> t Foo
--   instance HasFoo Foo where foo = <a>id</a>
--   fooX, fooY :: HasFoo t =&gt; <a>Simple</a> <a>Lens</a> t <a>Int</a>
--   </pre>
--   
--   <pre>
--   <a>makeClassy</a> = <a>makeLensesWith</a> <a>classyRules</a>
--   </pre>
makeClassy :: Name -> Q [Dec]

-- | Derive lenses and traversals, using a named wrapper class, and
--   specifying explicit pairings of <tt>(fieldName, traversalName)</tt>.
--   
--   Example usage:
--   
--   <pre>
--   <a>makeClassyFor</a> "HasFoo" "foo" [("_foo", "fooLens"), ("bar", "lbar")] ''Foo
--   </pre>
makeClassyFor :: String -> String -> [(String, String)] -> Name -> Q [Dec]

-- | Make a top level isomorphism injecting <i>into</i> the type.
--   
--   The supplied name is required to be for a type with a single
--   constructor that has a single argument.
--   
--   <i>e.g.</i>
--   
--   <pre>
--   newtype <tt>List</tt> a = <tt>List</tt> [a]
--   <a>makeIso</a> ''List
--   </pre>
--   
--   will create
--   
--   <pre>
--   <tt>list</tt> :: <a>Iso</a> [a] [b] (<tt>List</tt> a) (<tt>List</tt> b)
--   </pre>
--   
--   <pre>
--   <a>makeIso</a> = <a>makeLensesWith</a> <a>isoRules</a>
--   </pre>
makeIso :: Name -> Q [Dec]

-- | Generate a <a>Prism</a> for each constructor of a data type.
makePrisms :: Name -> Q [Dec]

-- | Build <a>Wrapped</a> instance for a given newtype
makeWrapped :: Name -> DecsQ

-- | <pre>
--   makeFields = <a>makeFieldsWith</a> <a>defaultFieldRules</a>
--   </pre>
makeFields :: Name -> Q [Dec]

-- | Build lenses with a custom configuration.
makeLensesWith :: LensRules -> Name -> Q [Dec]

-- | Make fields with the specified <a>FieldRules</a>.
makeFieldsWith :: FieldRules -> Name -> Q [Dec]

-- | Default <a>LensRules</a>.
defaultRules :: LensRules

-- | <pre>
--   defaultFieldRules = <a>camelCaseFields</a>
--   </pre>
defaultFieldRules :: FieldRules

-- | Field rules for fields in the form <tt> prefixFieldname </tt>
camelCaseFields :: FieldRules

-- | Field rules for fields in the form <tt> _prefix_fieldname </tt>
underscoreFields :: FieldRules

-- | This configuration describes the options we'll be using to make
--   isomorphisms or lenses.
data LensRules
LensRules :: (String -> Maybe String) -> (String -> Maybe String) -> (String -> Maybe (String, String)) -> Set LensFlag -> LensRules
data FieldRules
FieldRules :: (String -> Maybe String) -> (String -> String) -> (String -> Maybe String) -> (String -> Maybe String) -> FieldRules

-- | Rules for making fairly simple partial lenses, ignoring the special
--   cases for isomorphisms and traversals, and not making any classes.
lensRules :: LensRules

-- | Rules for making lenses and traversals that precompose another
--   <a>Lens</a>.
classyRules :: LensRules

-- | Rules for making an isomorphism from a data type.
isoRules :: LensRules

-- | <a>Lens'</a> to access the convention for naming top level
--   isomorphisms in our <a>LensRules</a>.
--   
--   Defaults to lowercasing the first letter of the constructor.
lensIso :: Lens' LensRules (String -> Maybe String)

-- | <a>Lens'</a> to access the convention for naming fields in our
--   <a>LensRules</a>.
--   
--   Defaults to stripping the _ off of the field name, lowercasing the
--   name, and rejecting the field if it doesn't start with an '_'.
lensField :: Lens' LensRules (String -> Maybe String)

-- | Retrieve options such as the name of the class and method to put in it
--   to build a class around monomorphic data types.
lensClass :: Lens' LensRules (String -> Maybe (String, String))

-- | Retrieve options such as the name of the class and method to put in it
--   to build a class around monomorphic data types.
lensFlags :: Lens' LensRules (Set LensFlag)

-- | Flags for <a>Lens</a> construction
data LensFlag
SimpleLenses :: LensFlag
PartialLenses :: LensFlag
BuildTraversals :: LensFlag
SingletonAndField :: LensFlag
SingletonIso :: LensFlag
HandleSingletons :: LensFlag
SingletonRequired :: LensFlag
CreateClass :: LensFlag
CreateInstance :: LensFlag
ClassRequired :: LensFlag
GenerateSignatures :: LensFlag

-- | Only Generate valid <a>Simple</a> lenses.
simpleLenses :: Lens' LensRules Bool

-- | Enables the generation of partial lenses, generating runtime errors
--   for every constructor that does not have a valid definition for the
--   <a>Lens</a>. This occurs when the constructor lacks the field, or has
--   multiple fields mapped to the same <a>Lens</a>.
partialLenses :: Lens' LensRules Bool

-- | In the situations that a <a>Lens</a> would be partial, when
--   <a>partialLenses</a> is used, this flag instead causes traversals to
--   be generated. Only one can be used, and if neither are, then
--   compile-time errors are generated.
buildTraversals :: Lens' LensRules Bool

-- | Handle singleton constructors specially.
handleSingletons :: Lens' LensRules Bool

-- | Use <a>Iso</a> for singleton constructors.
singletonIso :: Lens' LensRules Bool

-- | Expect a single constructor, single field newtype or data type.
singletonRequired :: Lens' LensRules Bool

-- | Create the class if the constructor is <a>Simple</a> and the
--   <a>lensClass</a> rule matches.
createClass :: Lens' LensRules Bool

-- | Create the instance if the constructor is <a>Simple</a> and the
--   <a>lensClass</a> rule matches.
createInstance :: Lens' LensRules Bool

-- | Die if the <a>lensClass</a> fails to match.
classRequired :: Lens' LensRules Bool

-- | When building a singleton <a>Iso</a> (or <a>Lens</a>) for a record
--   constructor, build both the <a>Iso</a> (or <a>Lens</a>) for the record
--   and the one for the field.
singletonAndField :: Lens' LensRules Bool

-- | Indicate whether or not to supply the signatures for the generated
--   lenses.
--   
--   Disabling this can be useful if you want to provide a more restricted
--   type signature or if you want to supply hand-written haddocks.
generateSignatures :: Lens' LensRules Bool
instance Eq LensFlag
instance Ord LensFlag
instance Show LensFlag
instance Read LensFlag


-- | Usage:
--   
--   You can derive lenses automatically for many data types:
--   
--   <pre>
--   import Control.Lens
--   data Foo a = Foo { _fooArgs :: [<a>String</a>], _fooValue :: a }
--   <a>makeLenses</a> ''Foo
--   </pre>
--   
--   This defines the following lenses:
--   
--   <pre>
--   fooArgs :: <a>Lens'</a> (Foo a) [<a>String</a>]
--   fooValue :: <a>Lens</a> (Foo a) (Foo b) a b
--   </pre>
--   
--   You can then access the value with (<a>^.</a>) and set the value of
--   the field with (<a>.~</a>) and can use almost any other combinator
--   that is re-exported here on those fields.
--   
--   The combinators here have unusually specific type signatures, so for
--   particularly tricky ones, the simpler type signatures you might want
--   to pretend the combinators have are specified as well.
--   
--   More information on how to use lenses is available on the lens wiki:
--   
--   <a>http://github.com/ekmett/lens/wiki</a>
--   
module Control.Lens


-- | Note: <tt>Generics.Deriving</tt> exports a number of names that
--   collide with <tt>Control.Lens</tt>.
--   
--   You can use hiding or imports to mitigate this to an extent, and the
--   following imports, represent a fair compromise for user code:
--   
--   <pre>
--   import Control.Lens hiding (Rep)
--   import Generics.Deriving hiding (from, to)
--   </pre>
--   
--   You can use <a>generic</a> to replace <a>from</a> and <a>to</a> from
--   <tt>Generics.Deriving</tt>, and probably won't be explicitly
--   referencing <a>Rep</a> from <tt>Control.Lens</tt> in code that uses
--   generics.
module Generics.Deriving.Lens

-- | Convert from the data type to its representation (or back)
--   
--   <pre>
--   &gt;&gt;&gt; "hello"^.generic.from generic :: String
--   "hello"
--   </pre>
generic :: Generic a => Iso' a (Rep a b)

-- | Convert from the data type to its representation (or back)
generic1 :: Generic1 f => Iso' (f a) (Rep1 f a)

-- | A <a>Generic</a> <a>Traversal</a> that visits every occurrence of
--   something <a>Typeable</a> anywhere in a container.
--   
--   <pre>
--   &gt;&gt;&gt; allOf tinplate (=="Hello") (1::Int,2::Double,(),"Hello",["Hello"])
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; mapMOf_ tinplate putStrLn ("hello",[(2 :: Int, "world!")])
--   hello
--   world!
--   </pre>
tinplate :: (Generic a, GTraversal (Rep a), Typeable b) => Traversal' a b

-- | Used to traverse <a>Generic</a> data by <a>uniplate</a>.
class GTraversal f
instance (Traversable f, GTraversal g) => GTraversal (f :.: g)
instance GTraversal a => GTraversal (M1 i c a)
instance (GTraversal f, GTraversal g) => GTraversal (f :+: g)
instance (GTraversal f, GTraversal g) => GTraversal (f :*: g)
instance GTraversal U1
instance (Generic a, GTraversal (Rep a), Typeable a) => GTraversal (K1 i a)


-- | Note: <tt>GHC.Generics</tt> exports a number of names that collide
--   with <tt>Control.Lens</tt>.
--   
--   You can use hiding or imports to mitigate this to an extent, and the
--   following imports, represent a fair compromise for user code:
--   
--   <pre>
--   import Control.Lens hiding (Rep)
--   import GHC.Generics hiding (from, to)
--   </pre>
--   
--   You can use <a>generic</a> to replace <a>from</a> and <a>to</a> from
--   <tt>GHC.Generics</tt>, and probably won't be explicitly referencing
--   <a>Rep</a> from <tt>Control.Lens</tt> in code that uses generics.
--   
--   This module provides compatibility with older GHC versions by using
--   the <a>generic-deriving</a> package.
module GHC.Generics.Lens


-- | <tt>Control.Exception</tt> provides an example of a large open
--   hierarchy that we can model with prisms and isomorphisms.
--   
--   Additional combinators for working with <a>IOException</a> results can
--   be found in <a>System.IO.Error.Lens</a>.
--   
--   The combinators in this module have been generalized to work with
--   <a>MonadCatchIO</a> instead of just <a>IO</a>. This enables them to be
--   used more easily in <a>Monad</a> transformer stacks.
module Control.Exception.Lens

-- | Catch exceptions that match a given <a>Prism</a> (or any
--   <a>Getter</a>, really).
--   
--   <pre>
--   &gt;&gt;&gt; catching _AssertionFailed (assert False (return "uncaught")) $ \ _ -&gt; return "caught"
--   "caught"
--   </pre>
--   
--   <pre>
--   <a>catching</a> :: <a>MonadCatchIO</a> m =&gt; <a>Prism'</a> <a>SomeException</a> a     -&gt; m r -&gt; (a -&gt; m r) -&gt; m r
--   <a>catching</a> :: <a>MonadCatchIO</a> m =&gt; <a>Lens'</a> <a>SomeException</a> a      -&gt; m r -&gt; (a -&gt; m r) -&gt; m r
--   <a>catching</a> :: <a>MonadCatchIO</a> m =&gt; <a>Traversal'</a> <a>SomeException</a> a -&gt; m r -&gt; (a -&gt; m r) -&gt; m r
--   <a>catching</a> :: <a>MonadCatchIO</a> m =&gt; <a>Iso'</a> <a>SomeException</a> a       -&gt; m r -&gt; (a -&gt; m r) -&gt; m r
--   <a>catching</a> :: <a>MonadCatchIO</a> m =&gt; <a>Getter</a> <a>SomeException</a> a     -&gt; m r -&gt; (a -&gt; m r) -&gt; m r
--   <a>catching</a> :: <a>MonadCatchIO</a> m =&gt; <a>Fold</a> <a>SomeException</a> a       -&gt; m r -&gt; (a -&gt; m r) -&gt; m r
--   </pre>
catching :: MonadCatchIO m => Getting (First a) SomeException a -> m r -> (a -> m r) -> m r

-- | Catch exceptions that match a given <a>Prism</a> (or any
--   <a>Getter</a>), discarding the information about the match. This is
--   particuarly useful when you have a <tt><a>Prism'</a> e ()</tt> where
--   the result of the <a>Prism</a> or <a>Fold</a> isn't particularly
--   valuable, just the fact that it matches.
--   
--   <pre>
--   &gt;&gt;&gt; catching_ _AssertionFailed (assert False (return "uncaught")) $ return "caught"
--   "caught"
--   </pre>
--   
--   <pre>
--   <a>catching_</a> :: <a>MonadCatchIO</a> m =&gt; <a>Prism'</a> <a>SomeException</a> a     -&gt; m r -&gt; m r -&gt; m r
--   <a>catching_</a> :: <a>MonadCatchIO</a> m =&gt; <a>Lens'</a> <a>SomeException</a> a      -&gt; m r -&gt; m r -&gt; m r
--   <a>catching_</a> :: <a>MonadCatchIO</a> m =&gt; <a>Traversal'</a> <a>SomeException</a> a -&gt; m r -&gt; m r -&gt; m r
--   <a>catching_</a> :: <a>MonadCatchIO</a> m =&gt; <a>Iso'</a> <a>SomeException</a> a       -&gt; m r -&gt; m r -&gt; m r
--   <a>catching_</a> :: <a>MonadCatchIO</a> m =&gt; <a>Getter</a> <a>SomeException</a> a     -&gt; m r -&gt; m r -&gt; m r
--   <a>catching_</a> :: <a>MonadCatchIO</a> m =&gt; <a>Fold</a> <a>SomeException</a> a       -&gt; m r -&gt; m r -&gt; m r
--   </pre>
catching_ :: MonadCatchIO m => Getting (First a) SomeException a -> m r -> m r -> m r

-- | A version of <a>catching</a> with the arguments swapped around; useful
--   in situations where the code for the handler is shorter.
--   
--   <pre>
--   &gt;&gt;&gt; handling _NonTermination (\_ -&gt; return "caught") $ throwIO NonTermination
--   "caught"
--   </pre>
--   
--   <pre>
--   <a>handling</a> :: <a>MonadCatchIO</a> m =&gt; <a>Prism'</a> <a>SomeException</a> a     -&gt; (a -&gt; m r) -&gt; m r -&gt; m r
--   <a>handling</a> :: <a>MonadCatchIO</a> m =&gt; <a>Lens'</a> <a>SomeException</a> a      -&gt; (a -&gt; m r) -&gt; m r -&gt; m r
--   <a>handling</a> :: <a>MonadCatchIO</a> m =&gt; <a>Traversal'</a> <a>SomeException</a> a -&gt; (a -&gt; m r) -&gt; m r -&gt; m r
--   <a>handling</a> :: <a>MonadCatchIO</a> m =&gt; <a>Iso'</a> <a>SomeException</a> a       -&gt; (a -&gt; m r) -&gt; m r -&gt; m r
--   <a>handling</a> :: <a>MonadCatchIO</a> m =&gt; <a>Fold</a> <a>SomeException</a> a       -&gt; (a -&gt; m r) -&gt; m r -&gt; m r
--   <a>handling</a> :: <a>MonadCatchIO</a> m =&gt; <a>Getter</a> <a>SomeException</a> a     -&gt; (a -&gt; m r) -&gt; m r -&gt; m r
--   </pre>
handling :: MonadCatchIO m => Getting (First a) SomeException a -> (a -> m r) -> m r -> m r

-- | A version of <a>catching_</a> with the arguments swapped around;
--   useful in situations where the code for the handler is shorter.
--   
--   <pre>
--   &gt;&gt;&gt; handling_ _NonTermination (return "caught") $ throwIO NonTermination
--   "caught"
--   </pre>
--   
--   <pre>
--   <a>handling_</a> :: <a>MonadCatchIO</a> m =&gt; <a>Prism'</a> <a>SomeException</a> a     -&gt; m r -&gt; m r -&gt; m r
--   <a>handling_</a> :: <a>MonadCatchIO</a> m =&gt; <a>Lens'</a> <a>SomeException</a> a      -&gt; m r -&gt; m r -&gt; m r
--   <a>handling_</a> :: <a>MonadCatchIO</a> m =&gt; <a>Traversal'</a> <a>SomeException</a> a -&gt; m r -&gt; m r -&gt; m r
--   <a>handling_</a> :: <a>MonadCatchIO</a> m =&gt; <a>Iso'</a> <a>SomeException</a> a       -&gt; m r -&gt; m r -&gt; m r
--   <a>handling_</a> :: <a>MonadCatchIO</a> m =&gt; <a>Getter</a> <a>SomeException</a> a     -&gt; m r -&gt; m r -&gt; m r
--   <a>handling_</a> :: <a>MonadCatchIO</a> m =&gt; <a>Fold</a> <a>SomeException</a> a       -&gt; m r -&gt; m r -&gt; m r
--   </pre>
handling_ :: MonadCatchIO m => Getting (First a) SomeException a -> m r -> m r -> m r

-- | A variant of <a>try</a> that takes a <a>Prism</a> (or any
--   <a>Getter</a>) to select which exceptions are caught (c.f.
--   <a>tryJust</a>, <a>catchJust</a>). If the <a>Exception</a> does not
--   match the predicate, it is re-thrown.
--   
--   <pre>
--   <a>trying</a> :: <a>MonadCatchIO</a> m =&gt; <a>Prism'</a>     <a>SomeException</a> a -&gt; m r -&gt; m (<a>Either</a> a r)
--   <a>trying</a> :: <a>MonadCatchIO</a> m =&gt; <a>Lens'</a>      <a>SomeException</a> a -&gt; m r -&gt; m (<a>Either</a> a r)
--   <a>trying</a> :: <a>MonadCatchIO</a> m =&gt; <a>Traversal'</a> <a>SomeException</a> a -&gt; m r -&gt; m (<a>Either</a> a r)
--   <a>trying</a> :: <a>MonadCatchIO</a> m =&gt; <a>Iso'</a>       <a>SomeException</a> a -&gt; m r -&gt; m (<a>Either</a> a r)
--   <a>trying</a> :: <a>MonadCatchIO</a> m =&gt; <a>Getter</a>     <a>SomeException</a> a -&gt; m r -&gt; m (<a>Either</a> a r)
--   <a>trying</a> :: <a>MonadCatchIO</a> m =&gt; <a>Fold</a>       <a>SomeException</a> a -&gt; m r -&gt; m (<a>Either</a> a r)
--   </pre>
trying :: MonadCatchIO m => Getting (First a) SomeException a -> m r -> m (Either a r)

-- | Throw an <a>Exception</a> described by a <a>Prism</a>. Exceptions may
--   be thrown from purely functional code, but may only be caught within
--   the <a>IO</a> <a>Monad</a>.
--   
--   <pre>
--   <a>throwing</a> l ≡ <a>reviews</a> l <a>throw</a>
--   </pre>
--   
--   <pre>
--   <a>throwing</a> :: <a>Prism'</a> <a>SomeException</a> t -&gt; t -&gt; r
--   <a>throwing</a> :: <a>Iso'</a> <a>SomeException</a> t   -&gt; t -&gt; r
--   </pre>
throwing :: AReview s SomeException a b -> b -> r

-- | A variant of <a>throwing</a> that can only be used within the
--   <a>IO</a> <a>Monad</a> (or any other <a>MonadCatchIO</a> instance) to
--   throw an <a>Exception</a> described by a <a>Prism</a>.
--   
--   Although <a>throwingM</a> has a type that is a specialization of the
--   type of <a>throwing</a>, the two functions are subtly different:
--   
--   <pre>
--   <a>throwing</a> l e `seq` x  ≡ <a>throwing</a> e
--   <a>throwingM</a> l e `seq` x ≡ x
--   </pre>
--   
--   The first example will cause the <a>Exception</a> <tt>e</tt> to be
--   raised, whereas the second one won't. In fact, <a>throwingM</a> will
--   only cause an <a>Exception</a> to be raised when it is used within the
--   <a>MonadCatchIO</a> instance. The <a>throwingM</a> variant should be
--   used in preference to <a>throwing</a> to raise an <a>Exception</a>
--   within the <a>Monad</a> because it guarantees ordering with respect to
--   other monadic operations, whereas <a>throwing</a> does not.
--   
--   <pre>
--   <a>throwingM</a> l ≡ <a>reviews</a> l <a>throw</a>
--   </pre>
--   
--   <pre>
--   <a>throwingM</a> :: <a>MonadIO</a> m =&gt; <a>Prism'</a> <a>SomeException</a> t -&gt; t -&gt; m r
--   <a>throwingM</a> :: <a>MonadIO</a> m =&gt; <a>Iso'</a> <a>SomeException</a> t   -&gt; t -&gt; m r
--   </pre>
throwingM :: MonadIO m => AReview s SomeException a b -> b -> m r

-- | <a>throwingTo</a> raises an <a>Exception</a> specified by a
--   <a>Prism</a> in the target thread.
--   
--   <pre>
--   <a>throwingTo</a> thread l ≡ <a>reviews</a> l (<a>throwTo</a> thread)
--   </pre>
--   
--   <pre>
--   <a>throwingTo</a> :: <a>ThreadId</a> -&gt; <a>Prism'</a> <a>SomeException</a> t -&gt; t -&gt; m a
--   <a>throwingTo</a> :: <a>ThreadId</a> -&gt; <a>Iso'</a> <a>SomeException</a> t   -&gt; t -&gt; m a
--   </pre>
throwingTo :: MonadIO m => ThreadId -> AReview s SomeException a b -> b -> m ()

-- | Traverse the strongly typed <a>Exception</a> contained in
--   <a>SomeException</a> where the type of your function matches the
--   desired <a>Exception</a>.
--   
--   <pre>
--   <a>exception</a> :: (<a>Applicative</a> f, <a>Exception</a> a)
--             =&gt; (a -&gt; f a) -&gt; <a>SomeException</a> -&gt; f <a>SomeException</a>
--   </pre>
exception :: Exception a => Prism' SomeException a

-- | Both <tt>MonadCatchIO-transformers</tt> and <a>Control.Exception</a>
--   provide a <a>Handler</a> type.
--   
--   This lets us write combinators to build handlers that are agnostic
--   about the choice of which of these they use.
class Handleable e (m :: * -> *) (h :: * -> *) | h -> e m where handler_ l = handler l . const
handler :: Handleable e m h => Getting (First a) e a -> (a -> m r) -> h r
handler_ :: Handleable e m h => Getting (First a) e a -> m r -> h r

-- | Exceptions that occur in the <a>IO</a> <a>Monad</a>. An
--   <a>IOException</a> records a more specific error type, a descriptive
--   string and maybe the handle that was used when the error was flagged.
--   
--   Due to their richer structure relative to other exceptions, these have
--   a more carefully overloaded signature.
class AsIOException p f t
_IOException :: AsIOException p f t => Overloaded' p f t IOException

-- | Arithmetic exceptions.
class AsArithException p f t
_ArithException :: AsArithException p f t => Overloaded' p f t ArithException

-- | Handle arithmetic <a>_Overflow</a>.
--   
--   <pre>
--   <a>_Overflow</a> ≡ <a>_ArithException</a> <a>.</a> <a>_Overflow</a>
--   </pre>
--   
--   <pre>
--   <a>_Overflow</a> :: <a>Prism'</a> <a>ArithException</a> <a>ArithException</a>
--   <a>_Overflow</a> :: <a>Prism'</a> <a>SomeException</a>  <a>ArithException</a>
--   </pre>
_Overflow :: (AsArithException p f t, Choice p, Applicative f) => Overloaded' p f t ()

-- | Handle arithmetic <a>_Underflow</a>.
--   
--   <pre>
--   <a>_Underflow</a> ≡ <a>_ArithException</a> <a>.</a> <a>_Underflow</a>
--   </pre>
--   
--   <pre>
--   <a>_Underflow</a> :: <a>Prism'</a> <a>ArithException</a> <a>ArithException</a>
--   <a>_Underflow</a> :: <a>Prism'</a> <a>SomeException</a>  <a>ArithException</a>
--   </pre>
_Underflow :: (AsArithException p f t, Choice p, Applicative f) => Overloaded' p f t ()

-- | Handle arithmetic loss of precision.
--   
--   <pre>
--   <a>_LossOfPrecision</a> ≡ <a>_ArithException</a> <a>.</a> <a>_LossOfPrecision</a>
--   </pre>
--   
--   <pre>
--   <a>_LossOfPrecision</a> :: <a>Prism'</a> <a>ArithException</a> <a>ArithException</a>
--   <a>_LossOfPrecision</a> :: <a>Prism'</a> <a>SomeException</a>  <a>ArithException</a>
--   </pre>
_LossOfPrecision :: (AsArithException p f t, Choice p, Applicative f) => Overloaded' p f t ()

-- | Handle division by zero.
--   
--   <pre>
--   <a>_DivideByZero</a> ≡ <a>_ArithException</a> <a>.</a> <a>_DivideByZero</a>
--   </pre>
--   
--   <pre>
--   <a>_DivideByZero</a> :: <a>Prism'</a> <a>ArithException</a> <a>ArithException</a>
--   <a>_DivideByZero</a> :: <a>Prism'</a> <a>SomeException</a>  <a>ArithException</a>
--   </pre>
_DivideByZero :: (AsArithException p f t, Choice p, Applicative f) => Overloaded' p f t ()

-- | Handle exceptional _Denormalized floating point.
--   
--   <pre>
--   <a>_Denormal</a> ≡ <a>_ArithException</a> <a>.</a> <a>_Denormal</a>
--   </pre>
--   
--   <pre>
--   <a>_Denormal</a> :: <a>Prism'</a> <a>ArithException</a> <a>ArithException</a>
--   <a>_Denormal</a> :: <a>Prism'</a> <a>SomeException</a>  <a>ArithException</a>
--   </pre>
_Denormal :: (AsArithException p f t, Choice p, Applicative f) => Overloaded' p f t ()

-- | Added in <tt>base</tt> 4.6 in response to this libraries discussion:
--   
--   
--   <a>http://haskell.1045720.n5.nabble.com/Data-Ratio-and-exceptions-td5711246.html</a>
--   
--   <pre>
--   <a>_RatioZeroDenominator</a> ≡ <a>_ArithException</a> <a>.</a> <a>_RatioZeroDenominator</a>
--   </pre>
--   
--   <pre>
--   <a>_RatioZeroDenominator</a> :: <a>Prism'</a> <a>ArithException</a> <a>ArithException</a>
--   <a>_RatioZeroDenominator</a> :: <a>Prism'</a> <a>SomeException</a>  <a>ArithException</a>
--   </pre>
_RatioZeroDenominator :: (AsArithException p f t, Choice p, Applicative f) => Overloaded' p f t ()

-- | Exceptions generated by array operations.
class AsArrayException p f t
_ArrayException :: AsArrayException p f t => Overloaded' p f t ArrayException

-- | An attempt was made to index an array outside its declared bounds.
--   
--   <pre>
--   <a>_IndexOutOfBounds</a> ≡ <a>_ArrayException</a> <a>.</a> <a>_IndexOutOfBounds</a>
--   </pre>
--   
--   <pre>
--   <a>_IndexOutOfBounds</a> :: <a>Prism'</a> <a>ArrayException</a> <a>String</a>
--   <a>_IndexOutOfBounds</a> :: <a>Prism'</a> <a>SomeException</a>  <a>String</a>
--   </pre>
_IndexOutOfBounds :: (AsArrayException p f t, Choice p, Applicative f) => Overloaded' p f t String

-- | An attempt was made to evaluate an element of an array that had not
--   been initialized.
--   
--   <pre>
--   <a>_UndefinedElement</a> ≡ <a>_ArrayException</a> <a>.</a> <a>_UndefinedElement</a>
--   </pre>
--   
--   <pre>
--   <a>_UndefinedElement</a> :: <a>Prism'</a> <a>ArrayException</a> <a>String</a>
--   <a>_UndefinedElement</a> :: <a>Prism'</a> <a>SomeException</a>  <a>String</a>
--   </pre>
_UndefinedElement :: (AsArrayException p f t, Choice p, Applicative f) => Overloaded' p f t String

-- | <a>assert</a> was applied to <a>False</a>.
class AsAssertionFailed p f t
_AssertionFailed :: AsAssertionFailed p f t => Overloaded' p f t String

-- | Asynchronous exceptions.
class AsAsyncException p f t
_AsyncException :: AsAsyncException p f t => Overloaded' p f t AsyncException

-- | The current thread's stack exceeded its limit. Since an
--   <a>Exception</a> has been raised, the thread's stack will certainly be
--   below its limit again, but the programmer should take remedial action
--   immediately.
--   
--   <pre>
--   <a>_StackOverflow</a> :: <a>Prism'</a> <a>AsyncException</a> ()
--   <a>_StackOverflow</a> :: <a>Prism'</a> <a>SomeException</a>  ()
--   </pre>
_StackOverflow :: (AsAsyncException p f t, Choice p, Applicative f) => Overloaded' p f t ()

-- | The program's heap is reaching its limit, and the program should take
--   action to reduce the amount of live data it has.
--   
--   Notes:
--   
--   <ul>
--   <li>It is undefined which thread receives this <a>Exception</a>.</li>
--   <li>GHC currently does not throw <a>HeapOverflow</a> exceptions.</li>
--   </ul>
--   
--   <pre>
--   <a>_HeapOverflow</a> :: <a>Prism'</a> <a>AsyncException</a> ()
--   <a>_HeapOverflow</a> :: <a>Prism'</a> <a>SomeException</a>  ()
--   </pre>
_HeapOverflow :: (AsAsyncException p f t, Choice p, Applicative f) => Overloaded' p f t ()

-- | This <a>Exception</a> is raised by another thread calling
--   <a>killThread</a>, or by the system if it needs to terminate the
--   thread for some reason.
--   
--   <pre>
--   <a>_ThreadKilled</a> :: <a>Prism'</a> <a>AsyncException</a> ()
--   <a>_ThreadKilled</a> :: <a>Prism'</a> <a>SomeException</a>  ()
--   </pre>
_ThreadKilled :: (AsAsyncException p f t, Choice p, Applicative f) => Overloaded' p f t ()

-- | This <a>Exception</a> is raised by default in the main thread of the
--   program when the user requests to terminate the program via the usual
--   mechanism(s) (<i>e.g.</i> Control-C in the console).
--   
--   <pre>
--   <a>_UserInterrupt</a> :: <a>Prism'</a> <a>AsyncException</a> ()
--   <a>_UserInterrupt</a> :: <a>Prism'</a> <a>SomeException</a>  ()
--   </pre>
_UserInterrupt :: (AsAsyncException p f t, Choice p, Applicative f) => Overloaded' p f t ()

-- | Thrown when the runtime system detects that the computation is
--   guaranteed not to terminate. Note that there is no guarantee that the
--   runtime system will notice whether any given computation is guaranteed
--   to terminate or not.
class (Profunctor p, Functor f) => AsNonTermination p f t
_NonTermination :: AsNonTermination p f t => Overloaded' p f t ()

-- | Thrown when the program attempts to call atomically, from the
--   <a>STM</a> package, inside another call to atomically.
class (Profunctor p, Functor f) => AsNestedAtomically p f t
_NestedAtomically :: AsNestedAtomically p f t => Overloaded' p f t ()

-- | The thread is blocked on an <a>MVar</a>, but there are no other
--   references to the <a>MVar</a> so it can't ever continue.
class (Profunctor p, Functor f) => AsBlockedIndefinitelyOnMVar p f t
_BlockedIndefinitelyOnMVar :: AsBlockedIndefinitelyOnMVar p f t => Overloaded' p f t ()

-- | The thread is waiting to retry an <a>STM</a> transaction, but there
--   are no other references to any TVars involved, so it can't ever
--   continue.
class (Profunctor p, Functor f) => AsBlockedIndefinitelyOnSTM p f t
_BlockedIndefinitelyOnSTM :: AsBlockedIndefinitelyOnSTM p f t => Overloaded' p f t ()

-- | There are no runnable threads, so the program is deadlocked. The
--   <a>Deadlock</a> <a>Exception</a> is raised in the main thread only.
class (Profunctor p, Functor f) => AsDeadlock p f t
_Deadlock :: AsDeadlock p f t => Overloaded' p f t ()

-- | A class method without a definition (neither a default definition, nor
--   a definition in the appropriate instance) was called.
class (Profunctor p, Functor f) => AsNoMethodError p f t
_NoMethodError :: AsNoMethodError p f t => Overloaded' p f t String

-- | A pattern match failed.
class (Profunctor p, Functor f) => AsPatternMatchFail p f t
_PatternMatchFail :: AsPatternMatchFail p f t => Overloaded' p f t String

-- | An uninitialised record field was used.
class (Profunctor p, Functor f) => AsRecConError p f t
_RecConError :: AsRecConError p f t => Overloaded' p f t String

-- | A record selector was applied to a constructor without the appropriate
--   field. This can only happen with a datatype with multiple
--   constructors, where some fields are in one constructor but not
--   another.
class (Profunctor p, Functor f) => AsRecSelError p f t
_RecSelError :: AsRecSelError p f t => Overloaded' p f t String

-- | A record update was performed on a constructor without the appropriate
--   field. This can only happen with a datatype with multiple
--   constructors, where some fields are in one constructor but not
--   another.
class (Profunctor p, Functor f) => AsRecUpdError p f t
_RecUpdError :: AsRecUpdError p f t => Overloaded' p f t String

-- | This is thrown when the user calls <a>error</a>.
class (Profunctor p, Functor f) => AsErrorCall p f t
_ErrorCall :: AsErrorCall p f t => Overloaded' p f t String

-- | This <a>Exception</a> is thrown by <tt>lens</tt> when the user somehow
--   manages to rethrow an internal <a>HandlingException</a>.
class (Profunctor p, Functor f) => AsHandlingException p f t
_HandlingException :: AsHandlingException p f t => Overloaded' p f t ()
instance (Choice p, Applicative f) => AsHandlingException p f SomeException
instance (Profunctor p, Functor f) => AsHandlingException p f HandlingException
instance (Choice p, Applicative f) => AsErrorCall p f SomeException
instance (Profunctor p, Functor f) => AsErrorCall p f ErrorCall
instance (Choice p, Applicative f) => AsRecUpdError p f SomeException
instance (Profunctor p, Functor f) => AsRecUpdError p f RecUpdError
instance (Choice p, Applicative f) => AsRecSelError p f SomeException
instance (Profunctor p, Functor f) => AsRecSelError p f RecSelError
instance (Choice p, Applicative f) => AsRecConError p f SomeException
instance (Profunctor p, Functor f) => AsRecConError p f RecConError
instance (Choice p, Applicative f) => AsPatternMatchFail p f SomeException
instance (Profunctor p, Functor f) => AsPatternMatchFail p f PatternMatchFail
instance (Choice p, Applicative f) => AsNoMethodError p f SomeException
instance (Profunctor p, Functor f) => AsNoMethodError p f NoMethodError
instance (Choice p, Applicative f) => AsDeadlock p f SomeException
instance (Profunctor p, Functor f) => AsDeadlock p f Deadlock
instance (Choice p, Applicative f) => AsBlockedIndefinitelyOnSTM p f SomeException
instance (Profunctor p, Functor f) => AsBlockedIndefinitelyOnSTM p f BlockedIndefinitelyOnSTM
instance (Choice p, Applicative f) => AsBlockedIndefinitelyOnMVar p f SomeException
instance (Profunctor p, Functor f) => AsBlockedIndefinitelyOnMVar p f BlockedIndefinitelyOnMVar
instance (Choice p, Applicative f) => AsNestedAtomically p f SomeException
instance (Profunctor p, Functor f) => AsNestedAtomically p f NestedAtomically
instance (Choice p, Applicative f) => AsNonTermination p f SomeException
instance (Profunctor p, Functor f) => AsNonTermination p f NonTermination
instance (Choice p, Applicative f) => AsAsyncException p f SomeException
instance AsAsyncException p f AsyncException
instance (Choice p, Applicative f) => AsAssertionFailed p f SomeException
instance (Profunctor p, Functor f) => AsAssertionFailed p f AssertionFailed
instance (Choice p, Applicative f) => AsArrayException p f SomeException
instance AsArrayException p f ArrayException
instance (Choice p, Applicative f) => AsArithException p f SomeException
instance AsArithException p f ArithException
instance (Choice p, Applicative f) => AsIOException p f SomeException
instance AsIOException p f IOException


module System.IO.Error.Lens

-- | Where the error happened.
--   
--   <pre>
--   <a>location</a> :: <a>Lens'</a>      <a>IOException</a>   <a>String</a>
--   <a>location</a> :: <a>Traversal'</a> <tt>SomeException</tt> <a>String</a>
--   </pre>
location :: (AsIOException (->) f t, Functor f) => LensLike' f t String

-- | Error type specific information.
--   
--   <pre>
--   <a>description</a> :: <a>Lens'</a>      <a>IOException</a>   <a>String</a>
--   <a>description</a> :: <a>Traversal'</a> <tt>SomeException</tt> <a>String</a>
--   </pre>
description :: (AsIOException (->) f t, Functor f) => LensLike' f t String

-- | The handle used by the action flagging this error.
--   
--   <pre>
--   <a>handle</a> :: <a>Lens'</a>      <a>IOException</a>   (<a>Maybe</a> <a>Handle</a>)
--   <a>handle</a> :: <a>Traversal'</a> <tt>SomeException</tt> (<a>Maybe</a> <a>Handle</a>)
--   </pre>
handle :: (AsIOException (->) f t, Functor f) => LensLike' f t (Maybe Handle)

-- | <a>fileName</a> the error is related to.
--   
--   <pre>
--   <a>fileName</a> :: <a>Lens'</a>      <a>IOException</a>   (<a>Maybe</a> <a>FilePath</a>)
--   <a>fileName</a> :: <a>Traversal'</a> <tt>SomeException</tt> (<a>Maybe</a> <a>FilePath</a>)
--   </pre>
fileName :: (AsIOException (->) f t, Functor f) => LensLike' f t (Maybe FilePath)

-- | <a>errno</a> leading to this error, if any.
--   
--   <pre>
--   <a>errno</a> :: <a>Lens'</a>      <a>IOException</a>   (<a>Maybe</a> <a>FilePath</a>)
--   <a>errno</a> :: <a>Traversal'</a> <tt>SomeException</tt> (<a>Maybe</a> <a>FilePath</a>)
--   </pre>
errno :: (AsIOException (->) f t, Functor f) => LensLike' f t (Maybe CInt)

-- | What type of error it is
--   
--   <pre>
--   <a>errorType</a> :: <a>Lens'</a>      <a>IOException</a>   <a>IOErrorType</a>
--   <a>errorType</a> :: <a>Traversal'</a> <tt>SomeException</tt> <a>IOErrorType</a>
--   </pre>
errorType :: (AsIOException (->) f t, Functor f) => LensLike' f t IOErrorType
_Interrupted :: Prism' IOErrorType ()
_ResourceVanished :: Prism' IOErrorType ()
_TimeExpired :: Prism' IOErrorType ()
_UnsupportedOperation :: Prism' IOErrorType ()
_HardwareFault :: Prism' IOErrorType ()
_InappropriateType :: Prism' IOErrorType ()
_InvalidArgument :: Prism' IOErrorType ()
_OtherError :: Prism' IOErrorType ()
_ProtocolError :: Prism' IOErrorType ()
_SystemError :: Prism' IOErrorType ()
_UnsatisfiedConstraints :: Prism' IOErrorType ()
_UserError :: Prism' IOErrorType ()
_PermissionDenied :: Prism' IOErrorType ()
_IllegalOperation :: Prism' IOErrorType ()
_EOF :: Prism' IOErrorType ()
_ResourceExhausted :: Prism' IOErrorType ()
_ResourceBusy :: Prism' IOErrorType ()
_NoSuchThing :: Prism' IOErrorType ()
_AlreadyExists :: Prism' IOErrorType ()


-- | This module spends a lot of time fiddling around with
--   <a>ByteString</a> internals to work around
--   <a>http://hackage.haskell.org/trac/ghc/ticket/7556</a> on older
--   Haskell Platforms and to improve constant and asymptotic factors in
--   our performance.
module Control.Lens.Internal.ByteString

-- | Unpack a strict <a>Bytestring</a>
unpackStrict :: ByteString -> [Word8]

-- | Traverse a strict <a>ByteString</a> from left to right in a biased
--   fashion.
traversedStrict :: Int -> IndexedTraversal' Int ByteString Word8

-- | Traverse a strict <a>ByteString</a> in a relatively balanced fashion,
--   as a balanced tree with biased runs of elements at the leaves.
traversedStrictTree :: Int -> IndexedTraversal' Int ByteString Word8

-- | Unpack a strict <a>Bytestring</a>, pretending the bytes are chars.
unpackStrict8 :: ByteString -> String

-- | Traverse a strict <a>ByteString</a> from left to right in a biased
--   fashion pretending the bytes are characters.
traversedStrict8 :: Int -> IndexedTraversal' Int ByteString Char

-- | Traverse a strict <a>ByteString</a> in a relatively balanced fashion,
--   as a balanced tree with biased runs of elements at the leaves,
--   pretending the bytes are chars.
traversedStrictTree8 :: Int -> IndexedTraversal' Int ByteString Char

-- | Unpack a lazy <tt>Bytestring</tt>
unpackLazy :: ByteString -> [Word8]

-- | An <a>IndexedTraversal</a> of the individual bytes in a lazy
--   <a>ByteString</a>
traversedLazy :: IndexedTraversal' Int64 ByteString Word8

-- | Unpack a lazy <a>ByteString</a> pretending the bytes are chars.
unpackLazy8 :: ByteString -> String

-- | An <a>IndexedTraversal</a> of the individual bytes in a lazy
--   <a>ByteString</a> pretending the bytes are chars.
traversedLazy8 :: IndexedTraversal' Int64 ByteString Char


module Control.Monad.Error.Lens

-- | Catch exceptions that match a given <a>Prism</a> (or any
--   <a>Getter</a>, really).
--   
--   <pre>
--   <a>catching</a> :: <a>MonadError</a> e m =&gt; <a>Prism'</a> e a     -&gt; m r -&gt; (a -&gt; m r) -&gt; m r
--   <a>catching</a> :: <a>MonadError</a> e m =&gt; <a>Lens'</a> e a      -&gt; m r -&gt; (a -&gt; m r) -&gt; m r
--   <a>catching</a> :: <a>MonadError</a> e m =&gt; <a>Traversal'</a> e a -&gt; m r -&gt; (a -&gt; m r) -&gt; m r
--   <a>catching</a> :: <a>MonadError</a> e m =&gt; <a>Iso'</a> e a       -&gt; m r -&gt; (a -&gt; m r) -&gt; m r
--   <a>catching</a> :: <a>MonadError</a> e m =&gt; <a>Getter</a> e a     -&gt; m r -&gt; (a -&gt; m r) -&gt; m r
--   <a>catching</a> :: <a>MonadError</a> e m =&gt; <a>Fold</a> e a       -&gt; m r -&gt; (a -&gt; m r) -&gt; m r
--   </pre>
catching :: MonadError e m => Getting (First a) e a -> m r -> (a -> m r) -> m r

-- | Catch exceptions that match a given <a>Prism</a> (or any
--   <a>Getter</a>), discarding the information about the match. This is
--   particuarly useful when you have a <tt><a>Prism'</a> e ()</tt> where
--   the result of the <a>Prism</a> or <a>Fold</a> isn't particularly
--   valuable, just the fact that it matches.
--   
--   <pre>
--   <a>catching_</a> :: <a>MonadError</a> e m =&gt; <a>Prism'</a> e a     -&gt; m r -&gt; m r -&gt; m r
--   <a>catching_</a> :: <a>MonadError</a> e m =&gt; <a>Lens'</a> e a      -&gt; m r -&gt; m r -&gt; m r
--   <a>catching_</a> :: <a>MonadError</a> e m =&gt; <a>Traversal'</a> e a -&gt; m r -&gt; m r -&gt; m r
--   <a>catching_</a> :: <a>MonadError</a> e m =&gt; <a>Iso'</a> e a       -&gt; m r -&gt; m r -&gt; m r
--   <a>catching_</a> :: <a>MonadError</a> e m =&gt; <a>Getter</a> e a     -&gt; m r -&gt; m r -&gt; m r
--   <a>catching_</a> :: <a>MonadError</a> e m =&gt; <a>Fold</a> e a       -&gt; m r -&gt; m r -&gt; m r
--   </pre>
catching_ :: MonadError e m => Getting (First a) e a -> m r -> m r -> m r

-- | A version of <a>catching</a> with the arguments swapped around; useful
--   in situations where the code for the handler is shorter.
--   
--   <pre>
--   <a>handling</a> :: <a>MonadError</a> e m =&gt; <a>Prism'</a> e a     -&gt; (a -&gt; m r) -&gt; m r -&gt; m r
--   <a>handling</a> :: <a>MonadError</a> e m =&gt; <a>Lens'</a> e a      -&gt; (a -&gt; m r) -&gt; m r -&gt; m r
--   <a>handling</a> :: <a>MonadError</a> e m =&gt; <a>Traversal'</a> e a -&gt; (a -&gt; m r) -&gt; m r -&gt; m r
--   <a>handling</a> :: <a>MonadError</a> e m =&gt; <a>Iso'</a> e a       -&gt; (a -&gt; m r) -&gt; m r -&gt; m r
--   <a>handling</a> :: <a>MonadError</a> e m =&gt; <a>Fold</a> e a       -&gt; (a -&gt; m r) -&gt; m r -&gt; m r
--   <a>handling</a> :: <a>MonadError</a> e m =&gt; <a>Getter</a> e a     -&gt; (a -&gt; m r) -&gt; m r -&gt; m r
--   </pre>
handling :: MonadError e m => Getting (First a) e a -> (a -> m r) -> m r -> m r

-- | A version of <a>catching_</a> with the arguments swapped around;
--   useful in situations where the code for the handler is shorter.
--   
--   <pre>
--   <a>handling_</a> :: <a>MonadError</a> e m =&gt; <a>Prism'</a> e a     -&gt; m r -&gt; m r -&gt; m r
--   <a>handling_</a> :: <a>MonadError</a> e m =&gt; <a>Lens'</a> e a      -&gt; m r -&gt; m r -&gt; m r
--   <a>handling_</a> :: <a>MonadError</a> e m =&gt; <a>Traversal'</a> e a -&gt; m r -&gt; m r -&gt; m r
--   <a>handling_</a> :: <a>MonadError</a> e m =&gt; <a>Iso'</a> e a       -&gt; m r -&gt; m r -&gt; m r
--   <a>handling_</a> :: <a>MonadError</a> e m =&gt; <a>Getter</a> e a     -&gt; m r -&gt; m r -&gt; m r
--   <a>handling_</a> :: <a>MonadError</a> e m =&gt; <a>Fold</a> e a       -&gt; m r -&gt; m r -&gt; m r
--   </pre>
handling_ :: MonadError e m => Getting (First a) e a -> m r -> m r -> m r

-- | <a>trying</a> takes a <a>Prism</a> (or any <a>Getter</a>) to select
--   which exceptions are caught If the <tt>Exception</tt> does not match
--   the predicate, it is re-thrown.
--   
--   <pre>
--   <a>trying</a> :: <a>MonadError</a> e m =&gt; <a>Prism'</a> e a     -&gt; m r -&gt; m (<a>Either</a> a r)
--   <a>trying</a> :: <a>MonadError</a> e m =&gt; <a>Lens'</a> e a      -&gt; m r -&gt; m (<a>Either</a> a r)
--   <a>trying</a> :: <a>MonadError</a> e m =&gt; <a>Traversal'</a> e a -&gt; m r -&gt; m (<a>Either</a> a r)
--   <a>trying</a> :: <a>MonadError</a> e m =&gt; <a>Iso'</a> e a       -&gt; m r -&gt; m (<a>Either</a> a r)
--   <a>trying</a> :: <a>MonadError</a> e m =&gt; <a>Getter</a> e a     -&gt; m r -&gt; m (<a>Either</a> a r)
--   <a>trying</a> :: <a>MonadError</a> e m =&gt; <a>Fold</a> e a       -&gt; m r -&gt; m (<a>Either</a> a r)
--   </pre>
trying :: MonadError e m => Getting (First a) e a -> m r -> m (Either a r)

-- | This function exists to remedy a gap between the functionality of
--   <tt>Control.Exception</tt> and <tt>Control.Monad.Error</tt>.
--   <tt>Control.Exception</tt> supplies <a>catches</a> and a notion of
--   <a>Handler</a>, which we duplicate here in a form suitable for working
--   with any <a>MonadError</a> instance.
--   
--   Sometimes you want to catch two different sorts of error. You could do
--   something like
--   
--   <pre>
--   f = <a>handling</a> _Foo handleFoo (<a>handling</a> _Bar handleBar expr)
--   </pre>
--   
--   However, there are a couple of problems with this approach. The first
--   is that having two exception handlers is inefficient. However, the
--   more serious issue is that the second exception handler will catch
--   exceptions in the first, e.g. in the example above, if
--   <tt>handleFoo</tt> uses <a>throwError</a> then the second exception
--   handler will catch it.
--   
--   Instead, we provide a function <a>catches</a>, which would be used
--   thus:
--   
--   <pre>
--   f = <a>catches</a> expr [ <a>handler</a> _Foo handleFoo
--                    , <a>handler</a> _Bar handleBar
--                    ]
--   </pre>
catches :: MonadError e m => m a -> [Handler e m a] -> m a

-- | You need this when using <a>catches</a>.
data Handler e m r
Handler :: (e -> Maybe a) -> (a -> m r) -> Handler e m r

-- | Both <tt>MonadCatchIO-transformers</tt> and <a>Control.Exception</a>
--   provide a <a>Handler</a> type.
--   
--   This lets us write combinators to build handlers that are agnostic
--   about the choice of which of these they use.
class Handleable e (m :: * -> *) (h :: * -> *) | h -> e m where handler_ l = handler l . const
handler :: Handleable e m h => Getting (First a) e a -> (a -> m r) -> h r
handler_ :: Handleable e m h => Getting (First a) e a -> m r -> h r

-- | Throw an <tt>Exception</tt> described by a <a>Prism</a>.
--   
--   <pre>
--   <a>throwing</a> l ≡ <a>reviews</a> l <a>throwError</a>
--   </pre>
--   
--   <pre>
--   <a>throwing</a> :: <a>MonadError</a> e m =&gt; <a>Prism'</a> e t -&gt; t -&gt; a
--   <a>throwing</a> :: <a>MonadError</a> e m =&gt; <a>Iso'</a> e t   -&gt; t -&gt; a
--   </pre>
throwing :: MonadError e m => AReview e e t t -> t -> m x
instance Handleable e m (Handler e m)
instance Monad m => Monoid (Handler e m a)
instance Monad m => Plus (Handler e m)
instance Monad m => Alt (Handler e m)
instance Monad m => Semigroup (Handler e m a)
instance Monad m => Functor (Handler e m)


-- | A <a>Lens</a> or <a>Traversal</a> can be used to take the role of
--   <a>Traversable</a> in <tt>Control.Parallel.Strategies</tt>, enabling
--   those combinators to work with monomorphic containers.
module Control.Parallel.Strategies.Lens

-- | Evaluate the targets of a <a>Lens</a> or <a>Traversal</a> into a data
--   structure according to the given <a>Strategy</a>.
--   
--   <pre>
--   <a>evalTraversable</a> = <a>evalOf</a> <a>traverse</a> = <a>traverse</a>
--   <a>evalOf</a> = <a>id</a>
--   </pre>
--   
--   <pre>
--   <a>evalOf</a> :: <a>Lens'</a> s a -&gt; <a>Strategy</a> a -&gt; <a>Strategy</a> s
--   <a>evalOf</a> :: <a>Traversal'</a> s a -&gt; <a>Strategy</a> a -&gt; <a>Strategy</a> s
--   <a>evalOf</a> :: (a -&gt; <a>Eval</a> a) -&gt; s -&gt; <a>Eval</a> s) -&gt; <a>Strategy</a> a -&gt; <a>Strategy</a> s
--   </pre>
evalOf :: LensLike' Eval s a -> Strategy a -> Strategy s

-- | Evaluate the targets of a <a>Lens</a> or <a>Traversal</a> according
--   into a data structure according to a given <a>Strategy</a> in
--   parallel.
--   
--   <pre>
--   <a>parTraversable</a> = <a>parOf</a> <a>traverse</a>
--   </pre>
--   
--   <pre>
--   <a>parOf</a> :: <a>Lens'</a> s a -&gt; <a>Strategy</a> a -&gt; <a>Strategy</a> s
--   <a>parOf</a> :: <a>Traversal'</a> s a -&gt; <a>Strategy</a> a -&gt; <a>Strategy</a> s
--   <a>parOf</a> :: ((a -&gt; <a>Eval</a> a) -&gt; s -&gt; <a>Eval</a> s) -&gt; <a>Strategy</a> a -&gt; <a>Strategy</a> s
--   </pre>
parOf :: LensLike' Eval s a -> Strategy a -> Strategy s

-- | Transform a <a>Lens</a>, <a>Fold</a>, <a>Getter</a>, <a>Setter</a> or
--   <a>Traversal</a> to first evaluates its argument according to a given
--   <a>Strategy</a> <i>before</i> proceeding.
--   
--   <pre>
--   <a>after</a> <a>rdeepseq</a> <a>traverse</a> :: <a>Traversable</a> t =&gt; <a>Strategy</a> a -&gt; <a>Strategy</a> [a]
--   </pre>
after :: Strategy s -> LensLike f s t a b -> LensLike f s t a b

-- | Transform a <a>Lens</a>, <a>Fold</a>, <a>Getter</a>, <a>Setter</a> or
--   <a>Traversal</a> to evaluate its argument according to a given
--   <a>Strategy</a> <i>in parallel with</i> evaluating.
--   
--   <pre>
--   <a>throughout</a> <a>rdeepseq</a> <a>traverse</a> :: <a>Traversable</a> t =&gt; <a>Strategy</a> a -&gt; <a>Strategy</a> [a]
--   </pre>
throughout :: Strategy s -> LensLike f s t a b -> LensLike f s t a b


-- | A <a>Fold</a> can be used to take the role of <tt>Foldable</tt> in
--   <tt>Control.Seq</tt>.
module Control.Seq.Lens

-- | Evaluate the elements targeted by a <a>Lens</a>, <a>Traversal</a>,
--   <a>Iso</a>, <a>Getter</a> or <a>Fold</a> according to the given
--   strategy.
--   
--   <pre>
--   <a>seqFoldable</a> = <a>seqOf</a> <a>folded</a>
--   </pre>
seqOf :: Getting (Endo [a]) s a -> Strategy a -> Strategy s


module Data.Array.Lens

-- | This <tt>setter</tt> can be used to derive a new <a>IArray</a> from an
--   old <tt>IAarray</tt> by applying a function to each of the indices to
--   look it up in the old <a>IArray</a>.
--   
--   This is a <i>contravariant</i> <a>Setter</a>.
--   
--   <pre>
--   <a>ixmap</a> ≡ <a>over</a> <a>.</a> <a>ixmapped</a>
--   <a>ixmapped</a> ≡ <a>setting</a> <a>.</a> <a>ixmap</a>
--   <a>over</a> (<a>ixmapped</a> b) f arr <a>!</a> i ≡ arr <a>!</a> f i
--   <a>bounds</a> (<a>over</a> (<a>ixmapped</a> b) f arr) ≡ b
--   </pre>
ixmapped :: (IArray a e, Ix i, Ix j) => (i, i) -> IndexPreservingSetter (a j e) (a i e) i j


module Data.Bits.Lens

-- | Bitwise <a>.|.</a> the target(s) of a <a>Lens</a> or <a>Setter</a>.
--   
--   <pre>
--   &gt;&gt;&gt; _2 .|.~ 6 $ ("hello",3)
--   ("hello",7)
--   </pre>
--   
--   <pre>
--   (<a>.|.~</a>) :: <a>Bits</a> a             =&gt; <a>Setter</a> s t a a    -&gt; a -&gt; s -&gt; t
--   (<a>.|.~</a>) :: <a>Bits</a> a             =&gt; <a>Iso</a> s t a a       -&gt; a -&gt; s -&gt; t
--   (<a>.|.~</a>) :: <a>Bits</a> a             =&gt; <a>Lens</a> s t a a      -&gt; a -&gt; s -&gt; t
--   (<a>.|.~</a>) :: (<a>Monoid</a> a, <a>Bits</a> a) =&gt; <a>Traversal</a> s t a a -&gt; a -&gt; s -&gt; t
--   </pre>
(.|.~) :: Bits a => ASetter s t a a -> a -> s -> t

-- | Bitwise <a>.&amp;.</a> the target(s) of a <a>Lens</a> or
--   <a>Setter</a>.
--   
--   <pre>
--   &gt;&gt;&gt; _2 .&amp;.~ 7 $ ("hello",254)
--   ("hello",6)
--   </pre>
--   
--   <pre>
--   (<a>.&amp;.~</a>) :: <a>Bits</a> a             =&gt; <a>Setter</a> s t a a    -&gt; a -&gt; s -&gt; t
--   (<a>.&amp;.~</a>) :: <a>Bits</a> a             =&gt; <a>Iso</a> s t a a       -&gt; a -&gt; s -&gt; t
--   (<a>.&amp;.~</a>) :: <a>Bits</a> a             =&gt; <a>Lens</a> s t a a      -&gt; a -&gt; s -&gt; t
--   (<a>.&amp;.~</a>) :: (<a>Monoid</a> a, <a>Bits</a> a) =&gt; <a>Traversal</a> s t a a -&gt; a -&gt; s -&gt; t
--   </pre>
(.&.~) :: Bits a => ASetter s t a a -> a -> s -> t

-- | Bitwise <a>.|.</a> the target(s) of a <a>Lens</a> (or
--   <a>Traversal</a>), returning the result (or a monoidal summary of all
--   of the results).
--   
--   <pre>
--   &gt;&gt;&gt; _2 &lt;.|.~ 6 $ ("hello",3)
--   (7,("hello",7))
--   </pre>
--   
--   <pre>
--   (<a>&lt;.|.~</a>) :: <a>Bits</a> a             =&gt; <a>Iso</a> s t a a       -&gt; a -&gt; s -&gt; (a, t)
--   (<a>&lt;.|.~</a>) :: <a>Bits</a> a             =&gt; <a>Lens</a> s t a a      -&gt; a -&gt; s -&gt; (a, t)
--   (<a>&lt;.|.~</a>) :: (<a>Bits</a> a, <a>Monoid</a> a) =&gt; <a>Traversal</a> s t a a -&gt; a -&gt; s -&gt; (a, t)
--   </pre>
(<.|.~) :: Bits a => LensLike ((,) a) s t a a -> a -> s -> (a, t)

-- | Bitwise <a>.&amp;.</a> the target(s) of a <a>Lens</a> or
--   <a>Traversal</a>, returning the result (or a monoidal summary of all
--   of the results).
--   
--   <pre>
--   &gt;&gt;&gt; _2 &lt;.&amp;.~ 7 $ ("hello",254)
--   (6,("hello",6))
--   </pre>
--   
--   <pre>
--   (<a>&lt;.&amp;.~</a>) :: <a>Bits</a> a             =&gt; <a>Iso</a>       s t a a -&gt; a -&gt; s -&gt; (a, t)
--   (<a>&lt;.&amp;.~</a>) :: <a>Bits</a> a             =&gt; <a>Lens</a>      s t a a -&gt; a -&gt; s -&gt; (a, t)
--   (<a>&lt;.&amp;.~</a>) :: (<a>Bits</a> a, <a>Monoid</a> a) =&gt; <a>Traversal</a> s t a a -&gt; a -&gt; s -&gt; (a, t)
--   </pre>
(<.&.~) :: Bits a => LensLike ((,) a) s t a a -> a -> s -> (a, t)

-- | Modify the target(s) of a <a>Lens'</a>, <a>Setter</a> or
--   <a>Traversal</a> by computing its bitwise <a>.|.</a> with another
--   value.
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 .|.= 15; _2 .|.= 3) (7,7)
--   (15,7)
--   </pre>
--   
--   <pre>
--   (<a>.|.=</a>) :: (<a>MonadState</a> s m, <a>Bits</a> a) =&gt; <a>Setter'</a> s a    -&gt; a -&gt; m ()
--   (<a>.|.=</a>) :: (<a>MonadState</a> s m, <a>Bits</a> a) =&gt; <a>Iso'</a> s a       -&gt; a -&gt; m ()
--   (<a>.|.=</a>) :: (<a>MonadState</a> s m, <a>Bits</a> a) =&gt; <a>Lens'</a> s a      -&gt; a -&gt; m ()
--   (<a>.|.=</a>) :: (<a>MonadState</a> s m, <a>Bits</a> a) =&gt; <a>Traversal'</a> s a -&gt; a -&gt; m ()
--   </pre>
(.|.=) :: (MonadState s m, Bits a) => ASetter' s a -> a -> m ()

-- | Modify the target(s) of a <a>Lens'</a>, <a>Setter'</a> or
--   <a>Traversal'</a> by computing its bitwise <a>.&amp;.</a> with another
--   value.
--   
--   <pre>
--   &gt;&gt;&gt; execState (do _1 .&amp;.= 15; _2 .&amp;.= 3) (7,7)
--   (7,3)
--   </pre>
--   
--   <pre>
--   (<a>.&amp;.=</a>) :: (<a>MonadState</a> s m, <a>Bits</a> a) =&gt; <a>Setter'</a> s a    -&gt; a -&gt; m ()
--   (<a>.&amp;.=</a>) :: (<a>MonadState</a> s m, <a>Bits</a> a) =&gt; <a>Iso'</a> s a       -&gt; a -&gt; m ()
--   (<a>.&amp;.=</a>) :: (<a>MonadState</a> s m, <a>Bits</a> a) =&gt; <a>Lens'</a> s a      -&gt; a -&gt; m ()
--   (<a>.&amp;.=</a>) :: (<a>MonadState</a> s m, <a>Bits</a> a) =&gt; <a>Traversal'</a> s a -&gt; a -&gt; m ()
--   </pre>
(.&.=) :: (MonadState s m, Bits a) => ASetter' s a -> a -> m ()

-- | Modify the target(s) of a <a>Lens'</a>, (or <a>Traversal</a>) by
--   computing its bitwise <a>.|.</a> with another value, returning the
--   result (or a monoidal summary of all of the results traversed).
--   
--   <pre>
--   &gt;&gt;&gt; runState (_1 &lt;.|.= 7) (28,0)
--   (31,(31,0))
--   </pre>
--   
--   <pre>
--   (<a>&lt;.|.=</a>) :: (<a>MonadState</a> s m, <a>Bits</a> a)           =&gt; <a>Lens'</a> s a      -&gt; a -&gt; m a
--   (<a>&lt;.|.=</a>) :: (<a>MonadState</a> s m, <a>Bits</a> a, <a>Monoid</a> a) =&gt; <a>Traversal'</a> s a -&gt; a -&gt; m a
--   </pre>
(<.|.=) :: (MonadState s m, Bits a) => LensLike' ((,) a) s a -> a -> m a

-- | Modify the target(s) of a <a>Lens'</a> (or <a>Traversal'</a>) by
--   computing its bitwise <a>.&amp;.</a> with another value, returning the
--   result (or a monoidal summary of all of the results traversed).
--   
--   <pre>
--   &gt;&gt;&gt; runState (_1 &lt;.&amp;.= 15) (31,0)
--   (15,(15,0))
--   </pre>
--   
--   <pre>
--   (<a>&lt;.&amp;.=</a>) :: (<a>MonadState</a> s m, <a>Bits</a> a)           =&gt; <a>Lens'</a> s a      -&gt; a -&gt; m a
--   (<a>&lt;.&amp;.=</a>) :: (<a>MonadState</a> s m, <a>Bits</a> a, <a>Monoid</a> a) =&gt; <a>Traversal'</a> s a -&gt; a -&gt; m a
--   </pre>
(<.&.=) :: (MonadState s m, Bits a) => LensLike' ((,) a) s a -> a -> m a

-- | This <a>Lens</a> can be used to access the value of the nth bit in a
--   number.
--   
--   <tt><a>bitAt</a> n</tt> is only a legal <a>Lens</a> into <tt>b</tt> if
--   <tt>0 <a>&lt;=</a> n <a>&lt;</a> <a>bitSize</a> (<a>undefined</a> ::
--   b)</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; 16^.bitAt 4
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; 15^.bitAt 4
--   False
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; 15 &amp; bitAt 4 .~ True
--   31
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; 16 &amp; bitAt 4 .~ False
--   0
--   </pre>
bitAt :: Bits b => Int -> IndexedLens' Int b Bool

-- | Traverse over all bits in a numeric type.
--   
--   The bit position is available as the index.
--   
--   <pre>
--   &gt;&gt;&gt; toListOf bits (5 :: Word8)
--   [True,False,True,False,False,False,False,False]
--   </pre>
--   
--   If you supply this an <a>Integer</a>, the result will be an infinite
--   <a>Traversal</a>, which can be productively consumed, but not
--   reassembled.
bits :: (Num b, Bits b) => IndexedTraversal' Int b Bool

-- | Get the nth byte, counting from the low end.
--   
--   <tt><a>byteAt</a> n</tt> is a legal <a>Lens</a> into <tt>b</tt> iff
--   <tt>0 <a>&lt;=</a> n <a>&lt;</a> <a>div</a> (<a>bitSize</a>
--   (<a>undefined</a> :: b)) 8</tt>
--   
--   <pre>
--   &gt;&gt;&gt; (0xff00 :: Word16)^.byteAt 0
--   0
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (0xff00 :: Word16)^.byteAt 1
--   255
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; byteAt 1 .~ 0 $ 0xff00 :: Word16
--   0
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; byteAt 0 .~ 0xff $ 0 :: Word16
--   255
--   </pre>
byteAt :: (Integral b, Bits b) => Int -> IndexedLens' Int b Word8


module Data.ByteString.Strict.Lens

-- | <a>pack</a> (or <a>unpack</a>) a list of bytes into a
--   <a>ByteString</a>
--   
--   <pre>
--   <a>packedBytes</a> ≡ <a>from</a> <a>unpackedBytes</a>
--   <a>pack</a> x ≡  x <a>^.</a> <a>packedBytes</a>
--   <a>unpack</a> x ≡ x <a>^.</a> <a>from</a> <a>packedBytes</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [104,101,108,108,111]^.packedBytes
--   "hello"
--   </pre>
packedBytes :: Iso' [Word8] ByteString

-- | <a>unpack</a> (or <a>pack</a>) a <a>ByteString</a> into a list of
--   bytes
--   
--   <pre>
--   <a>unpackedBytes</a> ≡ <a>from</a> <a>packedBytes</a>
--   <a>unpack</a> x ≡ x <a>^.</a> <a>unpackedBytes</a>
--   <a>pack</a> x ≡  x <a>^.</a> <a>from</a> <a>unpackedBytes</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "hello"^.packedChars.unpackedBytes
--   [104,101,108,108,111]
--   </pre>
unpackedBytes :: Iso' ByteString [Word8]

-- | Traverse each <a>Word8</a> in a <a>ByteString</a>.
--   
--   This <a>Traversal</a> walks the <a>ByteString</a> in a tree-like
--   fashion enable zippers to seek to locations in logarithmic time and
--   accelerating many monoidal queries, but up to associativity (and
--   constant factors) it is equivalent to the much slower:
--   
--   <pre>
--   <a>bytes</a> ≡ <a>unpackedBytes</a> <a>.</a> <a>traversed</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; anyOf bytes (== 0x80) (Char8.pack "hello")
--   False
--   </pre>
bytes :: IndexedTraversal' Int ByteString Word8

-- | <a>pack</a> (or <a>unpack</a>) a list of characters into a
--   <a>ByteString</a>
--   
--   When writing back to the <a>ByteString</a> it is assumed that every
--   <a>Char</a> lies between <tt>'\x00'</tt> and <tt>'\xff'</tt>.
--   
--   <pre>
--   <a>packedChars</a> ≡ <a>from</a> <a>unpackedChars</a>
--   <a>pack</a> x ≡ x <a>^.</a> <a>packedChars</a>
--   <a>unpack</a> x ≡ x <a>^.</a> <a>from</a> <a>packedChars</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "hello"^.packedChars.each.re (base 16 . enum).to (\x -&gt; if Prelude.length x == 1 then '0':x else x)
--   "68656c6c6f"
--   </pre>
packedChars :: Iso' String ByteString

-- | <a>unpack</a> (or <a>pack</a>) a list of characters into a
--   <a>ByteString</a>
--   
--   When writing back to the <a>ByteString</a> it is assumed that every
--   <a>Char</a> lies between <tt>'\x00'</tt> and <tt>'\xff'</tt>.
--   
--   <pre>
--   <a>unpackedChars</a> ≡ <a>from</a> <a>packedChars</a>
--   <a>unpack</a> x ≡ x <a>^.</a> <a>unpackedChars</a>
--   <a>pack</a> x ≡ x <a>^.</a> <a>from</a> <a>unpackedChars</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [104,101,108,108,111]^.packedBytes.unpackedChars
--   "hello"
--   </pre>
unpackedChars :: Iso' ByteString String

-- | Traverse the individual bytes in a <a>ByteString</a> as characters.
--   
--   When writing back to the <a>ByteString</a> it is assumed that every
--   <a>Char</a> lies between <tt>'\x00'</tt> and <tt>'\xff'</tt>.
--   
--   This <a>Traversal</a> walks the <a>ByteString</a> in a tree-like
--   fashion enable zippers to seek to locations in logarithmic time and
--   accelerating many monoidal queries, but up to associativity (and
--   constant factors) it is equivalent to the much slower:
--   
--   <pre>
--   <a>chars</a> = <a>unpackedChars</a> <a>.</a> <a>traverse</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; anyOf chars (== 'h') "hello"
--   True
--   </pre>
chars :: IndexedTraversal' Int ByteString Char


-- | Lazy <a>ByteString</a> lenses.
module Data.ByteString.Lazy.Lens

-- | <a>pack</a> (or <a>unpack</a>) a list of bytes into a
--   <a>ByteString</a>.
--   
--   <pre>
--   <a>packedBytes</a> ≡ <a>from</a> <a>unpackedBytes</a>
--   <a>pack</a> x ≡  x <a>^.</a> <a>packedBytes</a>
--   <a>unpack</a> x ≡ x <a>^.</a> <a>from</a> <a>packedBytes</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [104,101,108,108,111]^.packedBytes == Char8.pack "hello"
--   True
--   </pre>
packedBytes :: Iso' [Word8] ByteString

-- | <a>unpack</a> (or <a>pack</a>) a <a>ByteString</a> into a list of
--   bytes
--   
--   <pre>
--   <a>unpackedBytes</a> ≡ <a>from</a> <a>packedBytes</a>
--   <a>unpack</a> x ≡ x <a>^.</a> <a>unpackedBytes</a>
--   <a>pack</a> x ≡  x <a>^.</a> <a>from</a> <a>unpackedBytes</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "hello"^.packedChars.unpackedBytes
--   [104,101,108,108,111]
--   </pre>
unpackedBytes :: Iso' ByteString [Word8]

-- | Traverse the individual bytes in a <a>ByteString</a>.
--   
--   This <a>Traversal</a> walks each strict <a>ByteString</a> chunk in a
--   tree-like fashion enable zippers to seek to locations more quickly and
--   accelerate many monoidal queries, but up to associativity (and
--   constant factors) it is equivalent to the much slower:
--   
--   <pre>
--   <a>bytes</a> ≡ <a>unpackedBytes</a> <a>.</a> <a>traversed</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; anyOf bytes (== 0x80) (Char8.pack "hello")
--   False
--   </pre>
bytes :: IndexedTraversal' Int64 ByteString Word8

-- | <a>pack</a> (or <a>unpack</a>) a list of characters into a
--   <a>ByteString</a>.
--   
--   When writing back to the <a>ByteString</a> it is assumed that every
--   <a>Char</a> lies between <tt>'\x00'</tt> and <tt>'\xff'</tt>.
--   
--   <pre>
--   <a>packedChars</a> ≡ <a>from</a> <a>unpackedChars</a>
--   <a>pack</a> x ≡ x <a>^.</a> <a>packedChars</a>
--   <a>unpack</a> x ≡ x <a>^.</a> <a>from</a> <a>packedChars</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "hello"^.packedChars.each.re (base 16 . enum).to (\x -&gt; if Prelude.length x == 1 then '0':x else x)
--   "68656c6c6f"
--   </pre>
packedChars :: Iso' String ByteString

-- | <a>unpack</a> (or <a>pack</a>) a list of characters into a
--   <a>ByteString</a>
--   
--   When writing back to the <a>ByteString</a> it is assumed that every
--   <a>Char</a> lies between <tt>'\x00'</tt> and <tt>'\xff'</tt>.
--   
--   <pre>
--   <a>unpackedChars</a> ≡ <a>from</a> <a>packedChars</a>
--   <a>unpack</a> x ≡ x <a>^.</a> <a>unpackedChars</a>
--   <a>pack</a> x ≡ x <a>^.</a> <a>from</a> <a>unpackedChars</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [104,101,108,108,111]^.packedBytes.unpackedChars
--   "hello"
--   </pre>
unpackedChars :: Iso' ByteString String

-- | Traverse the individual bytes in a <a>ByteString</a> as characters.
--   
--   When writing back to the <a>ByteString</a> it is assumed that every
--   <a>Char</a> lies between <tt>'\x00'</tt> and <tt>'\xff'</tt>.
--   
--   This <a>Traversal</a> walks each strict <a>ByteString</a> chunk in a
--   tree-like fashion enable zippers to seek to locations more quickly and
--   accelerate many monoidal queries, but up to associativity (and
--   constant factors) it is equivalent to:
--   
--   <pre>
--   <a>chars</a> = <a>unpackedChars</a> <a>.</a> <a>traversed</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; anyOf chars (== 'h') "hello"
--   True
--   </pre>
chars :: IndexedTraversal' Int64 ByteString Char


module Data.ByteString.Lens

-- | Traversals for ByteStrings.
class IsByteString t where bytes = from packedBytes . traversed chars = from packedChars . traversed
packedBytes :: IsByteString t => Iso' [Word8] t
packedChars :: IsByteString t => Iso' String t
bytes :: IsByteString t => IndexedTraversal' Int t Word8
chars :: IsByteString t => IndexedTraversal' Int t Char

-- | <a>unpack</a> (or <a>pack</a>) a <a>ByteString</a> into a list of
--   bytes
--   
--   <pre>
--   <a>unpackedBytes</a> ≡ <a>from</a> <a>packedBytes</a>
--   <a>unpack</a> x ≡ x <a>^.</a> <a>unpackedBytes</a>
--   <a>pack</a> x ≡  x <a>^.</a> <a>from</a> <a>unpackedBytes</a>
--   </pre>
--   
--   <pre>
--   <a>unpackedBytes</a> :: <a>Iso'</a> <a>ByteString</a> [<a>Word8</a>]
--   <a>unpackedBytes</a> :: <a>Iso'</a> <a>ByteString</a> [<a>Word8</a>]
--   </pre>
unpackedBytes :: IsByteString t => Iso' t [Word8]

-- | <a>unpack</a> (or <a>pack</a>) a list of characters into a strict (or
--   lazy) <a>ByteString</a>
--   
--   When writing back to the <a>ByteString</a> it is assumed that every
--   <a>Char</a> lies between <tt>'\x00'</tt> and <tt>'\xff'</tt>.
--   
--   <pre>
--   <a>unpackedChars</a> ≡ <a>from</a> <a>packedChars</a>
--   <a>unpack</a> x ≡ x <a>^.</a> <a>unpackedChars</a>
--   <a>pack</a> x ≡ x <a>^.</a> <a>from</a> <a>unpackedChars</a>
--   </pre>
--   
--   <pre>
--   <a>unpackedChars</a> :: <a>Iso'</a> <a>ByteString</a> <a>String</a>
--   <a>unpackedChars</a> :: <a>Iso'</a> <a>ByteString</a> <a>String</a>
--   </pre>
unpackedChars :: IsByteString t => Iso' t String
instance IsByteString ByteString
instance IsByteString ByteString


-- | Lenses and traversals for complex numbers
module Data.Complex.Lens

-- | Access the <a>realPart</a> of a <a>Complex</a> number.
--   
--   <pre>
--   &gt;&gt;&gt; (a :+ b)^._realPart
--   a
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; a :+ b &amp; _realPart *~ 2
--   a * 2 :+ b
--   </pre>
--   
--   <pre>
--   <a>_realPart</a> :: <a>Functor</a> f =&gt; (a -&gt; f a) -&gt; <a>Complex</a> a -&gt; f (<a>Complex</a> a)
--   </pre>
_realPart :: Lens' (Complex a) a

-- | Access the <a>imagPart</a> of a <a>Complex</a> number.
--   
--   <pre>
--   &gt;&gt;&gt; (a :+ b)^._imagPart
--   b
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; a :+ b &amp; _imagPart *~ 2
--   a :+ b * 2
--   </pre>
--   
--   <pre>
--   <a>_imagPart</a> :: <a>Functor</a> f =&gt; (a -&gt; f a) -&gt; <a>Complex</a> a -&gt; f (<a>Complex</a> a)
--   </pre>
_imagPart :: Lens' (Complex a) a

-- | This isn't <i>quite</i> a legal <a>Lens</a>. Notably the
--   
--   <pre>
--   <a>view</a> l (<a>set</a> l b a) = b
--   </pre>
--   
--   law is violated when you set a <a>polar</a> value with 0
--   <a>magnitude</a> and non-zero <a>phase</a> as the <a>phase</a>
--   information is lost, or with a negative <a>magnitude</a> which flips
--   the <a>phase</a> and retains a positive <a>magnitude</a>. So don't do
--   that!
--   
--   Otherwise, this is a perfectly cromulent <a>Lens</a>.
_polar :: RealFloat a => Iso' (Complex a) (a, a)

-- | Access the <a>magnitude</a> of a <a>Complex</a> number.
--   
--   <pre>
--   &gt;&gt;&gt; (10.0 :+ 20.0) &amp; _magnitude *~ 2
--   20.0 :+ 40.0
--   </pre>
--   
--   This isn't <i>quite</i> a legal <a>Lens</a>. Notably the
--   
--   <pre>
--   <a>view</a> l (<a>set</a> l b a) = b
--   </pre>
--   
--   law is violated when you set a negative <a>magnitude</a>. This flips
--   the <a>phase</a> and retains a positive <a>magnitude</a>. So don't do
--   that!
--   
--   Otherwise, this is a perfectly cromulent <a>Lens</a>.
--   
--   Setting the <a>magnitude</a> of a zero <a>Complex</a> number assumes
--   the <a>phase</a> is 0.
_magnitude :: RealFloat a => Lens' (Complex a) a

-- | Access the <a>phase</a> of a <a>Complex</a> number.
--   
--   <pre>
--   &gt;&gt;&gt; (mkPolar 10 (2-pi) &amp; _phase +~ pi &amp; view _phase) ~~ 2
--   True
--   </pre>
--   
--   This isn't <i>quite</i> a legal <a>Lens</a>. Notably the
--   
--   <pre>
--   <a>view</a> l (<a>set</a> l b a) = b
--   </pre>
--   
--   law is violated when you set a <a>phase</a> outside the range
--   <tt>(-<a>pi</a>, <a>pi</a>]</tt>. The phase is always in that range
--   when queried. So don't do that!
--   
--   Otherwise, this is a perfectly cromulent <a>Lens</a>.
_phase :: RealFloat a => Lens' (Complex a) a

-- | Access the <a>conjugate</a> of a <a>Complex</a> number.
--   
--   <pre>
--   &gt;&gt;&gt; (2.0 :+ 3.0) &amp; _conjugate . _imagPart -~ 1
--   2.0 :+ 4.0
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (mkPolar 10.0 2.0 ^. _conjugate . _phase) ~~ (-2.0)
--   True
--   </pre>
_conjugate :: RealFloat a => Iso' (Complex a) (Complex a)


module Data.Dynamic.Lens

-- | Any <a>Dynamic</a> can be thrown as an <a>Exception</a>
class AsDynamic t
_Dynamic :: (AsDynamic t, Typeable a) => Prism' t a
instance AsDynamic SomeException
instance AsDynamic Dynamic


module Data.IntSet.Lens

-- | IntSet isn't Foldable, but this <a>Fold</a> can be used to access the
--   members of an <a>IntSet</a>.
--   
--   <pre>
--   &gt;&gt;&gt; sumOf members $ setOf folded [1,2,3,4]
--   10
--   </pre>
members :: Fold IntSet Int

-- | This <a>Setter</a> can be used to change the contents of an
--   <a>IntSet</a> by mapping the elements to new values.
--   
--   Sadly, you can't create a valid <a>Traversal</a> for a <tt>Set</tt>,
--   because the number of elements might change but you can manipulate it
--   by reading using <a>folded</a> and reindexing it via <a>setmapped</a>.
--   
--   <pre>
--   &gt;&gt;&gt; over setmapped (+1) (fromList [1,2,3,4])
--   fromList [2,3,4,5]
--   </pre>
setmapped :: IndexPreservingSetter' IntSet Int

-- | Construct an <a>IntSet</a> from a <a>Getter</a>, <a>Fold</a>,
--   <a>Traversal</a>, <a>Lens</a> or <a>Iso</a>.
--   
--   <pre>
--   &gt;&gt;&gt; setOf folded [1,2,3,4]
--   fromList [1,2,3,4]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; setOf (folded._2) [("hello",1),("world",2),("!!!",3)]
--   fromList [1,2,3]
--   </pre>
--   
--   <pre>
--   <a>setOf</a> :: <a>Getter</a> s <a>Int</a>     -&gt; s -&gt; <a>IntSet</a>
--   <a>setOf</a> :: <a>Fold</a> s <a>Int</a>       -&gt; s -&gt; <a>IntSet</a>
--   <a>setOf</a> :: <a>Iso'</a> s <a>Int</a>       -&gt; s -&gt; <a>IntSet</a>
--   <a>setOf</a> :: <a>Lens'</a> s <a>Int</a>      -&gt; s -&gt; <a>IntSet</a>
--   <a>setOf</a> :: <a>Traversal'</a> s <a>Int</a> -&gt; s -&gt; <a>IntSet</a>
--   </pre>
setOf :: Getting IntSet s Int -> s -> IntSet


-- | Traversals for manipulating parts of a list.
module Data.List.Lens

-- | A <a>Prism</a> stripping a prefix from a list when used as a
--   <a>Traversal</a>, or prepending that prefix when run backwards:
--   
--   <pre>
--   &gt;&gt;&gt; "preview" ^? prefixed "pre"
--   Just "view"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "review" ^? prefixed "pre"
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; prefixed "pre" # "amble"
--   "preamble"
--   </pre>
prefixed :: Eq a => [a] -> Prism' [a] [a]

-- | A <a>Prism</a> stripping a suffix from a list when used as a
--   <a>Traversal</a>, or prepending that prefix when run backwards:
--   
--   <pre>
--   &gt;&gt;&gt; "review" ^? suffixed "view"
--   Just "re"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "review" ^? suffixed "tire"
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; suffixed ".o" # "hello"
--   "hello.o"
--   </pre>
suffixed :: Eq a => [a] -> Prism' [a] [a]
stripSuffix :: Eq a => [a] -> [a] -> Maybe [a]

-- | This is a deprecated alias for <a>prefixed</a>.

-- | <i>Deprecated: Use <a>prefixed</a>. </i>
strippingPrefix :: Eq a => [a] -> Prism' [a] [a]

-- | This is a deprecated alias for <a>suffixed</a>.

-- | <i>Deprecated: Use <a>suffixed</a>. </i>
strippingSuffix :: Eq a => [a] -> Prism' [a] [a]


-- | Lenses for working with Data.List.Split
module Data.List.Split.Lens

-- | Obtain a <a>Fold</a> by splitting another <a>Fold</a>, <a>Lens</a>,
--   <a>Getter</a> or <a>Traversal</a> according to the given splitting
--   strategy.
--   
--   <pre>
--   <a>splitting</a> :: <a>Splitter</a> a -&gt; <a>Fold</a> s a -&gt; <a>Fold</a> s [a]
--   </pre>
splitting :: Splitter a -> Getting (Endo [a]) s a -> Fold s [a]

-- | Obtain a <a>Fold</a> by splitting another <a>Fold</a>, <a>Lens</a>,
--   <a>Getter</a> or <a>Traversal</a> on the given delimiter.
--   
--   Equivalent to <tt><a>splitting</a> <a>.</a> <a>dropDelims</a> <a>.</a>
--   <a>onSublist</a></tt>.
--   
--   <pre>
--   <a>splittingOn</a> :: <a>Eq</a> a =&gt; [a] -&gt; <a>Fold</a> s a -&gt; <a>Fold</a> s [a]
--   </pre>
splittingOn :: Eq a => [a] -> Getting (Endo [a]) s a -> Fold s [a]

-- | Obtain a <a>Fold</a> by splitting another <a>Fold</a>, <a>Lens</a>,
--   <a>Getter</a> or <a>Traversal</a> on any of the given elements.
--   
--   Equivalent to <tt><a>splitting</a> <a>.</a> <a>dropDelims</a> <a>.</a>
--   <a>oneOf</a></tt>.
--   
--   <pre>
--   <a>splittingOn</a> :: <a>Eq</a> a =&gt; [a] -&gt; <a>Fold</a> s a -&gt; <a>Fold</a> s [a]
--   </pre>
splittingOneOf :: Eq a => [a] -> Getting (Endo [a]) s a -> Fold s [a]

-- | Obtain a <a>Fold</a> by splitting another <a>Fold</a>, <a>Lens</a>,
--   <a>Getter</a> or <a>Traversal</a> on elements satisfying the given
--   predicate.
--   
--   Equivalent to <tt><a>splitting</a> <a>.</a> <a>dropDelims</a> <a>.</a>
--   <a>whenElt</a></tt>.
--   
--   <pre>
--   <a>splittingWhen</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>Fold</a> s a -&gt; <a>Fold</a> s [a]
--   </pre>
splittingWhen :: (a -> Bool) -> Getting (Endo [a]) s a -> Fold s [a]

-- | Obtain a <a>Fold</a> by splitting another <a>Fold</a>, <a>Lens</a>,
--   <a>Getter</a> or <a>Traversal</a> into chunks terminated by the given
--   delimiter.
--   
--   Equivalent to <tt><a>splitting</a> <a>.</a> <a>dropDelims</a> <a>.</a>
--   <a>onSublist</a></tt>.
--   
--   <pre>
--   <a>endingBy</a> :: <a>Eq</a> a =&gt; [a] -&gt; <a>Fold</a> s a -&gt; <a>Fold</a> s [a]
--   </pre>
endingBy :: Eq a => [a] -> Getting (Endo [a]) s a -> Fold s [a]

-- | Obtain a <a>Fold</a> by splitting another <a>Fold</a>, <a>Lens</a>,
--   <a>Getter</a> or <a>Traversal</a> into chunks terminated by any of the
--   given elements.
--   
--   Equivalent to <tt><a>splitting</a> <a>.</a> <a>dropFinalBlank</a>
--   <a>.</a> <a>dropDelims</a> <a>.</a> <a>oneOf</a></tt>.
--   
--   <pre>
--   <a>endingByOneOf</a> :: <a>Eq</a> a =&gt; [a] -&gt; <a>Fold</a> s a -&gt; <a>Fold</a> s [a]
--   </pre>
endingByOneOf :: Eq a => [a] -> Getting (Endo [a]) s a -> Fold s [a]

-- | Obtain a <a>Fold</a> by splitting another <a>Fold</a>, <a>Lens</a>,
--   <a>Getter</a> or <a>Traversal</a> into <a>words</a>, with word
--   boundaries indicated by the given predicate.
--   
--   Equivalent to <tt><a>splitting</a> <a>.</a> <a>dropBlanks</a> <a>.</a>
--   <a>dropDelims</a> <a>.</a> <a>whenElt</a></tt>.
--   
--   <pre>
--   <a>wordingBy</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>Fold</a> s a -&gt; <a>Fold</a> s [a]
--   </pre>
wordingBy :: (a -> Bool) -> Getting (Endo [a]) s a -> Fold s [a]

-- | Obtain a <a>Fold</a> by splitting another <a>Fold</a>, <a>Lens</a>,
--   <a>Getter</a> or <a>Traversal</a> into <a>lines</a>, with line
--   boundaries indicated by the given predicate.
--   
--   Equivalent to <tt><a>splitting</a> <a>.</a> <a>dropFinalBlank</a>
--   <a>.</a> <a>dropDelims</a> <a>.</a> <a>whenElt</a></tt>.
--   
--   <pre>
--   <a>liningBy</a> :: (a -&gt; <a>Bool</a>) -&gt; <a>Fold</a> s a -&gt; <a>Fold</a> s [a]
--   </pre>
liningBy :: (a -> Bool) -> Getting (Endo [a]) s a -> Fold s [a]

-- | Obtain a <a>Fold</a> by splitting another <a>Fold</a>, <a>Lens</a>,
--   <a>Getter</a> or <a>Traversal</a> into length-<tt>n</tt> pieces.
--   
--   <pre>
--   <a>chunking</a> :: <a>Int</a> -&gt; <a>Fold</a> s a -&gt; <a>Fold</a> s [a]
--   </pre>
chunking :: Int -> Getting (Endo [a]) s a -> Fold s [a]

-- | Obtain a <a>Fold</a> by splitting another <a>Fold</a>, <a>Lens</a>,
--   <a>Getter</a> or <a>Traversal</a> into chunks of the given lengths, .
--   
--   <pre>
--   <a>splittingPlaces</a> :: <a>Integral</a> n =&gt; [n] -&gt; <a>Fold</a> s a -&gt; <a>Fold</a> s [a]
--   </pre>
splittingPlaces :: Integral n => [n] -> Getting (Endo [a]) s a -> Fold s [a]

-- | Obtain a <a>Fold</a> by splitting another <a>Fold</a>, <a>Lens</a>,
--   <a>Getter</a> or <a>Traversal</a> into chunks of the given lengths.
--   Unlike <a>splittingPlaces</a>, the output <a>Fold</a> will always be
--   the same length as the first input argument.
--   
--   <pre>
--   <a>splittingPlacesBlanks</a> :: <a>Integral</a> n =&gt; [n] -&gt; <a>Fold</a> s a -&gt; <a>Fold</a> s [a]
--   </pre>
splittingPlacesBlanks :: Integral n => [n] -> Getting (Endo [a]) s a -> Fold s [a]

-- | Modify or retrieve the list of delimiters for a <a>Splitter</a>.
delimiters :: Lens (Splitter a) (Splitter b) [a -> Bool] [b -> Bool]

-- | Modify or retrieve the policy for what a <a>Splitter</a> to do with
--   delimiters.
delimiting :: Lens' (Splitter a) DelimPolicy

-- | Modify or retrieve the policy for what a <a>Splitter</a> should about
--   consecutive delimiters.
condensing :: Lens' (Splitter a) CondensePolicy

-- | Modify or retrieve the policy for whether a <a>Splitter</a> should
--   drop an initial blank.
keepInitialBlanks :: Lens' (Splitter a) Bool

-- | Modify or retrieve the policy for whether a <a>Splitter</a> should
--   drop a final blank.
keepFinalBlanks :: Lens' (Splitter a) Bool


module Data.Sequence.Lens

-- | A <a>Seq</a> is isomorphic to a <a>ViewL</a>
--   
--   <pre>
--   <a>viewl</a> m ≡ m <a>^.</a> <a>viewL</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Seq.fromList [a,b,c] ^. viewL
--   a :&lt; fromList [b,c]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Seq.empty ^. viewL
--   EmptyL
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; EmptyL ^. from viewL
--   fromList []
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; review viewL $ a :&lt; fromList [b,c]
--   fromList [a,b,c]
--   </pre>
viewL :: Iso (Seq a) (Seq b) (ViewL a) (ViewL b)

-- | A <a>Seq</a> is isomorphic to a <a>ViewR</a>
--   
--   <pre>
--   <a>viewr</a> m ≡ m <a>^.</a> <a>viewR</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Seq.fromList [a,b,c] ^. viewR
--   fromList [a,b] :&gt; c
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Seq.empty ^. viewR
--   EmptyR
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; EmptyR ^. from viewR
--   fromList []
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; review viewR $ fromList [a,b] :&gt; c
--   fromList [a,b,c]
--   </pre>
viewR :: Iso (Seq a) (Seq b) (ViewR a) (ViewR b)

-- | Traverse all the elements numbered from <tt>i</tt> to <tt>j</tt> of a
--   <a>Seq</a>
--   
--   <pre>
--   &gt;&gt;&gt; fromList [a,b,c,d,e] &amp; sliced 1 3 %~ f
--   fromList [a,f b,f c,d,e]
--   </pre>
sliced :: Int -> Int -> IndexedTraversal' Int (Seq a) a

-- | Traverse the first <tt>n</tt> elements of a <a>Seq</a>
--   
--   <pre>
--   &gt;&gt;&gt; fromList [a,b,c,d,e] ^.. slicedTo 2
--   [a,b]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; fromList [a,b,c,d,e] &amp; slicedTo 2 %~ f
--   fromList [f a,f b,c,d,e]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; fromList [a,b,c,d,e] &amp; slicedTo 10 .~ x
--   fromList [x,x,x,x,x]
--   </pre>
slicedTo :: Int -> IndexedTraversal' Int (Seq a) a

-- | Traverse all but the first <tt>n</tt> elements of a <a>Seq</a>
--   
--   <pre>
--   &gt;&gt;&gt; fromList [a,b,c,d,e] ^.. slicedFrom 2
--   [c,d,e]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; fromList [a,b,c,d,e] &amp; slicedFrom 2 %~ f
--   fromList [a,b,f c,f d,f e]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; fromList [a,b,c,d,e] &amp; slicedFrom 10 .~ x
--   fromList [a,b,c,d,e]
--   </pre>
slicedFrom :: Int -> IndexedTraversal' Int (Seq a) a


module Data.Text.Strict.Lens

-- | This isomorphism can be used to <a>pack</a> (or <a>unpack</a>) strict
--   <a>Text</a>.
--   
--   <pre>
--   &gt;&gt;&gt; "hello"^.packed -- :: Text
--   "hello"
--   </pre>
--   
--   <pre>
--   <a>pack</a> x ≡ x <a>^.</a> <a>packed</a>
--   <a>unpack</a> x ≡ x <a>^.</a> <a>from</a> <a>packed</a>
--   <a>packed</a> ≡ <a>from</a> <a>unpacked</a>
--   <a>packed</a> ≡ <a>iso</a> <a>pack</a> <a>unpack</a>
--   </pre>
packed :: Iso' String Text

-- | This isomorphism can be used to <a>unpack</a> (or <a>pack</a>) lazy
--   <a>Text</a>.
--   
--   <pre>
--   &gt;&gt;&gt; "hello"^.unpacked -- :: String
--   "hello"
--   </pre>
--   
--   This <a>Iso</a> is provided for notational convenience rather than out
--   of great need, since
--   
--   <pre>
--   <a>unpacked</a> ≡ <a>from</a> <a>packed</a>
--   </pre>
--   
--   <pre>
--   <a>pack</a> x ≡ x <a>^.</a> <a>from</a> <a>unpacked</a>
--   <a>unpack</a> x ≡ x <a>^.</a> <a>packed</a>
--   <a>unpacked</a> ≡ <a>iso</a> <a>unpack</a> <a>pack</a>
--   </pre>
unpacked :: Iso' Text String

-- | Convert between strict <a>Text</a> and <a>Builder</a> .
--   
--   <pre>
--   <a>fromText</a> x ≡ x <a>^.</a> <a>builder</a>
--   <a>toStrict</a> (<a>toLazyText</a> x) ≡ x <a>^.</a> <a>from</a> <a>builder</a>
--   </pre>
builder :: Iso' Text Builder

-- | Traverse the individual characters in strict <a>Text</a>.
--   
--   <pre>
--   &gt;&gt;&gt; anyOf text (=='o') "hello"
--   True
--   </pre>
--   
--   When the type is unambiguous, you can also use the more general
--   <a>each</a>.
--   
--   <pre>
--   <a>text</a> ≡ <a>unpacked</a> . <a>traversed</a>
--   <a>text</a> ≡ <a>each</a>
--   </pre>
text :: IndexedTraversal' Int Text Char


module Data.Text.Lazy.Lens

-- | This isomorphism can be used to <a>pack</a> (or <a>unpack</a>) lazy
--   <a>Text</a>.
--   
--   <pre>
--   &gt;&gt;&gt; "hello"^.packed -- :: Text
--   "hello"
--   </pre>
--   
--   <pre>
--   <a>pack</a> x ≡ x <a>^.</a> <a>packed</a>
--   <a>unpack</a> x ≡ x <a>^.</a> <a>from</a> <a>packed</a>
--   <a>packed</a> ≡ <a>from</a> <a>unpacked</a>
--   </pre>
packed :: Iso' String Text

-- | This isomorphism can be used to <a>unpack</a> (or <a>pack</a>) lazy
--   <a>Text</a>.
--   
--   <pre>
--   &gt;&gt;&gt; "hello"^.unpacked -- :: String
--   "hello"
--   </pre>
--   
--   <pre>
--   <a>pack</a> x ≡ x <a>^.</a> <a>from</a> <a>unpacked</a>
--   <a>unpack</a> x ≡ x <a>^.</a> <a>packed</a>
--   </pre>
--   
--   This <a>Iso</a> is provided for notational convenience rather than out
--   of great need, since
--   
--   <pre>
--   <a>unpacked</a> ≡ <a>from</a> <a>packed</a>
--   </pre>
unpacked :: Iso' Text String

-- | Traverse the individual characters in a <a>Text</a>.
--   
--   <pre>
--   &gt;&gt;&gt; anyOf text (=='c') "chello"
--   True
--   </pre>
--   
--   <pre>
--   <a>text</a> = <a>unpacked</a> . <a>traversed</a>
--   </pre>
--   
--   When the type is unambiguous, you can also use the more general
--   <a>each</a>.
--   
--   <pre>
--   <a>text</a> ≡ <a>each</a>
--   </pre>
text :: IndexedTraversal' Int Text Char

-- | Convert between lazy <a>Text</a> and <a>Builder</a> .
--   
--   <pre>
--   <a>fromLazyText</a> x ≡ x <a>^.</a> <a>builder</a>
--   <a>toLazyText</a> x ≡ x <a>^.</a> <a>from</a> <a>builder</a>
--   </pre>
builder :: Iso' Text Builder


module Data.Text.Lens

-- | Traversals for strict or lazy <a>Text</a>
class IsText t where text = unpacked . traversed
packed :: IsText t => Iso' String t
builder :: IsText t => Iso' t Builder
text :: IsText t => IndexedTraversal' Int t Char

-- | This isomorphism can be used to <a>unpack</a> (or <a>pack</a>) both
--   strict or lazy <a>Text</a>.
--   
--   <pre>
--   <a>unpack</a> x ≡ x <a>^.</a> <a>unpacked</a>
--   <a>pack</a> x ≡ x <a>^.</a> <a>from</a> <a>unpacked</a>
--   </pre>
--   
--   This <a>Iso</a> is provided for notational convenience rather than out
--   of great need, since
--   
--   <pre>
--   <a>unpacked</a> ≡ <a>from</a> <a>packed</a>
--   </pre>
unpacked :: IsText t => Iso' t String
instance IsText Text
instance IsText Text


module Data.Tree.Lens

-- | A <a>Lens</a> that focuses on the root of a <a>Tree</a>.
--   
--   <pre>
--   &gt;&gt;&gt; view root $ Node 42 []
--   42
--   </pre>
root :: Lens' (Tree a) a

-- | A <a>Lens</a> returning the direct descendants of the root of a
--   <a>Tree</a>
--   
--   <pre>
--   <a>view</a> <a>branches</a> ≡ <a>subForest</a>
--   </pre>
branches :: Lens' (Tree a) [Tree a]


module Data.Typeable.Lens

-- | A <a>Traversal'</a> for working with a <a>cast</a> of a
--   <a>Typeable</a> value.
_cast :: (Typeable s, Typeable a) => Traversal' s a

-- | A <a>Traversal'</a> for working with a <a>gcast</a> of a
--   <a>Typeable</a> value.
_gcast :: (Typeable s, Typeable a) => Traversal' (c s) (c a)


-- | This module provides lenses and traversals for working with generic
--   vectors.
module Data.Vector.Lens

-- | Similar to <a>toListOf</a>, but returning a <a>Vector</a>.
--   
--   <pre>
--   &gt;&gt;&gt; toVectorOf both (8,15)
--   fromList [8,15]
--   </pre>
toVectorOf :: Getting (Endo [a]) s a -> s -> Vector a

-- | Convert a list to a <a>Vector</a> (or back)
--   
--   <pre>
--   &gt;&gt;&gt; [1,2,3] ^. vector
--   fromList [1,2,3]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [1,2,3] ^. vector . from vector
--   [1,2,3]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Vector.fromList [0,8,15] ^. from vector . vector
--   fromList [0,8,15]
--   </pre>
vector :: Iso [a] [b] (Vector a) (Vector b)

-- | Convert a <a>Vector</a> to a version that doesn't retain any extra
--   memory.
forced :: Iso (Vector a) (Vector b) (Vector a) (Vector b)

-- | <tt>sliced i n</tt> provides a <a>Lens</a> that edits the <tt>n</tt>
--   elements starting at index <tt>i</tt> from a <a>Lens</a>.
--   
--   This is only a valid <a>Lens</a> if you do not change the length of
--   the resulting <a>Vector</a>.
--   
--   Attempting to return a longer or shorter vector will result in
--   violations of the <a>Lens</a> laws.
--   
--   <pre>
--   &gt;&gt;&gt; Vector.fromList [1..10] ^. sliced 2 5
--   fromList [3,4,5,6,7]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Vector.fromList [1..10] &amp; sliced 2 5 . mapped .~ 0
--   fromList [1,2,0,0,0,0,0,8,9,10]
--   </pre>
sliced :: Int -> Int -> Lens' (Vector a) (Vector a)

-- | This <a>Traversal</a> will ignore any duplicates in the supplied list
--   of indices.
--   
--   <pre>
--   &gt;&gt;&gt; toListOf (ordinals [1,3,2,5,9,10]) $ Vector.fromList [2,4..40]
--   [4,8,6,12,20,22]
--   </pre>
ordinals :: [Int] -> IndexedTraversal' Int (Vector a) a


-- | This module provides lenses and traversals for working with generic
--   vectors.
module Data.Vector.Generic.Lens

-- | Similar to <a>toListOf</a>, but returning a <a>Vector</a>.
--   
--   <pre>
--   &gt;&gt;&gt; toVectorOf both (8,15) :: Vector.Vector Int
--   fromList [8,15]
--   </pre>
toVectorOf :: Vector v a => Getting (Endo [a]) s a -> s -> v a

-- | Convert a <a>Vector</a> to a version that doesn't retain any extra
--   memory.
forced :: Vector v a => Iso' (v a) (v a)

-- | Convert a list to a <a>Vector</a> (or back.)
--   
--   <pre>
--   &gt;&gt;&gt; [1,2,3] ^. vector :: Vector.Vector Int
--   fromList [1,2,3]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Vector.fromList [0,8,15] ^. from vector
--   [0,8,15]
--   </pre>
vector :: Vector v a => Iso' [a] (v a)

-- | Convert a <a>Vector</a> to a finite <a>Stream</a> (or back.)
asStream :: Vector v a => Iso' (v a) (Stream a)

-- | Convert a <a>Vector</a> to a finite <a>Stream</a> from right to left
--   (or back.)
asStreamR :: Vector v a => Iso' (v a) (Stream a)

-- | Convert a <a>Vector</a> back and forth to an initializer that when run
--   produces a copy of the <a>Vector</a>.
cloned :: Vector v a => Iso' (v a) (New v a)

-- | <tt>sliced i n</tt> provides a <a>Lens</a> that edits the <tt>n</tt>
--   elements starting at index <tt>i</tt> from a <a>Lens</a>.
--   
--   This is only a valid <a>Lens</a> if you do not change the length of
--   the resulting <a>Vector</a>.
--   
--   Attempting to return a longer or shorter vector will result in
--   violations of the <a>Lens</a> laws.
--   
--   <pre>
--   &gt;&gt;&gt; Vector.fromList [1..10] ^. sliced 2 5
--   fromList [3,4,5,6,7]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Vector.fromList [1..10] &amp; sliced 2 5 . mapped .~ 0
--   fromList [1,2,0,0,0,0,0,8,9,10]
--   </pre>
sliced :: Vector v a => Int -> Int -> Lens' (v a) (v a)

-- | This <a>Traversal</a> will ignore any duplicates in the supplied list
--   of indices.
--   
--   <pre>
--   &gt;&gt;&gt; toListOf (ordinals [1,3,2,5,9,10]) $ Vector.fromList [2,4..40]
--   [4,8,6,12,20,22]
--   </pre>
ordinals :: Vector v a => [Int] -> IndexedTraversal' Int (v a) a


-- | These prisms can be used with the combinators in
--   <a>Control.Exception.Lens</a>.
module System.Exit.Lens

-- | Exit codes that a program can return with:
class AsExitCode p f t
_ExitCode :: AsExitCode p f t => Overloaded' p f t ExitCode

-- | 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).
--   
--   <pre>
--   <a>_ExitFailure</a> :: <a>Prism'</a> <a>ExitCode</a>      <a>Int</a>
--   <a>_ExitFailure</a> :: <a>Prism'</a> <a>SomeException</a> <a>Int</a>
--   </pre>
_ExitFailure :: (AsExitCode p f t, Choice p, Applicative f) => Overloaded' p f t Int

-- | indicates successful termination;
--   
--   <pre>
--   <a>_ExitSuccess</a> :: <a>Prism'</a> <a>ExitCode</a>      ()
--   <a>_ExitSuccess</a> :: <a>Prism'</a> <a>SomeException</a> ()
--   </pre>
_ExitSuccess :: (AsExitCode p f t, Choice p, Applicative f) => Overloaded' p f t ()
instance (Choice p, Applicative f) => AsExitCode p f SomeException
instance AsExitCode p f ExitCode


module System.FilePath.Lens

-- | Modify the path by adding another path.
--   
--   <pre>
--   &gt;&gt;&gt; both &lt;/&gt;~ "bin" $ ("hello","world")
--   ("hello/bin","world/bin")
--   </pre>
--   
--   <pre>
--   (<a>&lt;/&gt;~</a>) :: <a>Setter</a> s a <a>FilePath</a> <a>FilePath</a> -&gt; <a>FilePath</a> -&gt; s -&gt; a
--   (<a>&lt;/&gt;~</a>) :: <a>Iso</a> s a <a>FilePath</a> <a>FilePath</a> -&gt; <a>FilePath</a> -&gt; s -&gt; a
--   (<a>&lt;/&gt;~</a>) :: <a>Lens</a> s a <a>FilePath</a> <a>FilePath</a> -&gt; <a>FilePath</a> -&gt; s -&gt; a
--   (<a>&lt;/&gt;~</a>) :: <a>Traversal</a> s a <a>FilePath</a> <a>FilePath</a> -&gt; <a>FilePath</a> -&gt; s -&gt; a
--   </pre>
(</>~) :: ASetter s t FilePath FilePath -> FilePath -> s -> t

-- | Add a path onto the end of the target of a <a>Lens</a> and return the
--   result
--   
--   When you do not need the result of the operation, (<a>&lt;/&gt;~</a>)
--   is more flexible.
(<</>~) :: LensLike ((,) FilePath) s a FilePath FilePath -> FilePath -> s -> (FilePath, a)

-- | Modify the path by adding extension.
--   
--   <pre>
--   &gt;&gt;&gt; both &lt;.&gt;~ "txt" $ ("hello","world")
--   ("hello.txt","world.txt")
--   </pre>
--   
--   <pre>
--   (<a>&lt;.&gt;~</a>) :: <a>Setter</a> s a <a>FilePath</a> <a>FilePath</a> -&gt; <a>String</a> -&gt; s -&gt; a
--   (<a>&lt;.&gt;~</a>) :: <a>Iso</a> s a <a>FilePath</a> <a>FilePath</a> -&gt; <a>String</a> -&gt; s -&gt; a
--   (<a>&lt;.&gt;~</a>) :: <a>Lens</a> s a <a>FilePath</a> <a>FilePath</a> -&gt; <a>String</a> -&gt; s -&gt; a
--   (<a>&lt;.&gt;~</a>) :: <a>Traversal</a> s a <a>FilePath</a> <a>FilePath</a> -&gt; <a>String</a> -&gt; s -&gt; a
--   </pre>
(<.>~) :: ASetter s a FilePath FilePath -> String -> s -> a

-- | Add an extension onto the end of the target of a <a>Lens</a> and
--   return the result
--   
--   <pre>
--   &gt;&gt;&gt; _1 &lt;&lt;.&gt;~ "txt" $ ("hello","world")
--   ("hello.txt",("hello.txt","world"))
--   </pre>
--   
--   When you do not need the result of the operation, (<a>&lt;.&gt;~</a>)
--   is more flexible.
(<<.>~) :: LensLike ((,) FilePath) s a FilePath FilePath -> String -> s -> (FilePath, a)

-- | Modify the target(s) of a <a>Simple</a> <a>Lens</a>, <a>Iso</a>,
--   <a>Setter</a> or <a>Traversal</a> by adding a path.
--   
--   <pre>
--   &gt;&gt;&gt; execState (both &lt;/&gt;= "bin") ("hello","world")
--   ("hello/bin","world/bin")
--   </pre>
--   
--   <pre>
--   (<a>&lt;/&gt;=</a>) :: <a>MonadState</a> s m =&gt; <a>Setter'</a> s <a>FilePath</a> -&gt; <a>FilePath</a> -&gt; m ()
--   (<a>&lt;/&gt;=</a>) :: <a>MonadState</a> s m =&gt; <a>Iso'</a> s <a>FilePath</a> -&gt; <a>FilePath</a> -&gt; m ()
--   (<a>&lt;/&gt;=</a>) :: <a>MonadState</a> s m =&gt; <a>Lens'</a> s <a>FilePath</a> -&gt; <a>FilePath</a> -&gt; m ()
--   (<a>&lt;/&gt;=</a>) :: <a>MonadState</a> s m =&gt; <a>Traversal'</a> s <a>FilePath</a> -&gt; <a>FilePath</a> -&gt; m ()
--   </pre>
(</>=) :: MonadState s m => ASetter' s FilePath -> FilePath -> m ()

-- | Add a path onto the end of the target of a <a>Lens</a> into your
--   monad's state and return the result.
--   
--   When you do not need the result of the operation, (<a>&lt;/&gt;=</a>)
--   is more flexible.
(<</>=) :: MonadState s m => LensLike' ((,) FilePath) s FilePath -> FilePath -> m FilePath

-- | Modify the target(s) of a <a>Simple</a> <a>Lens</a>, <a>Iso</a>,
--   <a>Setter</a> or <a>Traversal</a> by adding an extension.
--   
--   <pre>
--   &gt;&gt;&gt; execState (both &lt;.&gt;= "txt") ("hello","world")
--   ("hello.txt","world.txt")
--   </pre>
--   
--   <pre>
--   (<a>&lt;.&gt;=</a>) :: <a>MonadState</a> s m =&gt; <a>Setter'</a> s <a>FilePath</a> -&gt; <a>String</a> -&gt; m ()
--   (<a>&lt;.&gt;=</a>) :: <a>MonadState</a> s m =&gt; <a>Iso'</a> s <a>FilePath</a> -&gt; <a>String</a> -&gt; m ()
--   (<a>&lt;.&gt;=</a>) :: <a>MonadState</a> s m =&gt; <a>Lens'</a> s <a>FilePath</a> -&gt; <a>String</a> -&gt; m ()
--   (<a>&lt;.&gt;=</a>) :: <a>MonadState</a> s m =&gt; <a>Traversal'</a> s <a>FilePath</a> -&gt; <a>String</a> -&gt; m ()
--   </pre>
(<.>=) :: MonadState s m => ASetter' s FilePath -> String -> m ()

-- | Add an extension onto the end of the target of a <a>Lens</a> into your
--   monad's state and return the result.
--   
--   <pre>
--   &gt;&gt;&gt; evalState (_1 &lt;&lt;.&gt;= "txt") $("hello","world")
--   "hello.txt"
--   </pre>
--   
--   When you do not need the result of the operation, (<a>&lt;.&gt;=</a>)
--   is more flexible.
(<<.>=) :: MonadState s m => LensLike' ((,) FilePath) s FilePath -> String -> m FilePath

-- | A <a>Lens</a> for reading and writing to the basename
--   
--   <pre>
--   &gt;&gt;&gt; basename .~ "filename" $ "path/name.png"
--   "path/filename.png"
--   </pre>
basename :: Lens' FilePath FilePath

-- | A <a>Lens</a> for reading and writing to the directory
--   
--   <pre>
--   &gt;&gt;&gt; "long/path/name.txt" ^. directory
--   "long/path"
--   </pre>
directory :: Lens' FilePath FilePath

-- | A <a>Lens</a> for reading and writing to the extension
--   
--   <pre>
--   &gt;&gt;&gt; extension .~ ".png" $ "path/name.txt"
--   "path/name.png"
--   </pre>
extension :: Lens' FilePath FilePath

-- | A <a>Lens</a> for reading and writing to the full filename
--   
--   <pre>
--   &gt;&gt;&gt; filename .~ "name.txt" $ "path/name.png"
--   "path/name.txt"
--   </pre>
filename :: Lens' FilePath FilePath


module Numeric.Lens

-- | A prism that shows and reads integers in base-2 through base-36
--   
--   <pre>
--   &gt;&gt;&gt; "100" ^? base 16
--   Just 256
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; 1767707668033969 ^. re (base 36)
--   "helloworld"
--   </pre>
base :: Integral a => Int -> Prism' String a

-- | This <a>Prism</a> extracts can be used to model the fact that every
--   <a>Integral</a> type is a subset of <a>Integer</a>.
--   
--   Embedding through the <a>Prism</a> only succeeds if the <a>Integer</a>
--   would pass through unmodified when re-extracted.
integral :: (Integral a, Integral b) => Prism Integer Integer a b

-- | <pre>
--   <a>binary</a> = <a>base</a> 2
--   </pre>
binary :: Integral a => Prism' String a

-- | <pre>
--   <a>octal</a> = <a>base</a> 8
--   </pre>
octal :: Integral a => Prism' String a

-- | <pre>
--   <a>decimal</a> = <a>base</a> 10
--   </pre>
decimal :: Integral a => Prism' String a

-- | <pre>
--   <a>hex</a> = <a>base</a> 16
--   </pre>
hex :: Integral a => Prism' String a
