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


-- | Embedded domain-specific language for declarative graphics
--   
--   Diagrams is a flexible, extensible EDSL for creating graphics of many
--   types. Graphics can be created in arbitrary vector spaces and rendered
--   with multiple backends. diagrams-lib provides a standard library of
--   primitives and operations for creating diagrams. To get started using
--   it, see the <a>Diagrams</a> module, and refer to the tutorials and
--   documentation on the diagrams website,
--   <a>http://diagrams.github.io</a>.
@package diagrams-lib
@version 1.5.1


-- | Diagrams may have <i>attributes</i> which affect the way they are
--   rendered. This module defines some common attributes; particular
--   backends may also define more backend-specific attributes.
--   
--   Every attribute type must have a <i>semigroup</i> structure, that is,
--   an associative binary operation for combining two attributes into one.
--   Unless otherwise noted, all the attributes defined here use the
--   <a>Last</a> structure, that is, combining two attributes simply keeps
--   the second one and throws away the first. This means that child
--   attributes always override parent attributes.
module Diagrams.Attributes
ultraThin :: OrderedField n => Measure n
veryThin :: OrderedField n => Measure n
thin :: OrderedField n => Measure n
medium :: OrderedField n => Measure n
thick :: OrderedField n => Measure n
veryThick :: OrderedField n => Measure n
ultraThick :: OrderedField n => Measure n
none :: OrderedField n => Measure n
tiny :: OrderedField n => Measure n
verySmall :: OrderedField n => Measure n
small :: OrderedField n => Measure n
normal :: OrderedField n => Measure n
large :: OrderedField n => Measure n
veryLarge :: OrderedField n => Measure n
huge :: OrderedField n => Measure n

-- | Line widths specified on child nodes always override line widths
--   specified at parent nodes.
data LineWidth n
getLineWidth :: LineWidth n -> n
_LineWidth :: forall n p f. (Profunctor p, Functor f) => p n (f n) -> p (LineWidth n) (f (LineWidth n))
_LineWidthM :: forall n p f. (Profunctor p, Functor f) => p (Measure n) (f (Measure n)) -> p (LineWidthM n) (f (LineWidthM n))

-- | Set the line (stroke) width.
lineWidth :: (N a ~ n, HasStyle a, Typeable n) => Measure n -> a -> a

-- | Apply a <a>LineWidth</a> attribute.
lineWidthM :: (N a ~ n, HasStyle a, Typeable n) => LineWidthM n -> a -> a

-- | Lens onto a measured line width in a style.
_lineWidth :: forall n (v :: Type -> Type). (Typeable n, OrderedField n) => Lens' (Style v n) (Measure n)

-- | Lens onto a measured line width in a style.
_lw :: forall n (v :: Type -> Type). (Typeable n, OrderedField n) => Lens' (Style v n) (Measure n)

-- | Lens onto the unmeasured linewith attribute. This is useful for
--   backends to use on styles once they have been unmeasured. Using on a
--   diagram style could lead to unexpected results.
_lineWidthU :: forall n (v :: Type -> Type). Typeable n => Lens' (Style v n) (Maybe n)

-- | Default for <a>lineWidth</a>.
lw :: (N a ~ n, HasStyle a, Typeable n) => Measure n -> a -> a

-- | A convenient synonym for 'lineWidth (normalized w)'.
lwN :: (N a ~ n, HasStyle a, Typeable n, Num n) => n -> a -> a

-- | A convenient synonym for 'lineWidth (output w)'.
lwO :: (N a ~ n, HasStyle a, Typeable n) => n -> a -> a

-- | A convenient sysnonym for 'lineWidth (local w)'.
lwL :: (N a ~ n, HasStyle a, Typeable n, Num n) => n -> a -> a

-- | A convenient synonym for 'lineWidth (global w)'.
lwG :: (N a ~ n, HasStyle a, Typeable n, Num n) => n -> a -> a

-- | Create lines that are dashing... er, dashed.
data Dashing n
Dashing :: [n] -> n -> Dashing n
getDashing :: Dashing n -> Dashing n

-- | Set the line dashing style.
dashing :: (N a ~ n, HasStyle a, Typeable n) => [Measure n] -> Measure n -> a -> a

-- | A convenient synonym for 'dashing (normalized w)'.
dashingN :: (N a ~ n, HasStyle a, Typeable n, Num n) => [n] -> n -> a -> a

-- | A convenient synonym for 'dashing (output w)'.
dashingO :: (N a ~ n, HasStyle a, Typeable n) => [n] -> n -> a -> a

-- | A convenient sysnonym for 'dashing (local w)'.
dashingL :: (N a ~ n, HasStyle a, Typeable n, Num n) => [n] -> n -> a -> a

-- | A convenient synonym for 'dashing (global w)'.
dashingG :: (N a ~ n, HasStyle a, Typeable n, Num n) => [n] -> n -> a -> a

-- | Lens onto a measured dashing attribute in a style.
_dashing :: forall n (v :: Type -> Type). Typeable n => Lens' (Style v n) (Maybe (Measured n (Dashing n)))

-- | Lens onto the unmeasured <a>Dashing</a> attribute. This is useful for
--   backends to use on styles once they have been unmeasured. Using on a
--   diagram style could lead to unexpected results.
_dashingU :: forall n (v :: Type -> Type). Typeable n => Lens' (Style v n) (Maybe (Dashing n))

-- | The <a>Color</a> type class encompasses color representations which
--   can be used by the Diagrams library. Instances are provided for both
--   the <a>Colour</a> and <a>AlphaColour</a> types from the
--   <a>Data.Colour</a> library.
class Color c

-- | Convert a color to its standard representation, AlphaColour.
toAlphaColour :: Color c => c -> AlphaColour Double

-- | Convert from an AlphaColour Double. Note that this direction may lose
--   some information. For example, the instance for <a>Colour</a> drops
--   the alpha channel.
fromAlphaColour :: Color c => AlphaColour Double -> c

-- | An existential wrapper for instances of the <a>Color</a> class.
data SomeColor
SomeColor :: c -> SomeColor

-- | Isomorphism between <a>SomeColor</a> and <a>AlphaColour</a>
--   <a>Double</a>.
_SomeColor :: Iso' SomeColor (AlphaColour Double)
someToAlpha :: SomeColor -> AlphaColour Double

-- | Although the individual colors in a diagram can have transparency, the
--   opacity/transparency of a diagram as a whole can be specified with the
--   <tt>Opacity</tt> attribute. The opacity is a value between 1
--   (completely opaque, the default) and 0 (completely transparent).
--   Opacity is multiplicative, that is, <tt><a>opacity</a> o1 .
--   <a>opacity</a> o2 === <a>opacity</a> (o1 * o2)</tt>. In other words,
--   for example, <tt>opacity 0.8</tt> means "decrease this diagram's
--   opacity to 80% of its previous opacity".
data Opacity
_Opacity :: Iso' Opacity Double
getOpacity :: Opacity -> Double

-- | Multiply the opacity (see <a>Opacity</a>) by the given value. For
--   example, <tt>opacity 0.8</tt> means "decrease this diagram's opacity
--   to 80% of its previous opacity".
opacity :: HasStyle a => Double -> a -> a

-- | Lens onto the opacity in a style.
_opacity :: forall (v :: Type -> Type) n f. Functor f => (Double -> f Double) -> Style v n -> f (Style v n)

-- | Like <a>Opacity</a>, but set the opacity only for fills (as opposed to
--   strokes). As with <a>Opacity</a>, the fill opacity is a value between
--   1 (completely opaque, the default) and 0 (completely transparent), and
--   is multiplicative.
data FillOpacity
_FillOpacity :: Iso' FillOpacity Double
getFillOpacity :: FillOpacity -> Double

-- | Multiply the fill opacity (see <a>FillOpacity</a>) by the given value.
--   For example, <tt>fillOpacity 0.8</tt> means "decrease this diagram's
--   fill opacity to 80% of its previous value".
fillOpacity :: HasStyle a => Double -> a -> a

-- | Lens onto the fill opacity in a style.
_fillOpacity :: forall (v :: Type -> Type) n f. Functor f => (Double -> f Double) -> Style v n -> f (Style v n)

-- | Like <a>Opacity</a>, but set the opacity only for strokes (as opposed
--   to fills). As with <a>Opacity</a>, the fill opacity is a value between
--   1 (completely opaque, the default) and 0 (completely transparent), and
--   is multiplicative.
data StrokeOpacity
_StrokeOpacity :: Iso' StrokeOpacity Double
getStrokeOpacity :: StrokeOpacity -> Double

-- | Multiply the stroke opacity (see <a>StrokeOpacity</a>) by the given
--   value. For example, <tt>strokeOpacity 0.8</tt> means "decrease this
--   diagram's stroke opacity to 80% of its previous value".
strokeOpacity :: HasStyle a => Double -> a -> a

-- | Lens onto the stroke opacity in a style.
_strokeOpacity :: forall (v :: Type -> Type) n f. Functor f => (Double -> f Double) -> Style v n -> f (Style v n)

-- | Convert to sRGBA.
colorToSRGBA :: Color c => c -> (Double, Double, Double, Double)

-- | Convert to sRGBA.

-- | <i>Deprecated: Renamed to colorToSRGBA.</i>
colorToRGBA :: Color c => c -> (Double, Double, Double, Double)

-- | What sort of shape should be placed at the endpoints of lines?
data LineCap

-- | Lines end precisely at their endpoints.
LineCapButt :: LineCap

-- | Lines are capped with semicircles centered on endpoints.
LineCapRound :: LineCap

-- | Lines are capped with a squares centered on endpoints.
LineCapSquare :: LineCap
getLineCap :: LineCap -> LineCap

-- | Set the line end cap attribute.
lineCap :: HasStyle a => LineCap -> a -> a

-- | Lens onto the line cap in a style.
_lineCap :: forall (v :: Type -> Type) n f. Functor f => (LineCap -> f LineCap) -> Style v n -> f (Style v n)

-- | How should the join points between line segments be drawn?
data LineJoin

-- | Use a "miter" shape (whatever that is).
LineJoinMiter :: LineJoin

-- | Use rounded join points.
LineJoinRound :: LineJoin

-- | Use a "bevel" shape (whatever that is). Are these... carpentry terms?
LineJoinBevel :: LineJoin
getLineJoin :: LineJoin -> LineJoin

-- | Set the segment join style.
lineJoin :: HasStyle a => LineJoin -> a -> a

-- | Lens onto the line join type in a style.
_lineJoin :: forall (v :: Type -> Type) n f. Functor f => (LineJoin -> f LineJoin) -> Style v n -> f (Style v n)

-- | Miter limit attribute affecting the <a>LineJoinMiter</a> joins. For
--   some backends this value may have additional effects.
newtype LineMiterLimit
LineMiterLimit :: Last Double -> LineMiterLimit
_LineMiterLimit :: Iso' LineMiterLimit Double
getLineMiterLimit :: LineMiterLimit -> Double

-- | Set the miter limit for joins with <a>LineJoinMiter</a>.
lineMiterLimit :: HasStyle a => Double -> a -> a

-- | Apply a <a>LineMiterLimit</a> attribute.
lineMiterLimitA :: HasStyle a => LineMiterLimit -> a -> a

-- | Lens onto the line miter limit in a style.
_lineMiterLimit :: forall (v :: Type -> Type) n f. Functor f => (Double -> f Double) -> Style v n -> f (Style v n)

-- | Prism onto a <a>Recommend</a>.
_Recommend :: forall a p f. (Choice p, Applicative f) => p a (f a) -> p (Recommend a) (f (Recommend a))

-- | Prism onto a <a>Commit</a>.
_Commit :: forall a p f. (Choice p, Applicative f) => p a (f a) -> p (Recommend a) (f (Recommend a))

-- | Lens onto the value inside either a <a>Recommend</a> or <a>Commit</a>.
--   Unlike <a>committed</a>, this is a valid lens.
_recommend :: forall a b f. Functor f => (a -> f b) -> Recommend a -> f (Recommend b)

-- | Lens onto whether something is committed or not.
isCommitted :: forall a f. Functor f => (Bool -> f Bool) -> Recommend a -> f (Recommend a)

-- | <a>Commit</a> a value for any <a>Recommend</a>. This is *not* a valid
--   <a>Iso</a> because the resulting <tt>Recommend b</tt> is always a
--   <a>Commit</a>. This is useful because it means any <a>Recommend</a>
--   styles set with a lens will not be accidentally overridden. If you
--   want a valid lens onto a recommend value use <a>_recommend</a>.
--   
--   Other lenses that use this are labeled with a warning.
committed :: forall a b p f. (Profunctor p, Functor f) => p a (f b) -> p (Recommend a) (f (Recommend b))
instance GHC.Internal.Data.Typeable.Internal.Typeable n => Diagrams.Core.Style.AttributeClass (Diagrams.Attributes.Dashing n)
instance Diagrams.Core.Style.AttributeClass Diagrams.Attributes.FillOpacity
instance Diagrams.Core.Style.AttributeClass Diagrams.Attributes.LineCap
instance Diagrams.Core.Style.AttributeClass Diagrams.Attributes.LineJoin
instance Diagrams.Core.Style.AttributeClass Diagrams.Attributes.LineMiterLimit
instance GHC.Internal.Data.Typeable.Internal.Typeable n => Diagrams.Core.Style.AttributeClass (Diagrams.Attributes.LineWidth n)
instance Diagrams.Core.Style.AttributeClass Diagrams.Attributes.Opacity
instance Diagrams.Core.Style.AttributeClass Diagrams.Attributes.StrokeOpacity
instance (a GHC.Types.~ GHC.Types.Double) => Diagrams.Attributes.Color (Data.Colour.Internal.AlphaColour a)
instance (a GHC.Types.~ GHC.Types.Double) => Diagrams.Attributes.Color (Data.Colour.Internal.Colour a)
instance Diagrams.Attributes.Color Diagrams.Attributes.SomeColor
instance Data.Default.Internal.Default Diagrams.Attributes.LineCap
instance Data.Default.Internal.Default Diagrams.Attributes.LineJoin
instance Data.Default.Internal.Default Diagrams.Attributes.LineMiterLimit
instance Diagrams.Core.Envelope.OrderedField n => Data.Default.Internal.Default (Diagrams.Attributes.LineWidthM n)
instance GHC.Classes.Eq n => GHC.Classes.Eq (Diagrams.Attributes.Dashing n)
instance GHC.Classes.Eq Diagrams.Attributes.LineCap
instance GHC.Classes.Eq Diagrams.Attributes.LineJoin
instance GHC.Classes.Eq Diagrams.Attributes.LineMiterLimit
instance GHC.Internal.Base.Functor Diagrams.Attributes.Dashing
instance GHC.Classes.Ord Diagrams.Attributes.LineCap
instance GHC.Classes.Ord Diagrams.Attributes.LineJoin
instance GHC.Classes.Ord Diagrams.Attributes.LineMiterLimit
instance GHC.Internal.Base.Semigroup (Diagrams.Attributes.Dashing n)
instance GHC.Internal.Base.Semigroup Diagrams.Attributes.FillOpacity
instance GHC.Internal.Base.Semigroup Diagrams.Attributes.LineCap
instance GHC.Internal.Base.Semigroup Diagrams.Attributes.LineJoin
instance GHC.Internal.Base.Semigroup Diagrams.Attributes.LineMiterLimit
instance GHC.Internal.Base.Semigroup (Diagrams.Attributes.LineWidth n)
instance GHC.Internal.Base.Semigroup Diagrams.Attributes.Opacity
instance GHC.Internal.Base.Semigroup Diagrams.Attributes.StrokeOpacity
instance GHC.Internal.Show.Show Diagrams.Attributes.LineCap
instance GHC.Internal.Show.Show Diagrams.Attributes.LineJoin
instance GHC.Internal.Show.Show Diagrams.Attributes.SomeColor


-- | XXX
module Diagrams.Attributes.Compile
class (AttributeClass AttrType code, Typeable PrimType code) => SplitAttribute code where {
    type AttrType code;
    type PrimType code;
}
primOK :: SplitAttribute code => code -> PrimType code -> Bool

-- | Push certain attributes down until they are at the roots of trees
--   containing only "safe" nodes. In particular this is used to push fill
--   attributes down until they are over only loops; see
--   <tt>splitFills</tt>.
splitAttr :: forall code b (v :: Type -> Type) n a. SplitAttribute code => code -> RTree b v n a -> RTree b v n a


-- | A <i>cubic spline</i> is a smooth, connected sequence of cubic curves
--   passing through a given sequence of points. This module implements a
--   straightforward spline generation algorithm based on solving
--   tridiagonal systems of linear equations.
module Diagrams.CubicSpline.Internal

-- | Use the tri-diagonal solver with the appropriate parameters for an
--   open cubic spline.
solveCubicSplineDerivatives :: Fractional a => [a] -> [a]

-- | Use the cyclic-tri-diagonal solver with the appropriate parameters for
--   a closed cubic spline.
solveCubicSplineDerivativesClosed :: Fractional a => [a] -> [a]

-- | Use the cyclic-tri-diagonal solver with the appropriate parameters for
--   a closed cubic spline.
solveCubicSplineCoefficients :: Fractional a => Bool -> [a] -> [[a]]


-- | Names can be given to subdiagrams, and subdiagrams can later be
--   queried by name. This module exports types for representing names and
--   subdiagrams, and various functions for working with them.
module Diagrams.Names

-- | Atomic names. <tt>AName</tt> is just an existential wrapper around
--   things which are <a>Typeable</a>, <a>Ord</a> and <a>Show</a>.
data AName

-- | A (qualified) name is a (possibly empty) sequence of atomic names.
data Name

-- | Class for those types which can be used as names. They must support
--   <a>Typeable</a> (to facilitate extracting them from existential
--   wrappers), <a>Ord</a> (for comparison and efficient storage) and
--   <a>Show</a>.
--   
--   To make an instance of <a>IsName</a>, you need not define any methods,
--   just declare it.
--   
--   WARNING: it is not recommended to use
--   <tt>GeneralizedNewtypeDeriving</tt> in conjunction with
--   <tt>IsName</tt>, since in that case the underlying type and the
--   <tt>newtype</tt> will be considered equivalent when comparing names.
--   For example:
--   
--   <pre>
--   newtype WordN = WordN Int deriving (Show, Ord, Eq, Typeable, IsName)
--   
--   </pre>
--   
--   is unlikely to work as intended, since <tt>(1 :: Int)</tt> and
--   <tt>(WordN 1)</tt> will be considered equal as names. Instead, use
--   
--   <pre>
--   newtype WordN = WordN Int deriving (Show, Ord, Eq, Typeable, IsName)
--   instance IsName WordN
--   
--   </pre>
class (Typeable a, Ord a, Show a) => IsName a
toName :: IsName a => a -> Name

-- | Convenient operator for writing qualified names with atomic components
--   of different types. Instead of writing <tt>toName a1 &lt;&gt; toName
--   a2 &lt;&gt; toName a3</tt> you can just write <tt>a1 .&gt; a2 .&gt;
--   a3</tt>.
(.>) :: (IsName a1, IsName a2) => a1 -> a2 -> Name
infixr 5 .>

-- | Instances of <a>Qualifiable</a> are things which can be qualified by
--   prefixing them with a name.
class Qualifiable q

-- | Qualify with the given name.
(.>>) :: (Qualifiable q, IsName a) => a -> q -> q
infixr 5 .>>

-- | A <tt>Subdiagram</tt> represents a diagram embedded within the context
--   of a larger diagram. Essentially, it consists of a diagram paired with
--   any accumulated information from the larger context (transformations,
--   attributes, etc.).
data Subdiagram b (v :: Type -> Type) n m

-- | Turn a diagram into a subdiagram with no accumulated context.
mkSubdiagram :: forall b (v :: Type -> Type) n m. QDiagram b v n m -> Subdiagram b v n m

-- | Create a "point subdiagram", that is, a <a>pointDiagram</a> (with no
--   content and a point envelope) treated as a subdiagram with local
--   origin at the given point. Note this is not the same as
--   <tt>mkSubdiagram . pointDiagram</tt>, which would result in a
--   subdiagram with local origin at the parent origin, rather than at the
--   given point.
subPoint :: forall (v :: Type -> Type) n b m. (Metric v, OrderedField n) => Point v n -> Subdiagram b v n m

-- | Turn a subdiagram into a normal diagram, including the enclosing
--   context. Concretely, a subdiagram is a pair of (1) a diagram and (2) a
--   "context" consisting of an extra transformation and attributes.
--   <tt>getSub</tt> simply applies the transformation and attributes to
--   the diagram to get the corresponding "top-level" diagram.
getSub :: forall (v :: Type -> Type) n m b. (Metric v, OrderedField n, Semigroup m) => Subdiagram b v n m -> QDiagram b v n m

-- | Extract the "raw" content of a subdiagram, by throwing away the
--   context.
rawSub :: forall b (v :: Type -> Type) n m. Subdiagram b v n m -> QDiagram b v n m

-- | Get the location of a subdiagram; that is, the location of its local
--   origin <i>with respect to</i> the vector space of its parent diagram.
--   In other words, the point where its local origin "ended up".
location :: forall (v :: Type -> Type) n b m. (Additive v, Num n) => Subdiagram b v n m -> Point v n

-- | A <a>SubMap</a> is a map associating names to subdiagrams. There can
--   be multiple associations for any given name.
data SubMap b (v :: Type -> Type) n m

-- | Construct a <a>SubMap</a> from a list of associations between names
--   and subdiagrams.
fromNames :: forall a b (v :: Type -> Type) n m. IsName a => [(a, Subdiagram b v n m)] -> SubMap b v n m

-- | Add a name/diagram association to a submap.
rememberAs :: forall a b (v :: Type -> Type) n m. IsName a => a -> QDiagram b v n m -> SubMap b v n m -> SubMap b v n m

-- | Look for the given name in a name map, returning a list of subdiagrams
--   associated with that name. If no names match the given name exactly,
--   return all the subdiagrams associated with names of which the given
--   name is a suffix.
lookupSub :: forall nm b (v :: Type -> Type) n m. IsName nm => nm -> SubMap b v n m -> Maybe [Subdiagram b v n m]

-- | Attach an atomic name to a diagram.
named :: forall nm (v :: Type -> Type) n m b. (IsName nm, Metric v, OrderedField n, Semigroup m) => nm -> QDiagram b v n m -> QDiagram b v n m

-- | Attach an atomic name to a certain subdiagram, computed from the given
--   diagram /with the mapping from name to subdiagram included/. The
--   upshot of this knot-tying is that if <tt>d' = d # named x</tt>, then
--   <tt>lookupName x d' == Just d'</tt> (instead of <tt>Just d</tt>).
nameSub :: forall nm (v :: Type -> Type) n m b. (IsName nm, Metric v, OrderedField n, Semigroup m) => (QDiagram b v n m -> Subdiagram b v n m) -> nm -> QDiagram b v n m -> QDiagram b v n m

-- | Attach an atomic name to a certain point (which may be computed from
--   the given diagram), treated as a subdiagram with no content and a
--   point envelope.
namePoint :: forall nm (v :: Type -> Type) n m b. (IsName nm, Metric v, OrderedField n, Semigroup m) => (QDiagram b v n m -> Point v n) -> nm -> QDiagram b v n m -> QDiagram b v n m

-- | "Localize" a diagram by hiding all the names, so they are no longer
--   visible to the outside.
localize :: forall b (v :: Type -> Type) n m. (Metric v, OrderedField n, Semigroup m) => QDiagram b v n m -> QDiagram b v n m

-- | Get a list of names of subdiagrams and their locations.
names :: forall (v :: Type -> Type) m n b. (Metric v, Semigroup m, OrderedField n) => QDiagram b v n m -> [(Name, [Point v n])]

-- | Lookup the most recent diagram associated with (some qualification of)
--   the given name.
lookupName :: forall nm (v :: Type -> Type) m n b. (IsName nm, Metric v, Semigroup m, OrderedField n) => nm -> QDiagram b v n m -> Maybe (Subdiagram b v n m)

-- | Given a name and a diagram transformation indexed by a subdiagram,
--   perform the transformation using the most recent subdiagram associated
--   with (some qualification of) the name, or perform the identity
--   transformation if the name does not exist.
withName :: forall nm (v :: Type -> Type) m n b. (IsName nm, Metric v, Semigroup m, OrderedField n) => nm -> (Subdiagram b v n m -> QDiagram b v n m -> QDiagram b v n m) -> QDiagram b v n m -> QDiagram b v n m

-- | Given a name and a diagram transformation indexed by a list of
--   subdiagrams, perform the transformation using the collection of all
--   such subdiagrams associated with (some qualification of) the given
--   name.
withNameAll :: forall nm (v :: Type -> Type) m n b. (IsName nm, Metric v, Semigroup m, OrderedField n) => nm -> ([Subdiagram b v n m] -> QDiagram b v n m -> QDiagram b v n m) -> QDiagram b v n m -> QDiagram b v n m

-- | Given a list of names and a diagram transformation indexed by a list
--   of subdiagrams, perform the transformation using the list of most
--   recent subdiagrams associated with (some qualification of) each name.
--   Do nothing (the identity transformation) if any of the names do not
--   exist.
withNames :: forall nm (v :: Type -> Type) m n b. (IsName nm, Metric v, Semigroup m, OrderedField n) => [nm] -> ([Subdiagram b v n m] -> QDiagram b v n m -> QDiagram b v n m) -> QDiagram b v n m -> QDiagram b v n m


-- | Type classes for things which are parameterized in some way,
--   <i>e.g.</i> segments and trails.
module Diagrams.Parametric

-- | The standard tolerance used by <tt>std...</tt> functions (like
--   <a>stdArcLength</a> and <a>stdArcLengthToParam</a>, currently set at
--   <tt>1e-6</tt>.
stdTolerance :: Fractional a => a

-- | Codomain of parametric classes. This is usually either <tt>(V p)</tt>,
--   for relative vector results, or <tt>(Point (V p))</tt>, for functions
--   with absolute coordinates.
type family Codomain p :: Type -> Type

-- | Type class for parametric functions.
class Parametric p

-- | <a>atParam</a> yields a parameterized view of an object as a
--   continuous function. It is designed to be used infix, like <tt>path
--   <a>`atParam`</a> 0.5</tt>.
atParam :: Parametric p => p -> N p -> Codomain p (N p)

-- | Type class for parametric functions with a bounded domain. The default
--   bounds are <tt>[0,1]</tt>.
--   
--   Note that this domain indicates the main "interesting" portion of the
--   function. It must be defined within this range, but for some instances
--   may still have sensible values outside.
class DomainBounds p

-- | <a>domainLower</a> defaults to being constantly 0 (for vector spaces
--   with numeric scalars).
domainLower :: DomainBounds p => p -> N p
($dmdomainLower) :: (DomainBounds p, Num (N p)) => p -> N p

-- | <a>domainUpper</a> defaults to being constantly 1 (for vector spaces
--   with numeric scalars).
domainUpper :: DomainBounds p => p -> N p
($dmdomainUpper) :: (DomainBounds p, Num (N p)) => p -> N p

-- | Return the lower and upper bounds of a parametric domain together as a
--   pair.
domainBounds :: DomainBounds p => p -> (N p, N p)

-- | Type class for querying the values of a parametric object at the ends
--   of its domain.
class (Parametric p, DomainBounds p) => EndValues p

-- | <a>atStart</a> is the value at the start of the domain. That is,
--   
--   <pre>
--   atStart x = x `atParam` domainLower x
--   </pre>
--   
--   This is the default implementation, but some representations will have
--   a more efficient and/or precise implementation.
atStart :: EndValues p => p -> Codomain p (N p)

-- | <a>atEnd</a> is the value at the end of the domain. That is,
--   
--   <pre>
--   atEnd x = x `atParam` domainUpper x
--   </pre>
--   
--   This is the default implementation, but some representations will have
--   a more efficient and/or precise implementation.
atEnd :: EndValues p => p -> Codomain p (N p)

-- | Type class for parametric objects which can be split into subobjects.
--   
--   Minimal definition: Either <a>splitAtParam</a> or <a>section</a>, plus
--   <a>reverseDomain</a>.
class DomainBounds p => Sectionable p

-- | <a>splitAtParam</a> splits an object <tt>p</tt> into two new objects
--   <tt>(l,r)</tt> at the parameter <tt>t</tt>, where <tt>l</tt>
--   corresponds to the portion of <tt>p</tt> for parameter values from
--   <tt>0</tt> to <tt>t</tt> and <tt>r</tt> for to that from <tt>t</tt> to
--   <tt>1</tt>. The following property should hold:
--   
--   <pre>
--   prop_splitAtParam f t u =
--     | u &lt; t     = atParam f u == atParam l (u / t)
--     | otherwise = atParam f u == atParam f t ??? atParam l ((u - t) / (domainUpper f - t))
--     where (l,r) = splitAtParam f t
--   </pre>
--   
--   where <tt>(???) = (^+^)</tt> if the codomain is a vector type, or
--   <tt>const flip</tt> if the codomain is a point type. Stated more
--   intuitively, all this is to say that the parameterization scales
--   linearly with splitting.
--   
--   <a>splitAtParam</a> can also be used with parameters outside the range
--   of the domain. For example, using the parameter <tt>2</tt> with a path
--   (where the domain is the default <tt>[0,1]</tt>) gives two result
--   paths where the first is the original path extended to the parameter
--   2, and the second result path travels <i>backwards</i> from the end of
--   the first to the end of the original path.
splitAtParam :: Sectionable p => p -> N p -> (p, p)

-- | Extract a particular section of the domain, linearly reparameterized
--   to the same domain as the original. Should satisfy the property:
--   
--   <pre>
--   prop_section x l u t =
--     let s = section x l u
--     in     domainBounds x == domainBounds x
--         &amp;&amp; (x `atParam` lerp l u t) == (s `atParam` t)
--   </pre>
--   
--   That is, the section should have the same domain as the original, and
--   the reparameterization should be linear.
section :: Sectionable p => p -> N p -> N p -> p
($dmsection) :: (Sectionable p, Fractional (N p)) => p -> N p -> N p -> p

-- | Flip the parameterization on the domain.
reverseDomain :: Sectionable p => p -> p

-- | Type class for parametric things with a notion of arc length.
class Parametric p => HasArcLength p

-- | <tt>arcLengthBounded eps x</tt> approximates the arc length of
--   <tt>x</tt>. The true arc length is guaranteed to lie within the
--   interval returned, which will have a size of at most <tt>eps</tt>.
arcLengthBounded :: HasArcLength p => N p -> p -> Interval (N p)

-- | <tt>arcLength eps s</tt> approximates the arc length of <tt>x</tt> up
--   to the accuracy <tt>eps</tt> (plus or minus).
arcLength :: HasArcLength p => N p -> p -> N p
($dmarcLength) :: (HasArcLength p, Fractional (N p)) => N p -> p -> N p

-- | Approximate the arc length up to a standard accuracy of
--   <a>stdTolerance</a> (<tt>1e-6</tt>).
stdArcLength :: HasArcLength p => p -> N p
($dmstdArcLength) :: (HasArcLength p, Fractional (N p)) => p -> N p

-- | <tt><a>arcLengthToParam</a> eps s l</tt> converts the absolute arc
--   length <tt>l</tt>, measured from the start of the domain, to a
--   parameter on the object <tt>s</tt>. The true arc length at the
--   parameter returned is guaranteed to be within <tt>eps</tt> of the
--   requested arc length.
--   
--   This should work for <i>any</i> arc length, and may return any
--   parameter value (not just parameters in the domain).
arcLengthToParam :: HasArcLength p => N p -> p -> N p -> N p

-- | A simple interface to convert arc length to a parameter, guaranteed to
--   be accurate within <a>stdTolerance</a>, or <tt>1e-6</tt>.
stdArcLengthToParam :: HasArcLength p => p -> N p -> N p
($dmstdArcLengthToParam) :: (HasArcLength p, Fractional (N p)) => p -> N p -> N p


-- | Tools for adjusting the length of parametric objects such as segments
--   and trails.
module Diagrams.Parametric.Adjust

-- | Adjust the length of a parametric object such as a segment or trail.
--   The second parameter is an option record which controls how the
--   adjustment should be performed; see <a>AdjustOpts</a>.
adjust :: (N t ~ n, Sectionable t, HasArcLength t, Fractional n) => t -> AdjustOpts n -> t

-- | How should a segment, trail, or path be adjusted?
data AdjustOpts n

-- | Which method should be used for adjusting?
adjMethod :: forall n f. Functor f => (AdjustMethod n -> f (AdjustMethod n)) -> AdjustOpts n -> f (AdjustOpts n)

-- | Which end(s) of the object should be adjusted?
adjSide :: forall n f. Functor f => (AdjustSide -> f AdjustSide) -> AdjustOpts n -> f (AdjustOpts n)

-- | Tolerance to use when doing adjustment.
adjEps :: forall n f. Functor f => (n -> f n) -> AdjustOpts n -> f (AdjustOpts n)

-- | What method should be used for adjusting a segment, trail, or path?
data AdjustMethod n

-- | Extend by the given parameter value (use a negative parameter to
--   shrink)
ByParam :: n -> AdjustMethod n

-- | Extend by the given arc length (use a negative length to shrink)
ByAbsolute :: n -> AdjustMethod n

-- | Extend or shrink to the given arc length
ToAbsolute :: n -> AdjustMethod n

-- | Which side of a segment, trail, or path should be adjusted?
data AdjustSide

-- | Adjust only the beginning
Start :: AdjustSide

-- | Adjust only the end
End :: AdjustSide

-- | Adjust both sides equally
Both :: AdjustSide
instance GHC.Internal.Enum.Bounded Diagrams.Parametric.Adjust.AdjustSide
instance GHC.Internal.Real.Fractional n => Data.Default.Internal.Default (Diagrams.Parametric.Adjust.AdjustMethod n)
instance GHC.Internal.Real.Fractional n => Data.Default.Internal.Default (Diagrams.Parametric.Adjust.AdjustOpts n)
instance Data.Default.Internal.Default Diagrams.Parametric.Adjust.AdjustSide
instance GHC.Internal.Enum.Enum Diagrams.Parametric.Adjust.AdjustSide
instance GHC.Classes.Eq Diagrams.Parametric.Adjust.AdjustSide
instance GHC.Classes.Ord Diagrams.Parametric.Adjust.AdjustSide
instance GHC.Internal.Read.Read Diagrams.Parametric.Adjust.AdjustSide
instance GHC.Internal.Show.Show Diagrams.Parametric.Adjust.AdjustSide


-- | Points in space. For more tools for working with points and vectors,
--   see <a>Linear.Affine</a>.
module Diagrams.Points

-- | A handy wrapper to help distinguish points from vectors at the type
--   level
newtype Point (f :: Type -> Type) a
P :: f a -> Point (f :: Type -> Type) a

-- | Vector spaces have origins.
origin :: forall (f :: Type -> Type) a. (Additive f, Num a) => Point f a

-- | Scale a point by a scalar. Specialized version of <a>(*^)</a>.
(*.) :: forall (v :: Type -> Type) n. (Functor v, Num n) => n -> Point v n -> Point v n

-- | The centroid of a set of <i>n</i> points is their sum divided by
--   <i>n</i>. Returns the origin for an empty list of points.
centroid :: forall (v :: Type -> Type) n. (Additive v, Fractional n) => [Point v n] -> Point v n

-- | Create a "point diagram", which has no content, no trace, an empty
--   query, and a point envelope.
pointDiagram :: forall (v :: Type -> Type) n b m. (Metric v, Fractional n) => Point v n -> QDiagram b v n m
_Point :: forall f1 a g b p f2. (Profunctor p, Functor f2) => p (f1 a) (f2 (g b)) -> p (Point f1 a) (f2 (Point g b))
lensP :: forall f1 a g b f2. Functor f2 => (f1 a -> f2 (g b)) -> Point f1 a -> f2 (Point g b)


-- | Nice syntax for constructing and pattern-matching on literal points
--   and vectors.
module Diagrams.Coordinates

-- | A pair of values, with a convenient infix (left-associative) data
--   constructor.
data a :& b
(:&) :: a -> b -> (:&) a b
infixl 7 :&
infixl 7 :&

-- | Types which are instances of the <tt>Coordinates</tt> class can be
--   constructed using <a>^&amp;</a> (for example, a three-dimensional
--   vector could be constructed by <tt>1 ^&amp; 6 ^&amp; 3</tt>), and
--   deconstructed using <a>coords</a>. A common pattern is to use
--   <a>coords</a> in conjunction with the <tt>ViewPatterns</tt> extension,
--   like so:
--   
--   <pre>
--   foo :: Vector3 -&gt; ...
--   foo (coords -&gt; x :&amp; y :&amp; z) = ...
--   </pre>
class Coordinates c where {
    
    -- | The type of the final coordinate.
    type FinalCoord c;
    
    -- | The type of everything other than the final coordinate.
    type PrevDim c;
    
    -- | Decomposition of <tt>c</tt> into applications of <a>:&amp;</a>.
    type Decomposition c;
}

-- | Construct a value of type <tt>c</tt> by providing something of one
--   less dimension (which is perhaps itself recursively constructed using
--   <tt>(^&amp;)</tt>) and a final coordinate. For example,
--   
--   <pre>
--   2 ^&amp; 3 :: P2
--   3 ^&amp; 5 ^&amp; 6 :: V3
--   </pre>
--   
--   Note that <tt>^&amp;</tt> is left-associative.
(^&) :: Coordinates c => PrevDim c -> FinalCoord c -> c

-- | Prefix synonym for <tt>^&amp;</tt>. pr stands for pair of
--   <tt>PrevDim</tt>, <tt>FinalCoord</tt>
pr :: Coordinates c => PrevDim c -> FinalCoord c -> c

-- | Decompose a value of type <tt>c</tt> into its constituent coordinates,
--   stored in a nested <tt>(:&amp;)</tt> structure.
coords :: Coordinates c => c -> Decomposition c
infixl 7 ^&
instance Diagrams.Coordinates.Coordinates (a Diagrams.Coordinates.:& b)
instance Diagrams.Coordinates.Coordinates (v n) => Diagrams.Coordinates.Coordinates (Linear.Affine.Point v n)
instance Diagrams.Coordinates.Coordinates (a, b)
instance Diagrams.Coordinates.Coordinates (a, b, c)
instance Diagrams.Coordinates.Coordinates (a, b, c, d)
instance Diagrams.Coordinates.Coordinates (Linear.V2.V2 n)
instance Diagrams.Coordinates.Coordinates (Linear.V3.V3 n)
instance Diagrams.Coordinates.Coordinates (Linear.V4.V4 n)
instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (a Diagrams.Coordinates.:& b)
instance (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (a Diagrams.Coordinates.:& b)
instance (GHC.Internal.Show.Show a, GHC.Internal.Show.Show b) => GHC.Internal.Show.Show (a Diagrams.Coordinates.:& b)


-- | Type for representing angles.
module Diagrams.Angle

-- | Angles can be expressed in a variety of units. Internally, they are
--   represented in radians.
data Angle n

-- | <tt>30 @@ deg</tt> is an <a>Angle</a> of the given measure and units.
--   
--   <pre>
--   &gt;&gt;&gt; pi @@ rad
--   3.141592653589793 @@ rad
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; 1 @@ turn
--   6.283185307179586 @@ rad
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; 30 @@ deg
--   0.5235987755982988 @@ rad
--   </pre>
--   
--   For <a>Iso'</a>s, (<a>@@</a>) reverses the <a>Iso'</a> on its right,
--   and applies the <a>Iso'</a> to the value on the left. <a>Angle</a>s
--   are the motivating example where this order improves readability.
--   
--   This is the same as a flipped <a>review</a>.
--   
--   <pre>
--   (<a>@@</a>) :: a -&gt; <a>Iso'</a>      s a -&gt; s
--   (<a>@@</a>) :: a -&gt; <tt>Prism'</tt>    s a -&gt; s
--   (<a>@@</a>) :: a -&gt; <tt>Review</tt>    s a -&gt; s
--   (<a>@@</a>) :: a -&gt; <tt>Equality'</tt> s a -&gt; s
--   </pre>
(@@) :: b -> AReview a b -> a
infixl 5 @@

-- | The radian measure of an <a>Angle</a> <tt>a</tt> can be accessed as
--   <tt>a <a>^.</a> rad</tt>. A new <a>Angle</a> can be defined in radians
--   as <tt>pi @@ rad</tt>.
rad :: forall n p f. (Profunctor p, Functor f) => p n (f n) -> p (Angle n) (f (Angle n))

-- | The measure of an <a>Angle</a> <tt>a</tt> in full circles can be
--   accessed as <tt>a <a>^.</a> turn</tt>. A new <a>Angle</a> of one-half
--   circle can be defined in as <tt>1/2 @@ turn</tt>.
turn :: Floating n => Iso' (Angle n) n

-- | The degree measure of an <a>Angle</a> <tt>a</tt> can be accessed as
--   <tt>a <a>^.</a> deg</tt>. A new <a>Angle</a> can be defined in degrees
--   as <tt>180 @@ deg</tt>.
deg :: Floating n => Iso' (Angle n) n

-- | An angle representing one full turn.
fullTurn :: Floating v => Angle v

-- | An angle representing a half turn.
halfTurn :: Floating v => Angle v

-- | An angle representing a quarter turn.
quarterTurn :: Floating v => Angle v

-- | The sine of the given <tt>Angle</tt>.
sinA :: Floating n => Angle n -> n

-- | The cosine of the given <tt>Angle</tt>.
cosA :: Floating n => Angle n -> n

-- | The tangent function of the given <tt>Angle</tt>.
tanA :: Floating n => Angle n -> n

-- | The <tt>Angle</tt> with the given sine.
asinA :: Floating n => n -> Angle n

-- | The <tt>Angle</tt> with the given cosine.
acosA :: Floating n => n -> Angle n

-- | The <tt>Angle</tt> with the given tangent.
atanA :: Floating n => n -> Angle n

-- | <tt>atan2A y x</tt> is the angle between the positive x-axis and the
--   vector given by the coordinates (x, y). The <a>Angle</a> returned is
--   in the [-pi,pi] range.
atan2A :: RealFloat n => n -> n -> Angle n

-- | Similar to <a>atan2A</a> but without the <a>RealFloat</a> constraint.
--   This means it doesn't handle negative zero cases. However, for most
--   geometric purposes, the outcome will be the same.
atan2A' :: OrderedField n => n -> n -> Angle n

-- | Compute the positive angle between the two vectors in their common
--   plane in the [0,pi] range. For a signed angle see
--   <a>signedAngleBetween</a>.
--   
--   Returns NaN if either of the vectors are zero.
angleBetween :: (Metric v, Floating n, Ord n) => v n -> v n -> Angle n

-- | Calculate ratio between two angles.
angleRatio :: Floating n => Angle n -> Angle n -> n

-- | Normalize an angle so that it lies in the [0,tau) range.
normalizeAngle :: (Floating n, Real n) => Angle n -> Angle n

-- | The class of types with at least one angle coordinate, called
--   <a>_theta</a>.
class HasTheta (t :: Type -> Type)
_theta :: (HasTheta t, RealFloat n) => Lens' (t n) (Angle n)

-- | The class of types with at least two angle coordinates, the second
--   called <a>_phi</a>. <a>_phi</a> is the positive angle measured from
--   the z axis.
class HasTheta t => HasPhi (t :: Type -> Type)
_phi :: (HasPhi t, RealFloat n) => Lens' (t n) (Angle n)

-- | Create a transformation which performs a rotation about the local
--   origin by the given angle. See also <a>rotate</a>.
rotation :: Floating n => Angle n -> Transformation V2 n

-- | Rotate about the local origin by the given angle. Positive angles
--   correspond to counterclockwise rotation, negative to clockwise. The
--   angle can be expressed using any of the <tt>Iso</tt>s on <a>Angle</a>.
--   For example, <tt>rotate (1/4 @@ <a>turn</a>)</tt>, <tt>rotate (tau/4
--   @@ rad)</tt>, and <tt>rotate (90 @@ deg)</tt> all represent the same
--   transformation, namely, a counterclockwise rotation by a right angle.
--   To rotate about some point other than the local origin, see
--   <tt>rotateAbout</tt>.
--   
--   Note that writing <tt>rotate (1/4)</tt>, with no <a>Angle</a>
--   constructor, will yield an error since GHC cannot figure out which
--   sort of angle you want to use. In this common situation you can use
--   <tt>rotateBy</tt>, which interprets its argument as a number of turns.
rotate :: (InSpace V2 n t, Transformable t, Floating n) => Angle n -> t -> t
instance (Diagrams.Core.V.V t GHC.Types.~ Linear.V2.V2, Diagrams.Core.V.N t GHC.Types.~ n, Diagrams.Core.Transform.Transformable t, GHC.Internal.Float.Floating n) => Data.Monoid.Action.Action (Diagrams.Angle.Angle n) t
instance Linear.Vector.Additive Diagrams.Angle.Angle
instance GHC.Internal.Base.Applicative Diagrams.Angle.Angle
instance GHC.Internal.Enum.Enum n => GHC.Internal.Enum.Enum (Diagrams.Angle.Angle n)
instance GHC.Classes.Eq n => GHC.Classes.Eq (Diagrams.Angle.Angle n)
instance GHC.Internal.Base.Functor Diagrams.Angle.Angle
instance Diagrams.Angle.HasPhi v => Diagrams.Angle.HasPhi (Linear.Affine.Point v)
instance Diagrams.Angle.HasTheta v => Diagrams.Angle.HasTheta (Linear.Affine.Point v)
instance GHC.Internal.Num.Num n => GHC.Internal.Base.Monoid (Diagrams.Angle.Angle n)
instance GHC.Classes.Ord n => GHC.Classes.Ord (Diagrams.Angle.Angle n)
instance GHC.Internal.Read.Read n => GHC.Internal.Read.Read (Diagrams.Angle.Angle n)
instance GHC.Internal.Num.Num n => GHC.Internal.Base.Semigroup (Diagrams.Angle.Angle n)
instance GHC.Internal.Show.Show n => GHC.Internal.Show.Show (Diagrams.Angle.Angle n)


-- | Type for representing directions, polymorphic in vector space
module Diagrams.Direction

-- | A vector is described by a <tt>Direction</tt> and a magnitude. So we
--   can think of a <tt>Direction</tt> as a vector that has forgotten its
--   magnitude. <tt>Direction</tt>s can be used with <a>fromDirection</a>
--   and the lenses provided by its instances.
data Direction (v :: Type -> Type) n

-- | _Dir is provided to allow efficient implementations of functions in
--   particular vector-spaces, but should be used with care as it exposes
--   too much information.
_Dir :: forall v n p f. (Profunctor p, Functor f) => p (v n) (f (v n)) -> p (Direction v n) (f (Direction v n))

-- | <tt>direction v</tt> is the direction in which <tt>v</tt> points.
--   Returns an unspecified value when given the zero vector as input.
direction :: v n -> Direction v n

-- | Synonym for <a>direction</a>.
dir :: v n -> Direction v n

-- | <tt>fromDirection d</tt> is the unit vector in the direction
--   <tt>d</tt>.
fromDirection :: (Metric v, Floating n) => Direction v n -> v n

-- | Synonym for <a>fromDirection</a>.
fromDir :: (Metric v, Floating n) => Direction v n -> v n

-- | compute the positive angle between the two directions in their common
--   plane
angleBetweenDirs :: forall (v :: Type -> Type) n. (Metric v, Floating n, Ord n) => Direction v n -> Direction v n -> Angle n

-- | <tt>dirBetween p q</tt> returns the direction from <tt>p</tt> to
--   <tt>q</tt>.
dirBetween :: forall (v :: Type -> Type) n. (Additive v, Num n) => Point v n -> Point v n -> Direction v n
instance GHC.Classes.Eq (v n) => GHC.Classes.Eq (Diagrams.Direction.Direction v n)
instance GHC.Internal.Base.Functor v => GHC.Internal.Base.Functor (Diagrams.Direction.Direction v)
instance Diagrams.Angle.HasPhi v => Diagrams.Angle.HasPhi (Diagrams.Direction.Direction v)
instance Diagrams.Angle.HasTheta v => Diagrams.Angle.HasTheta (Diagrams.Direction.Direction v)
instance GHC.Classes.Ord (v n) => GHC.Classes.Ord (Diagrams.Direction.Direction v n)
instance GHC.Internal.Read.Read (v n) => GHC.Internal.Read.Read (Diagrams.Direction.Direction v n)
instance GHC.Internal.Show.Show (v n) => GHC.Internal.Show.Show (Diagrams.Direction.Direction v n)
instance (Diagrams.Core.V.V (v n) GHC.Types.~ v, Diagrams.Core.V.N (v n) GHC.Types.~ n, Diagrams.Core.Transform.Transformable (v n)) => Diagrams.Core.Transform.Transformable (Diagrams.Direction.Direction v n)


-- | A query is a function that maps points in a vector space to values in
--   some monoid. Queries naturally form a monoid, with two queries being
--   combined pointwise.
module Diagrams.Query

-- | A query is a function that maps points in a vector space to values in
--   some monoid. Queries naturally form a monoid, with two queries being
--   combined pointwise.
--   
--   The idea for annotating diagrams with monoidal queries came from the
--   graphics-drawingcombinators package,
--   <a>http://hackage.haskell.org/package/graphics-drawingcombinators</a>.
newtype Query (v :: Type -> Type) n m
Query :: (Point v n -> m) -> Query (v :: Type -> Type) n m
[runQuery] :: Query (v :: Type -> Type) n m -> Point v n -> m

-- | Types which can answer a <a>Query</a> about points inside the
--   geometric object.
--   
--   If <tt>t</tt> and <tt>m</tt> are both a <a>Semigroup</a>s,
--   <a>getQuery</a> should satisfy
--   
--   <pre>
--   <a>getQuery</a> (t1 &lt;&gt; t2) = <a>getQuery</a> t1 &lt;&gt; <a>getQuery</a> t2
--   </pre>
class HasQuery t m | t -> m

-- | Extract the query of an object.
getQuery :: HasQuery t m => t -> Query (V t) (N t) m

-- | Sample a diagram's query function at a given point.
--   
--   <pre>
--   <a>sample</a> :: <a>QDiagram</a> b v n m -&gt; <a>Point</a> v n -&gt; m
--   <a>sample</a> :: <a>Query</a> v n m      -&gt; <a>Point</a> v n -&gt; m
--   <a>sample</a> :: <a>BoundingBox</a> v n  -&gt; <a>Point</a> v n -&gt; <a>Any</a>
--   <a>sample</a> :: <a>Path</a> <tt>V2</tt> <a>Double</a>   -&gt; <a>Point</a> v n -&gt; <a>Crossings</a>
--   </pre>
sample :: HasQuery t m => t -> Point (V t) (N t) -> m

-- | Test if a point is not equal to <a>mempty</a>.
--   
--   <pre>
--   <a>inquire</a> :: <a>QDiagram</a> b v n <a>Any</a> -&gt; <a>Point</a> v n -&gt; <a>Bool</a>
--   <a>inquire</a> :: <a>Query</a> v n <a>Any</a>      -&gt; <a>Point</a> v n -&gt; <a>Bool</a>
--   <a>inquire</a> :: <a>BoundingBox</a> v n  -&gt; <a>Point</a> v n -&gt; <a>Bool</a>
--   </pre>
inquire :: HasQuery t Any => t -> Point (V t) (N t) -> Bool

-- | Get the query function associated with a diagram.
query :: forall m b (v :: Type -> Type) n. Monoid m => QDiagram b v n m -> Query v n m

-- | Set the query value for <a>True</a> points in a diagram (<i>i.e.</i>
--   points "inquire" the diagram); <a>False</a> points will be set to
--   <a>mempty</a>.
value :: forall m b (v :: Type -> Type) n. Monoid m => m -> QDiagram b v n Any -> QDiagram b v n m

-- | Reset the query values of a diagram to <tt>True</tt>/<tt>False</tt>:
--   any values equal to <a>mempty</a> are set to <a>False</a>; any other
--   values are set to <a>True</a>.
resetValue :: forall m b (v :: Type -> Type) n. (Eq m, Monoid m) => QDiagram b v n m -> QDiagram b v n Any

-- | Set all the query values of a diagram to <a>False</a>.
clearValue :: forall b (v :: Type -> Type) n m. QDiagram b v n m -> QDiagram b v n Any
instance GHC.Internal.Base.Monoid m => Diagrams.Query.HasQuery (Diagrams.Core.Types.QDiagram b v n m) m
instance Diagrams.Query.HasQuery (Diagrams.Core.Query.Query v n m) m


-- | Diagrams may have <i>attributes</i> which affect the way they are
--   rendered. This module defines some common attributes relevant in 3D;
--   particular backends may also define more backend-specific attributes.
--   
--   Every attribute type must have a <i>semigroup</i> structure, that is,
--   an associative binary operation for combining two attributes into one.
--   Unless otherwise noted, all the attributes defined here use the
--   <a>Last</a> structure, that is, combining two attributes simply keeps
--   the second one and throws away the first. This means that child
--   attributes always override parent attributes.
module Diagrams.ThreeD.Attributes

-- | <tt>SurfaceColor</tt> is the inherent pigment of an object, assumed to
--   be opaque.
newtype SurfaceColor
SurfaceColor :: Last (Colour Double) -> SurfaceColor
_SurfaceColor :: Iso' SurfaceColor (Colour Double)

-- | Set the surface color.
sc :: HasStyle d => Colour Double -> d -> d

-- | Lens onto the surface colour of a style.
_sc :: forall (v :: Type -> Type) n f. Functor f => (Maybe (Colour Double) -> f (Maybe (Colour Double))) -> Style v n -> f (Style v n)

-- | <tt>Diffuse</tt> is the fraction of incident light reflected
--   diffusely, that is, in all directions. The actual light reflected is
--   the product of this value, the incident light, and the
--   <tt>SurfaceColor</tt> Attribute. For physical reasonableness,
--   <tt>Diffuse</tt> should have a value between 0 and 1; this is not
--   checked.
newtype Diffuse
Diffuse :: Last Double -> Diffuse

-- | Isomorphism between <a>Diffuse</a> and <a>Double</a>
_Diffuse :: Iso' Diffuse Double

-- | Set the diffuse reflectance.
diffuse :: HasStyle d => Double -> d -> d

-- | Lens onto the possible diffuse reflectance in a style.
_diffuse :: forall (v :: Type -> Type) n f. Functor f => (Maybe Double -> f (Maybe Double)) -> Style v n -> f (Style v n)

-- | <tt>Ambient</tt> is an ad-hoc representation of indirect lighting. The
--   product of <tt>Ambient</tt> and <tt>SurfaceColor</tt> is added to the
--   light leaving an object due to diffuse and specular terms.
--   <tt>Ambient</tt> can be set per-object, and can be loosely thought of
--   as the product of indirect lighting incident on that object and the
--   diffuse reflectance.
newtype Ambient
Ambient :: Last Double -> Ambient
_Ambient :: Iso' Ambient Double

-- | Set the emittance due to ambient light.
ambient :: HasStyle d => Double -> d -> d

-- | Lens onto the possible ambience in a style.
_ambient :: forall (v :: Type -> Type) n f. Functor f => (Maybe Double -> f (Maybe Double)) -> Style v n -> f (Style v n)

-- | A specular highlight has two terms, the intensity, between 0 and 1,
--   and the size. The highlight size is assumed to be the exponent in a
--   Phong shading model (though Backends are free to use a different
--   shading model). In this model, reasonable values are between 1 and 50
--   or so, with higher values for shinier objects. Physically, the
--   intensity and the value of <tt>Diffuse</tt> must add up to less than
--   1; this is not enforced.
data Specular
Specular :: Double -> Double -> Specular
[_specularIntensity] :: Specular -> Double
[_specularSize] :: Specular -> Double
specularIntensity :: Lens' Specular Double
specularSize :: Lens' Specular Double
newtype Highlight
Highlight :: Last Specular -> Highlight
_Highlight :: Iso' Highlight Specular

-- | Set the specular highlight.
highlight :: HasStyle d => Specular -> d -> d

-- | Lens onto the possible specular highlight in a style
_highlight :: forall (v :: Type -> Type) n f. Functor f => (Maybe Specular -> f (Maybe Specular)) -> Style v n -> f (Style v n)

-- | Traversal over the highlight intensity of a style. If the style has no
--   <a>Specular</a>, setting this will do nothing.
highlightIntensity :: forall (v :: Type -> Type) n f. Applicative f => (Double -> f Double) -> Style v n -> f (Style v n)

-- | Traversal over the highlight size in a style. If the style has no
--   <a>Specular</a>, setting this will do nothing.
highlightSize :: forall (v :: Type -> Type) n f. Applicative f => (Double -> f Double) -> Style v n -> f (Style v n)
instance Diagrams.Core.Style.AttributeClass Diagrams.ThreeD.Attributes.Ambient
instance Diagrams.Core.Style.AttributeClass Diagrams.ThreeD.Attributes.Diffuse
instance Diagrams.Core.Style.AttributeClass Diagrams.ThreeD.Attributes.Highlight
instance Diagrams.Core.Style.AttributeClass Diagrams.ThreeD.Attributes.SurfaceColor
instance GHC.Internal.Base.Semigroup Diagrams.ThreeD.Attributes.Ambient
instance GHC.Internal.Base.Semigroup Diagrams.ThreeD.Attributes.Diffuse
instance GHC.Internal.Base.Semigroup Diagrams.ThreeD.Attributes.Highlight
instance GHC.Internal.Base.Semigroup Diagrams.ThreeD.Attributes.SurfaceColor
instance GHC.Internal.Show.Show Diagrams.ThreeD.Attributes.Ambient
instance GHC.Internal.Show.Show Diagrams.ThreeD.Attributes.Diffuse
instance GHC.Internal.Show.Show Diagrams.ThreeD.Attributes.Highlight
instance GHC.Internal.Show.Show Diagrams.ThreeD.Attributes.Specular
instance GHC.Internal.Show.Show Diagrams.ThreeD.Attributes.SurfaceColor


-- | Affine transformations, parameterized by any vector space. For
--   transformations on particular vector spaces, see <i>e.g.</i>
--   <a>Diagrams.TwoD.Transform</a>.
module Diagrams.Transform

-- | General (affine) transformations, represented by an invertible linear
--   map, its <i>transpose</i>, and a vector representing a translation
--   component.
--   
--   By the <i>transpose</i> of a linear map we mean simply the linear map
--   corresponding to the transpose of the map's matrix representation. For
--   example, any scale is its own transpose, since scales are represented
--   by matrices with zeros everywhere except the diagonal. The transpose
--   of a rotation is the same as its inverse.
--   
--   The reason we need to keep track of transposes is because it turns out
--   that when transforming a shape according to some linear map L, the
--   shape's <i>normal vectors</i> transform according to L's inverse
--   transpose. (For a more detailed explanation and proof, see
--   <a>https://wiki.haskell.org/Diagrams/Dev/Transformations</a>.) This is
--   exactly what we need when transforming bounding functions, which are
--   defined in terms of <i>perpendicular</i> (i.e. normal) hyperplanes.
--   
--   For more general, non-invertible transformations, see
--   <tt>Diagrams.Deform</tt> (in <tt>diagrams-lib</tt>).
data Transformation (v :: Type -> Type) n

-- | Invert a transformation.
inv :: forall (v :: Type -> Type) n. (Functor v, Num n) => Transformation v n -> Transformation v n

-- | Get the translational component of a transformation.
transl :: Transformation v n -> v n

-- | Apply a transformation to a vector. Note that any translational
--   component of the transformation will not affect the vector, since
--   vectors are invariant under translation.
apply :: Transformation v n -> v n -> v n

-- | Apply a transformation to a point.
papply :: forall (v :: Type -> Type) n. (Additive v, Num n) => Transformation v n -> Point v n -> Point v n

-- | Type class for things <tt>t</tt> which can be transformed.
class Transformable t

-- | Apply a transformation to an object.
transform :: Transformable t => Transformation (V t) (N t) -> t -> t

-- | Create a translation.
translation :: v n -> Transformation v n

-- | Translate by a vector.
translate :: Transformable t => Vn t -> t -> t

-- | Translate the object by the translation that sends the origin to the
--   given point. Note that this is dual to <a>moveOriginTo</a>, i.e. we
--   should have
--   
--   <pre>
--   moveTo (origin .^+ v) === moveOriginTo (origin .^- v)
--   
--   </pre>
--   
--   For types which are also <tt>Transformable</tt>, this is essentially
--   the same as <tt>translate</tt>, i.e.
--   
--   <pre>
--   moveTo (origin .^+ v) === translate v
--   
--   </pre>
moveTo :: forall (v :: Type -> Type) n t. (InSpace v n t, HasOrigin t) => Point v n -> t -> t

-- | A flipped variant of <a>moveTo</a>, provided for convenience. Useful
--   when writing a function which takes a point as an argument, such as
--   when using <tt>withName</tt> and friends.
place :: forall (v :: Type -> Type) n t. (InSpace v n t, HasOrigin t) => t -> Point v n -> t

-- | Create a uniform scaling transformation.
scaling :: forall (v :: Type -> Type) n. (Additive v, Fractional n) => n -> Transformation v n

-- | Scale uniformly in every dimension by the given scalar.
scale :: forall (v :: Type -> Type) n a. (InSpace v n a, Eq n, Fractional n, Transformable a) => n -> a -> a

-- | Conjugate one transformation by another. <tt>conjugate t1 t2</tt> is
--   the transformation which performs first <tt>t1</tt>, then <tt>t2</tt>,
--   then the inverse of <tt>t1</tt>.
conjugate :: forall (v :: Type -> Type) n. (Additive v, Num n) => Transformation v n -> Transformation v n -> Transformation v n

-- | Carry out some transformation "under" another one: <tt>f
--   <a>`underT`</a> t</tt> first applies <tt>t</tt>, then <tt>f</tt>, then
--   the inverse of <tt>t</tt>. For example, <tt><tt>scaleX</tt> 2
--   <a>`underT`</a> <tt>rotation</tt> (-1/8 @@ Turn)</tt> is the
--   transformation which scales by a factor of 2 along the diagonal line y
--   = x.
--   
--   Note that
--   
--   <pre>
--   (transform t2) <a>underT</a> t1 == transform (conjugate t1 t2)
--   </pre>
--   
--   for all transformations <tt>t1</tt> and <tt>t2</tt>.
--   
--   See also the isomorphisms like <a>transformed</a>, <a>movedTo</a>,
--   <a>movedFrom</a>, and <a>translated</a>.
underT :: forall (v :: Type -> Type) n a b. (InSpace v n a, SameSpace a b, Transformable a, Transformable b) => (a -> b) -> Transformation v n -> a -> b

-- | Use a <a>Transformation</a> to make an <a>Iso</a> between an object
--   transformed and untransformed. This is useful for carrying out
--   functions <a>under</a> another transform:
--   
--   <pre>
--   under (transformed t) f               == transform (inv t) . f . transform t
--   under (transformed t1) (transform t2) == transform (conjugate t1 t2)
--   transformed t ## a                    == transform t a
--   a ^. transformed t                    == transform (inv t) a
--   </pre>
transformed :: forall (v :: Type -> Type) n a b. (InSpace v n a, SameSpace a b, Transformable a, Transformable b) => Transformation v n -> Iso a b a b

-- | Use a vector to make an <a>Iso</a> between an object translated and
--   untranslated.
--   
--   <pre>
--   under (translated v) f == translate (-v) . f . translate v
--   translated v ## a      == translate v a
--   a ^. translated v      == translate (-v) a
--   over (translated v) f  == translate v . f . translate (-v)
--   </pre>
translated :: (InSpace v n a, SameSpace a b, Transformable a, Transformable b) => v n -> Iso a b a b

-- | Use a <a>Point</a> to make an <a>Iso</a> between an object moved to
--   and from that point:
--   
--   <pre>
--   under (movedTo p) f == moveTo (-p) . f . moveTo p
--   over (movedTo p) f  == moveTo p . f . moveTo (-p)
--   movedTo p           == from (movedFrom p)
--   movedTo p ## a      == moveTo p a
--   a ^. movedTo p      == moveOriginTo p a
--   </pre>
movedTo :: forall (v :: Type -> Type) n a b. (InSpace v n a, SameSpace a b, HasOrigin a, HasOrigin b) => Point v n -> Iso a b a b

-- | Use a <a>Transformation</a> to make an <a>Iso</a> between an object
--   transformed and untransformed. We have
--   
--   <pre>
--   under (movedFrom p) f == moveTo p . f . moveTo (-p)
--   movedFrom p           == from (movedTo p)
--   movedFrom p ## a      == moveOriginTo p a
--   a ^. movedFrom p      == moveTo p a
--   over (movedFrom p) f  == moveTo (-p) . f . moveTo p
--   </pre>
movedFrom :: forall (v :: Type -> Type) n a b. (InSpace v n a, SameSpace a b, HasOrigin a, HasOrigin b) => Point v n -> Iso a b a b

-- | Class of types which have an intrinsic notion of a "local origin",
--   i.e. things which are not invariant under translation, and which allow
--   the origin to be moved.
--   
--   One might wonder why not just use <tt>Transformable</tt> instead of
--   having a separate class for <a>HasOrigin</a>; indeed, for types which
--   are instances of both we should have the identity
--   
--   <pre>
--   moveOriginTo (origin .^+ v) === translate (negated v)
--   
--   </pre>
--   
--   The reason is that some things (e.g. vectors, <tt>Trail</tt>s) are
--   transformable but are translationally invariant, i.e. have no origin.
class HasOrigin t

-- | Move the local origin to another point.
--   
--   Note that this function is in some sense dual to <tt>translate</tt>
--   (for types which are also <tt>Transformable</tt>); moving the origin
--   itself while leaving the object "fixed" is dual to fixing the origin
--   and translating the diagram.
moveOriginTo :: HasOrigin t => Point (V t) (N t) -> t -> t

-- | Move the local origin by a relative vector.
moveOriginBy :: (V t ~ v, N t ~ n, HasOrigin t) => v n -> t -> t


-- | Bernstein polynomials, used internally by code to find intersections
--   of paths. This module is probably not of any relevance to most users
--   of diagrams.
module Diagrams.TwoD.Segment.Bernstein
data BernsteinPoly n
BernsteinPoly :: Int -> [n] -> BernsteinPoly n
[bernsteinDegree] :: BernsteinPoly n -> Int
[bernsteinCoeffs] :: BernsteinPoly n -> [n]

-- | Create a bernstein polynomial from a list of coëfficients.
listToBernstein :: Fractional n => [n] -> BernsteinPoly n

-- | Evaluate the bernstein polynomial.
evaluateBernstein :: Fractional n => BernsteinPoly n -> n -> n

-- | Degree elevate a bernstein polynomial a number of times.
degreeElevate :: Fractional n => BernsteinPoly n -> Int -> BernsteinPoly n

-- | Find the derivative of a bernstein polynomial.
bernsteinDeriv :: Fractional n => BernsteinPoly n -> BernsteinPoly n

-- | Evaluate the bernstein polynomial and its derivatives.
evaluateBernsteinDerivs :: Fractional n => BernsteinPoly n -> n -> [n]
instance GHC.Internal.Num.Num n => Diagrams.Parametric.DomainBounds (Diagrams.TwoD.Segment.Bernstein.BernsteinPoly n)
instance GHC.Internal.Real.Fractional n => Diagrams.Parametric.EndValues (Diagrams.TwoD.Segment.Bernstein.BernsteinPoly n)
instance GHC.Internal.Base.Functor Diagrams.TwoD.Segment.Bernstein.BernsteinPoly
instance GHC.Internal.Real.Fractional n => GHC.Internal.Num.Num (Diagrams.TwoD.Segment.Bernstein.BernsteinPoly n)
instance GHC.Internal.Real.Fractional n => Diagrams.Parametric.Parametric (Diagrams.TwoD.Segment.Bernstein.BernsteinPoly n)
instance GHC.Internal.Real.Fractional n => Diagrams.Parametric.Sectionable (Diagrams.TwoD.Segment.Bernstein.BernsteinPoly n)
instance GHC.Internal.Show.Show n => GHC.Internal.Show.Show (Diagrams.TwoD.Segment.Bernstein.BernsteinPoly n)


-- | Basic types for two-dimensional Euclidean space.
module Diagrams.TwoD.Types

-- | A 2-dimensional vector
--   
--   <pre>
--   &gt;&gt;&gt; pure 1 :: V2 Int
--   V2 1 1
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; V2 1 2 + V2 3 4
--   V2 4 6
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; V2 1 2 * V2 3 4
--   V2 3 8
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; sum (V2 1 2)
--   3
--   </pre>
data V2 a
V2 :: !a -> !a -> V2 a

-- | A space that has at least 1 basis vector <a>_x</a>.
class R1 (t :: Type -> Type)

-- | <pre>
--   &gt;&gt;&gt; V1 2 ^._x
--   2
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; V1 2 &amp; _x .~ 3
--   V1 3
--   </pre>
_x :: R1 t => Lens' (t a) a

-- | A space that distinguishes 2 orthogonal basis vectors <a>_x</a> and
--   <a>_y</a>, but may have more.
class R1 t => R2 (t :: Type -> Type)

-- | <pre>
--   &gt;&gt;&gt; V2 1 2 ^._y
--   2
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; V2 1 2 &amp; _y .~ 3
--   V2 1 3
--   </pre>
_y :: R2 t => Lens' (t a) a
_xy :: R2 t => Lens' (t a) (V2 a)
type P2 = Point V2
type T2 = Transformation V2

-- | Construct a 2D vector from a pair of components. See also
--   <tt>&amp;</tt>.
r2 :: (n, n) -> V2 n

-- | Convert a 2D vector back into a pair of components. See also
--   <tt>coords</tt>.
unr2 :: V2 n -> (n, n)

-- | Curried form of <a>r2</a>.
mkR2 :: n -> n -> V2 n
r2Iso :: forall n p f. (Profunctor p, Functor f) => p (n, n) (f (n, n)) -> p (V2 n) (f (V2 n))

-- | Construct a 2D point from a pair of coordinates. See also
--   <tt>^&amp;</tt>.
p2 :: (n, n) -> P2 n

-- | Curried form of <a>p2</a>.
mkP2 :: n -> n -> P2 n

-- | Convert a 2D point back into a pair of coordinates. See also
--   <tt>coords</tt>.
unp2 :: P2 n -> (n, n)
p2Iso :: forall n p f. (Profunctor p, Functor f) => p (n, n) (f (n, n)) -> p (Point V2 n) (f (Point V2 n))
r2PolarIso :: RealFloat n => Iso' (V2 n) (n, Angle n)

-- | A space which has magnitude <a>_r</a> that can be calculated
--   numerically.
class HasR (t :: Type -> Type)
_r :: (HasR t, RealFloat n) => Lens' (t n) n
instance Diagrams.TwoD.Types.HasR v => Diagrams.TwoD.Types.HasR (Linear.Affine.Point v)
instance Diagrams.TwoD.Types.HasR Linear.V2.V2
instance Diagrams.Angle.HasTheta Linear.V2.V2
instance Diagrams.Core.Transform.Transformable (Linear.V2.V2 n)


-- | Basic types for three-dimensional Euclidean space.
module Diagrams.ThreeD.Types

-- | Construct a 3D vector from a triple of components.
r3 :: (n, n, n) -> V3 n

-- | Convert a 3D vector back into a triple of components.
unr3 :: V3 n -> (n, n, n)

-- | Curried version of <a>r3</a>.
mkR3 :: n -> n -> n -> V3 n

-- | Construct a 3D point from a triple of coordinates.
p3 :: (n, n, n) -> P3 n

-- | Convert a 3D point back into a triple of coordinates.
unp3 :: P3 n -> (n, n, n)

-- | Curried version of <a>r3</a>.
mkP3 :: n -> n -> n -> P3 n
r3Iso :: forall n p f. (Profunctor p, Functor f) => p (n, n, n) (f (n, n, n)) -> p (V3 n) (f (V3 n))
p3Iso :: forall n p f. (Profunctor p, Functor f) => p (n, n, n) (f (n, n, n)) -> p (P3 n) (f (P3 n))

-- | <tt>project u v</tt> computes the projection of <tt>v</tt> onto
--   <tt>u</tt>.
project :: (Metric v, Fractional a) => v a -> v a -> v a
r3SphericalIso :: RealFloat n => Iso' (V3 n) (n, Angle n, Angle n)
r3CylindricalIso :: RealFloat n => Iso' (V3 n) (n, Angle n, n)

-- | A 3-dimensional vector
data V3 a
V3 :: !a -> !a -> !a -> V3 a
type P3 = Point V3
type T3 = Transformation V3

-- | A space that has at least 1 basis vector <a>_x</a>.
class R1 (t :: Type -> Type)

-- | <pre>
--   &gt;&gt;&gt; V1 2 ^._x
--   2
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; V1 2 &amp; _x .~ 3
--   V1 3
--   </pre>
_x :: R1 t => Lens' (t a) a

-- | A space that distinguishes 2 orthogonal basis vectors <a>_x</a> and
--   <a>_y</a>, but may have more.
class R1 t => R2 (t :: Type -> Type)

-- | <pre>
--   &gt;&gt;&gt; V2 1 2 ^._y
--   2
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; V2 1 2 &amp; _y .~ 3
--   V2 1 3
--   </pre>
_y :: R2 t => Lens' (t a) a
_xy :: R2 t => Lens' (t a) (V2 a)

-- | A space that distinguishes 3 orthogonal basis vectors: <a>_x</a>,
--   <a>_y</a>, and <a>_z</a>. (It may have more)
class R2 t => R3 (t :: Type -> Type)

-- | <pre>
--   &gt;&gt;&gt; V3 1 2 3 ^. _z
--   3
--   </pre>
_z :: R3 t => Lens' (t a) a
_xyz :: R3 t => Lens' (t a) (V3 a)
instance Diagrams.Angle.HasPhi Linear.V3.V3
instance Diagrams.TwoD.Types.HasR Linear.V3.V3
instance Diagrams.Angle.HasTheta Linear.V3.V3
instance Diagrams.Core.Transform.Transformable (Linear.V3.V3 n)


-- | Functions for converting between <a>Transformation</a>s and matricies.
module Diagrams.Transform.Matrix

-- | Build a matrix from a <a>Transformation</a>, ignoring the translation.
mkMat :: (HasBasis v, Num n) => Transformation v n -> v (v n)

-- | Build a 3D transformation matrix in homogeneous coordinates from a
--   'Transformation V3'.
mkMatHomo :: Num n => Transformation V3 n -> M44 n

-- | Make a 2D transformation from a 2x2 transform matrix and a translation
--   vector. Does not check if the matrix is not invertible (in which case
--   the <a>T2</a> will be invalid).
fromMat22 :: Floating n => M22 n -> V2 n -> T2 n

-- | Make a 3D transformation from a 3x3 transform matrix and a translation
--   vector. Does not check if the matrix is not invertible (in which case
--   the <a>T3</a> will be invalid).
fromMat33 :: Floating n => M33 n -> V3 n -> T3 n

-- | Build a transform with a maxtrix along with its inverse.
fromMatWithInv :: (Additive v, Distributive v, Foldable v, Num n) => v (v n) -> v (v n) -> v n -> Transformation v n

-- | Prism onto a 2D transformation from a 2x2 transform matrix and
--   translation vector. Does not check if the matrix is invertible (in
--   which case the <a>T2</a> will be invalid).
mat22 :: Floating n => Iso' (M22 n, V2 n) (T2 n)

-- | Prism onto a 3D transformation from a 3x3 transform matrix and
--   translation vector. Does not check if the matrix is invertible (in
--   which case the <a>T3</a> will be invalid).
mat33 :: Floating n => Iso' (M33 n, V3 n) (T3 n)


-- | Types to specify lighting for 3D rendering.
module Diagrams.ThreeD.Light

-- | A <tt>PointLight</tt> radiates uniformly in all directions from a
--   given point.
data PointLight n
PointLight :: Point V3 n -> Colour Double -> PointLight n

-- | A <tt>ParallelLight</tt> casts parallel rays in the specified
--   direction, from some distant location outside the scene.
data ParallelLight n
ParallelLight :: V3 n -> Colour Double -> ParallelLight n

-- | Construct a Diagram with a single PointLight at the origin, which
--   takes up no space.
pointLight :: (Typeable n, Num n, Ord n, Renderable (PointLight n) b) => Colour Double -> QDiagram b V3 n Any

-- | Construct a Diagram with a single ParallelLight, which takes up no
--   space.
parallelLight :: (Typeable n, OrderedField n, Renderable (ParallelLight n) b) => Direction V3 n -> Colour Double -> QDiagram b V3 n Any
instance Diagrams.Core.Transform.Transformable (Diagrams.ThreeD.Light.ParallelLight n)
instance GHC.Internal.Real.Fractional n => Diagrams.Core.Transform.Transformable (Diagrams.ThreeD.Light.PointLight n)


-- | Two-dimensional vectors.
module Diagrams.TwoD.Vector

-- | The unit vector in the positive X direction.
unitX :: (R1 v, Additive v, Num n) => v n

-- | The unit vector in the positive Y direction.
unitY :: (R2 v, Additive v, Num n) => v n

-- | The unit vector in the negative X direction.
unit_X :: (R1 v, Additive v, Num n) => v n

-- | The unit vector in the negative Y direction.
unit_Y :: (R2 v, Additive v, Num n) => v n

-- | A <a>Direction</a> pointing in the X direction.
xDir :: forall (v :: Type -> Type) n. (R1 v, Additive v, Num n) => Direction v n

-- | A <a>Direction</a> pointing in the Y direction.
yDir :: forall (v :: Type -> Type) n. (R2 v, Additive v, Num n) => Direction v n

-- | A unit vector at a specified angle counter-clockwise from the positive
--   x-axis
angleV :: Floating n => Angle n -> V2 n

-- | A direction at a specified angle counter-clockwise from the
--   <a>xDir</a>.
angleDir :: Floating n => Angle n -> Direction V2 n

-- | A unit vector at a specified angle counter-clockwise from the positive
--   X axis.
e :: Floating n => Angle n -> V2 n

-- | Signed angle between two vectors. Currently defined as
--   
--   <pre>
--   signedAngleBetween u v = (u ^. _theta) ^-^ (v ^. _theta)
--   </pre>
signedAngleBetween :: RealFloat n => V2 n -> V2 n -> Angle n

-- | Same as <a>signedAngleBetween</a> but for <tt>Directions</tt>s.
signedAngleBetweenDirs :: RealFloat n => Direction V2 n -> Direction V2 n -> Angle n

-- | the counter-clockwise perpendicular vector
--   
--   <pre>
--   &gt;&gt;&gt; perp $ V2 10 20
--   V2 (-20) 10
--   </pre>
perp :: Num a => V2 a -> V2 a

-- | <tt>leftTurn v1 v2</tt> tests whether the direction of <tt>v2</tt> is
--   a left turn from <tt>v1</tt> (that is, if the direction of <tt>v2</tt>
--   can be obtained from that of <tt>v1</tt> by adding an angle 0 &lt;=
--   theta &lt;= tau/2).
leftTurn :: (Num n, Ord n) => V2 n -> V2 n -> Bool

-- | Cross product on vectors in R2.
cross2 :: Num n => V2 n -> V2 n -> n


-- | Transformations specific to two dimensions, with a few generic
--   transformations (uniform scaling, translation) also re-exported for
--   convenience.
module Diagrams.TwoD.Transform
type T2 = Transformation V2

-- | Create a transformation which performs a rotation about the local
--   origin by the given angle. See also <a>rotate</a>.
rotation :: Floating n => Angle n -> Transformation V2 n

-- | Rotate about the local origin by the given angle. Positive angles
--   correspond to counterclockwise rotation, negative to clockwise. The
--   angle can be expressed using any of the <tt>Iso</tt>s on <a>Angle</a>.
--   For example, <tt>rotate (1/4 @@ <a>turn</a>)</tt>, <tt>rotate (tau/4
--   @@ rad)</tt>, and <tt>rotate (90 @@ deg)</tt> all represent the same
--   transformation, namely, a counterclockwise rotation by a right angle.
--   To rotate about some point other than the local origin, see
--   <tt>rotateAbout</tt>.
--   
--   Note that writing <tt>rotate (1/4)</tt>, with no <a>Angle</a>
--   constructor, will yield an error since GHC cannot figure out which
--   sort of angle you want to use. In this common situation you can use
--   <tt>rotateBy</tt>, which interprets its argument as a number of turns.
rotate :: (InSpace V2 n t, Transformable t, Floating n) => Angle n -> t -> t

-- | A synonym for <a>rotate</a>, interpreting its argument in units of
--   turns; it can be more convenient to write <tt>rotateBy (1/4)</tt> than
--   <tt><a>rotate</a> (1/4 @@ <a>turn</a>)</tt>.
rotateBy :: (InSpace V2 n t, Transformable t, Floating n) => n -> t -> t

-- | Use an <a>Angle</a> to make an <a>Iso</a> between an object rotated
--   and unrotated. This us useful for performing actions <a>under</a> a
--   rotation:
--   
--   <pre>
--   under (rotated t) f = rotate (negated t) . f . rotate t
--   rotated t ## a      = rotate t a
--   a ^. rotated t      = rotate (-t) a
--   over (rotated t) f  = rotate t . f . rotate (negated t)
--   </pre>
rotated :: (InSpace V2 n a, Floating n, SameSpace a b, Transformable a, Transformable b) => Angle n -> Iso a b a b

-- | <tt>rotationAbout p</tt> is a rotation about the point <tt>p</tt>
--   (instead of around the local origin).
rotationAround :: Floating n => P2 n -> Angle n -> T2 n

-- | <tt>rotateAbout p</tt> is like <a>rotate</a>, except it rotates around
--   the point <tt>p</tt> instead of around the local origin.
rotateAround :: (InSpace V2 n t, Transformable t, Floating n) => P2 n -> Angle n -> t -> t

-- | The rotation that aligns the x-axis with the given direction.
rotationTo :: OrderedField n => Direction V2 n -> T2 n

-- | Rotate around the local origin such that the x axis aligns with the
--   given direction.
rotateTo :: (InSpace V2 n t, OrderedField n, Transformable t) => Direction V2 n -> t -> t

-- | Construct a transformation which scales by the given factor in the x
--   (horizontal) direction.
scalingX :: forall (v :: Type -> Type) n. (Additive v, R1 v, Fractional n) => n -> Transformation v n

-- | Scale a diagram by the given factor in the x (horizontal) direction.
--   To scale uniformly, use <a>scale</a>.
scaleX :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Fractional n, Transformable t) => n -> t -> t

-- | Construct a transformation which scales by the given factor in the y
--   (vertical) direction.
scalingY :: forall (v :: Type -> Type) n. (Additive v, R2 v, Fractional n) => n -> Transformation v n

-- | Scale a diagram by the given factor in the y (vertical) direction. To
--   scale uniformly, use <a>scale</a>.
scaleY :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Fractional n, Transformable t) => n -> t -> t

-- | Create a uniform scaling transformation.
scaling :: forall (v :: Type -> Type) n. (Additive v, Fractional n) => n -> Transformation v n

-- | Scale uniformly in every dimension by the given scalar.
scale :: forall (v :: Type -> Type) n a. (InSpace v n a, Eq n, Fractional n, Transformable a) => n -> a -> a

-- | <tt>scaleToX w</tt> scales a diagram in the x (horizontal) direction
--   by whatever factor required to make its width <tt>w</tt>.
--   <tt>scaleToX</tt> should not be applied to diagrams with a width of 0,
--   such as <tt>vrule</tt>.
scaleToX :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Enveloped t, Transformable t) => n -> t -> t

-- | <tt>scaleToY h</tt> scales a diagram in the y (vertical) direction by
--   whatever factor required to make its height <tt>h</tt>.
--   <tt>scaleToY</tt> should not be applied to diagrams with a height of
--   0, such as <tt>hrule</tt>.
scaleToY :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Enveloped t, Transformable t) => n -> t -> t

-- | <tt>scaleUToX w</tt> scales a diagram <i>uniformly</i> by whatever
--   factor required to make its width <tt>w</tt>. <tt>scaleUToX</tt>
--   should not be applied to diagrams with a width of 0, such as
--   <tt>vrule</tt>.
scaleUToX :: forall (v :: Type -> Type) n t. (InSpace v n t, R1 v, Enveloped t, Transformable t) => n -> t -> t

-- | <tt>scaleUToY h</tt> scales a diagram <i>uniformly</i> by whatever
--   factor required to make its height <tt>h</tt>. <tt>scaleUToY</tt>
--   should not be applied to diagrams with a height of 0, such as
--   <tt>hrule</tt>.
scaleUToY :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Enveloped t, Transformable t) => n -> t -> t

-- | Construct a transformation which translates by the given distance in
--   the x (horizontal) direction.
translationX :: forall (v :: Type -> Type) n. (Additive v, R1 v, Num n) => n -> Transformation v n

-- | Translate a diagram by the given distance in the x (horizontal)
--   direction.
translateX :: forall (v :: Type -> Type) n t. (InSpace v n t, R1 v, Transformable t) => n -> t -> t

-- | Construct a transformation which translates by the given distance in
--   the y (vertical) direction.
translationY :: forall (v :: Type -> Type) n. (Additive v, R2 v, Num n) => n -> Transformation v n

-- | Translate a diagram by the given distance in the y (vertical)
--   direction.
translateY :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Transformable t) => n -> t -> t

-- | Create a translation.
translation :: v n -> Transformation v n

-- | Translate by a vector.
translate :: Transformable t => Vn t -> t -> t

-- | The angle-preserving linear map that aligns the x-axis unit vector
--   with the given vector. See also <a>scaleRotateTo</a>.
scalingRotationTo :: Floating n => V2 n -> T2 n

-- | Rotate and uniformly scale around the local origin such that the
--   x-axis aligns with the given vector. This satisfies the equation
--   
--   <pre>
--   scaleRotateTo v = rotateTo (dir v) . scale (norm v)
--   </pre>
--   
--   up to floating point rounding errors, but is more accurate and
--   performant since it avoids cancellable uses of trigonometric
--   functions.
scaleRotateTo :: (InSpace V2 n t, Transformable t, Floating n) => V2 n -> t -> t

-- | Construct a transformation which flips a diagram from left to right,
--   i.e. sends the point (x,y) to (-x,y).
reflectionX :: forall (v :: Type -> Type) n. (Additive v, R1 v, Num n) => Transformation v n

-- | Flip a diagram from left to right, i.e. send the point (x,y) to
--   (-x,y).
reflectX :: forall (v :: Type -> Type) n t. (InSpace v n t, R1 v, Transformable t) => t -> t

-- | Construct a transformation which flips a diagram from top to bottom,
--   i.e. sends the point (x,y) to (x,-y).
reflectionY :: forall (v :: Type -> Type) n. (Additive v, R2 v, Num n) => Transformation v n

-- | Flip a diagram from top to bottom, i.e. send the point (x,y) to
--   (x,-y).
reflectY :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Transformable t) => t -> t

-- | Construct a transformation which flips the diagram about x=y, i.e.
--   sends the point (x,y) to (y,x).
reflectionXY :: forall (v :: Type -> Type) n. (Additive v, R2 v, Num n) => Transformation v n

-- | Flips the diagram about x=y, i.e. send the point (x,y) to (y,x).
reflectXY :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Transformable t) => t -> t

-- | <tt>reflectionAbout p d</tt> is a reflection in the line determined by
--   the point <tt>p</tt> and direction <tt>d</tt>.
reflectionAbout :: OrderedField n => P2 n -> Direction V2 n -> T2 n

-- | <tt>reflectAbout p d</tt> reflects a diagram in the line determined by
--   the point <tt>p</tt> and direction <tt>d</tt>.
reflectAbout :: (InSpace V2 n t, OrderedField n, Transformable t) => P2 n -> Direction V2 n -> t -> t

-- | <tt>shearingX d</tt> is the linear transformation which is the
--   identity on y coordinates and sends <tt>(0,1)</tt> to <tt>(d,1)</tt>.
shearingX :: Num n => n -> T2 n

-- | <tt>shearX d</tt> performs a shear in the x-direction which sends
--   <tt>(0,1)</tt> to <tt>(d,1)</tt>.
shearX :: (InSpace V2 n t, Transformable t) => n -> t -> t

-- | <tt>shearingY d</tt> is the linear transformation which is the
--   identity on x coordinates and sends <tt>(1,0)</tt> to <tt>(1,d)</tt>.
shearingY :: Num n => n -> T2 n

-- | <tt>shearY d</tt> performs a shear in the y-direction which sends
--   <tt>(1,0)</tt> to <tt>(1,d)</tt>.
shearY :: (InSpace V2 n t, Transformable t) => n -> t -> t


-- | Wrapper for creating scale-invariant objects in two dimensions.
module Diagrams.Transform.ScaleInv

-- | The <tt>ScaleInv</tt> wrapper creates two-dimensional
--   <i>scale-invariant</i> objects. Intuitively, a scale-invariant object
--   is affected by transformations like translations and rotations, but
--   not by scales.
--   
--   However, this is problematic when it comes to <i>non-uniform</i>
--   scales (<i>e.g.</i> <tt>scaleX 2 . scaleY 3</tt>) since they can
--   introduce a perceived rotational component. The prototypical example
--   is an arrowhead on the end of a path, which should be scale-invariant.
--   However, applying a non-uniform scale to the path but not the
--   arrowhead would leave the arrowhead pointing in the wrong direction.
--   
--   Moreover, for objects whose local origin is not at the local origin of
--   the parent diagram, any scale can result in a translational component
--   as well.
--   
--   The solution is to also store a point (indicating the location,
--   <i>i.e.</i> the local origin) and a unit vector (indicating the
--   <i>direction</i>) along with a scale-invariant object. A
--   transformation to be applied is decomposed into rotational and
--   translational components as follows:
--   
--   <ul>
--   <li>The transformation is applied to the direction vector, and the
--   difference in angle between the original direction vector and its
--   image under the transformation determines the rotational component.
--   The rotation is applied with respect to the stored location, rather
--   than the global origin.</li>
--   <li>The vector from the location to the image of the location under
--   the transformation determines the translational component.</li>
--   </ul>
data ScaleInv t
ScaleInv :: t -> Vn t -> Point (V t) (N t) -> ScaleInv t
[_scaleInvObj] :: ScaleInv t -> t
[_scaleInvDir] :: ScaleInv t -> Vn t
[_scaleInvLoc] :: ScaleInv t -> Point (V t) (N t)
scaleInvObj :: forall t f. Functor f => (t -> f t) -> ScaleInv t -> f (ScaleInv t)
scaleInvDir :: forall t f. Functor f => (Vn t -> f (Vn t)) -> ScaleInv t -> f (ScaleInv t)
scaleInvLoc :: forall t f. Functor f => (Point (V t) (N t) -> f (Point (V t) (N t))) -> ScaleInv t -> f (ScaleInv t)

-- | Create a scale-invariant object pointing in the given direction,
--   located at the origin.
scaleInv :: (V t ~ v, N t ~ n, Additive v, Num n) => t -> v n -> ScaleInv t

-- | Create a diagram from a single scale-invariant primitive. The vector
--   argument specifies the direction in which the primitive is "pointing"
--   (for the purpose of keeping it rotated correctly under non-uniform
--   scaling). The primitive is assumed to be "located" at the origin (for
--   the purpose of translating it correctly under scaling).
--   
--   Note that the resulting diagram will have an <i>empty</i> envelope,
--   trace, and query. The reason is that the envelope, trace, and query
--   cannot be cached---applying a transformation would cause the cached
--   envelope, etc. to get "out of sync" with the scale-invariant object.
--   The intention, at any rate, is that scale-invariant things will be
--   used only as "decorations" (<i>e.g.</i> arrowheads) which should not
--   affect the envelope, trace, and query.
scaleInvPrim :: (V t ~ V2, N t ~ n, RealFloat n, Typeable t, Renderable t b, Monoid m) => t -> V2 n -> QDiagram b (V t) (N t) m
instance (Diagrams.Core.V.V t GHC.Types.~ v, Diagrams.Core.V.N t GHC.Types.~ n, Linear.Vector.Additive v, GHC.Internal.Num.Num n, Diagrams.Core.HasOrigin.HasOrigin t) => Diagrams.Core.HasOrigin.HasOrigin (Diagrams.Transform.ScaleInv.ScaleInv t)
instance (Diagrams.Core.V.V t GHC.Types.~ Linear.V2.V2, Diagrams.Core.V.N t GHC.Types.~ n, GHC.Internal.Float.RealFloat n, Diagrams.Core.Types.Renderable t b) => Diagrams.Core.Types.Renderable (Diagrams.Transform.ScaleInv.ScaleInv t) b
instance (GHC.Internal.Show.Show t, GHC.Internal.Show.Show (Diagrams.Core.V.Vn t)) => GHC.Internal.Show.Show (Diagrams.Transform.ScaleInv.ScaleInv t)
instance (Diagrams.Core.V.V t GHC.Types.~ Linear.V2.V2, Diagrams.Core.V.N t GHC.Types.~ n, GHC.Internal.Float.RealFloat n, Diagrams.Core.Transform.Transformable t) => Diagrams.Core.Transform.Transformable (Diagrams.Transform.ScaleInv.ScaleInv t)


-- | Transformations specific to three dimensions, with a few generic
--   transformations (uniform scaling, translation) also re-exported for
--   convenience.
module Diagrams.ThreeD.Transform
type T3 = Transformation V3

-- | Like <a>aboutZ</a>, but rotates about the X axis, bringing positive
--   y-values towards the positive z-axis.
aboutX :: Floating n => Angle n -> Transformation V3 n

-- | Like <a>aboutZ</a>, but rotates about the Y axis, bringing postive
--   x-values towards the negative z-axis.
aboutY :: Floating n => Angle n -> Transformation V3 n

-- | Create a transformation which rotates by the given angle about a line
--   parallel the Z axis passing through the local origin. A positive angle
--   brings positive x-values towards the positive-y axis.
--   
--   The angle can be expressed using any type which is an instance of
--   <a>Angle</a>. For example, <tt>aboutZ (1/4 @@ <a>turn</a>)</tt>,
--   <tt>aboutZ (tau/4 @@ <a>rad</a>)</tt>, and <tt>aboutZ (90 @@
--   <a>deg</a>)</tt> all represent the same transformation, namely, a
--   counterclockwise rotation by a right angle. For more general
--   rotations, see <a>rotationAbout</a>.
--   
--   Note that writing <tt>aboutZ (1/4)</tt>, with no type annotation, will
--   yield an error since GHC cannot figure out which sort of angle you
--   want to use.
aboutZ :: Floating n => Angle n -> Transformation V3 n

-- | <tt>rotationAbout p d a</tt> is a rotation about a line parallel to
--   <tt>d</tt> passing through <tt>p</tt>.
rotationAbout :: Floating n => Point V3 n -> Direction V3 n -> Angle n -> Transformation V3 n

-- | <tt>rotationAbout p d a</tt> is a rotation about a line parallel to
--   <tt>d</tt> passing through <tt>p</tt>.
rotateAbout :: (InSpace V3 n t, Floating n, Transformable t) => Point V3 n -> Direction V3 n -> Angle n -> t -> t

-- | <tt>pointAt about initial final</tt> produces a rotation which brings
--   the direction <tt>initial</tt> to point in the direction
--   <tt>final</tt> by first panning around <tt>about</tt>, then tilting
--   about the axis perpendicular to <tt>about</tt> and <tt>final</tt>. In
--   particular, if this can be accomplished without tilting, it will be,
--   otherwise if only tilting is necessary, no panning will occur. The
--   tilt will always be between ± 1/4 turn.
pointAt :: (Floating n, Ord n) => Direction V3 n -> Direction V3 n -> Direction V3 n -> Transformation V3 n

-- | pointAt' has the same behavior as <a>pointAt</a>, but takes vectors
--   instead of directions.
pointAt' :: (Floating n, Ord n) => V3 n -> V3 n -> V3 n -> Transformation V3 n

-- | Construct a transformation which scales by the given factor in the x
--   (horizontal) direction.
scalingX :: forall (v :: Type -> Type) n. (Additive v, R1 v, Fractional n) => n -> Transformation v n

-- | Construct a transformation which scales by the given factor in the y
--   (vertical) direction.
scalingY :: forall (v :: Type -> Type) n. (Additive v, R2 v, Fractional n) => n -> Transformation v n

-- | Construct a transformation which scales by the given factor in the z
--   direction.
scalingZ :: forall (v :: Type -> Type) n. (Additive v, R3 v, Fractional n) => n -> Transformation v n

-- | Scale a diagram by the given factor in the x (horizontal) direction.
--   To scale uniformly, use <a>scale</a>.
scaleX :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Fractional n, Transformable t) => n -> t -> t

-- | Scale a diagram by the given factor in the y (vertical) direction. To
--   scale uniformly, use <a>scale</a>.
scaleY :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Fractional n, Transformable t) => n -> t -> t

-- | Scale a diagram by the given factor in the z direction. To scale
--   uniformly, use <a>scale</a>.
scaleZ :: forall (v :: Type -> Type) n t. (InSpace v n t, R3 v, Fractional n, Transformable t) => n -> t -> t

-- | Create a uniform scaling transformation.
scaling :: forall (v :: Type -> Type) n. (Additive v, Fractional n) => n -> Transformation v n

-- | Scale uniformly in every dimension by the given scalar.
scale :: forall (v :: Type -> Type) n a. (InSpace v n a, Eq n, Fractional n, Transformable a) => n -> a -> a

-- | Construct a transformation which translates by the given distance in
--   the x (horizontal) direction.
translationX :: forall (v :: Type -> Type) n. (Additive v, R1 v, Num n) => n -> Transformation v n

-- | Translate a diagram by the given distance in the x (horizontal)
--   direction.
translateX :: forall (v :: Type -> Type) n t. (InSpace v n t, R1 v, Transformable t) => n -> t -> t

-- | Construct a transformation which translates by the given distance in
--   the y (vertical) direction.
translationY :: forall (v :: Type -> Type) n. (Additive v, R2 v, Num n) => n -> Transformation v n

-- | Translate a diagram by the given distance in the y (vertical)
--   direction.
translateY :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Transformable t) => n -> t -> t

-- | Construct a transformation which translates by the given distance in
--   the z direction.
translationZ :: forall (v :: Type -> Type) n. (Additive v, R3 v, Num n) => n -> Transformation v n

-- | Translate a diagram by the given distance in the y direction.
translateZ :: forall (v :: Type -> Type) n t. (InSpace v n t, R3 v, Transformable t) => n -> t -> t

-- | Create a translation.
translation :: v n -> Transformation v n

-- | Translate by a vector.
translate :: Transformable t => Vn t -> t -> t

-- | Construct a transformation which flips a diagram from left to right,
--   i.e. sends the point (x,y) to (-x,y).
reflectionX :: forall (v :: Type -> Type) n. (Additive v, R1 v, Num n) => Transformation v n

-- | Flip a diagram from left to right, i.e. send the point (x,y) to
--   (-x,y).
reflectX :: forall (v :: Type -> Type) n t. (InSpace v n t, R1 v, Transformable t) => t -> t

-- | Construct a transformation which flips a diagram from top to bottom,
--   i.e. sends the point (x,y) to (x,-y).
reflectionY :: forall (v :: Type -> Type) n. (Additive v, R2 v, Num n) => Transformation v n

-- | Flip a diagram from top to bottom, i.e. send the point (x,y) to
--   (x,-y).
reflectY :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Transformable t) => t -> t

-- | Construct a transformation which flips a diagram across z=0, i.e.
--   sends the point (x,y,z) to (x,y,-z).
reflectionZ :: forall (v :: Type -> Type) n. (Additive v, R3 v, Num n) => Transformation v n

-- | Flip a diagram across z=0, i.e. send the point (x,y,z) to (x,y,-z).
reflectZ :: forall (v :: Type -> Type) n t. (InSpace v n t, R3 v, Transformable t) => t -> t

-- | <tt>reflectionAcross p v</tt> is a reflection across the plane through
--   the point <tt>p</tt> and normal to vector <tt>v</tt>. This also works
--   as a 2D transform where <tt>v</tt> is the normal to the line passing
--   through point <tt>p</tt>.
reflectionAcross :: (Metric v, Fractional n) => Point v n -> v n -> Transformation v n

-- | <tt>reflectAcross p v</tt> reflects a diagram across the plane though
--   the point <tt>p</tt> and the vector <tt>v</tt>. This also works as a
--   2D transform where <tt>v</tt> is the normal to the line passing
--   through point <tt>p</tt>.
reflectAcross :: (InSpace v n t, Metric v, Fractional n, Transformable t) => Point v n -> v n -> t -> t


-- | Special functions for points in R2.
module Diagrams.TwoD.Points

-- | Find the convex hull of a list of points using Andrew's monotone chain
--   algorithm O(n log n).
--   
--   Returns clockwise list of points starting from the left-most point.
convexHull2D :: OrderedField n => [P2 n] -> [P2 n]

-- | Find the convex hull of a set of points already sorted in the x
--   direction. The first list of the tuple is the upper hull going
--   clockwise from left-most to right-most point. The second is the lower
--   hull from right-most to left-most in the anti-clockwise direction.
sortedConvexHull :: OrderedField n => [P2 n] -> ([P2 n], [P2 n])


-- | Three-dimensional vectors.
module Diagrams.ThreeD.Vector

-- | The unit vector in the positive X direction.
unitX :: (R1 v, Additive v, Num n) => v n

-- | The unit vector in the positive Y direction.
unitY :: (R2 v, Additive v, Num n) => v n

-- | The unit vector in the positive Y direction.
unitZ :: (R3 v, Additive v, Num n) => v n

-- | The unit vector in the negative X direction.
unit_X :: (R1 v, Additive v, Num n) => v n

-- | The unit vector in the negative Y direction.
unit_Y :: (R2 v, Additive v, Num n) => v n

-- | The unit vector in the negative X direction.
unit_Z :: (R3 v, Additive v, Num n) => v n

-- | A <a>Direction</a> pointing in the X direction.
xDir :: forall (v :: Type -> Type) n. (R1 v, Additive v, Num n) => Direction v n

-- | A <a>Direction</a> pointing in the Y direction.
yDir :: forall (v :: Type -> Type) n. (R2 v, Additive v, Num n) => Direction v n

-- | A <a>Direction</a> pointing in the Z direction.
zDir :: forall (v :: Type -> Type) n. (R3 v, Additive v, Num n) => Direction v n


-- | Various three-dimensional shapes.
module Diagrams.ThreeD.Shapes

-- | Types which can be rendered as 3D Diagrams.
class Skinned t
skin :: (Skinned t, Renderable t b, N t ~ n, TypeableFloat n) => t -> QDiagram b V3 n Any
data Ellipsoid n
Ellipsoid :: Transformation V3 n -> Ellipsoid n

-- | A sphere of radius 1 with its center at the origin.
sphere :: Num n => Ellipsoid n
data Box n
Box :: Transformation V3 n -> Box n

-- | A cube with side length 1, in the positive octant, with one vertex at
--   the origin.
cube :: Num n => Box n
data Frustum n
Frustum :: n -> n -> Transformation V3 n -> Frustum n

-- | A frustum of a right circular cone. It has height 1 oriented along the
--   positive z axis, and radii r0 and r1 at Z=0 and Z=1. <a>cone</a> and
--   <a>cylinder</a> are special cases.
frustum :: Num n => n -> n -> Frustum n

-- | A cone with its base centered on the origin, with radius 1 at the
--   base, height 1, and it's apex on the positive Z axis.
cone :: Num n => Frustum n

-- | A circular cylinder of radius 1 with one end cap centered on the
--   origin, and extending to Z=1.
cylinder :: Num n => Frustum n

-- | A tree of Constructive Solid Geometry operations and the primitives
--   that can be used in them.
data CSG n
CsgEllipsoid :: Ellipsoid n -> CSG n
CsgBox :: Box n -> CSG n
CsgFrustum :: Frustum n -> CSG n
CsgUnion :: [CSG n] -> CSG n
CsgIntersection :: [CSG n] -> CSG n
CsgDifference :: CSG n -> CSG n -> CSG n
union :: (CsgPrim a, CsgPrim b) => a n -> b n -> CSG n
intersection :: (CsgPrim a, CsgPrim b) => a n -> b n -> CSG n
difference :: (CsgPrim a, CsgPrim b) => a n -> b n -> CSG n
instance Diagrams.ThreeD.Shapes.CsgPrim Diagrams.ThreeD.Shapes.Box
instance Diagrams.ThreeD.Shapes.CsgPrim Diagrams.ThreeD.Shapes.CSG
instance Diagrams.ThreeD.Shapes.CsgPrim Diagrams.ThreeD.Shapes.Ellipsoid
instance Diagrams.ThreeD.Shapes.CsgPrim Diagrams.ThreeD.Shapes.Frustum
instance Diagrams.Core.Envelope.OrderedField n => Diagrams.Core.Envelope.Enveloped (Diagrams.ThreeD.Shapes.Box n)
instance GHC.Internal.Float.RealFloat n => Diagrams.Core.Envelope.Enveloped (Diagrams.ThreeD.Shapes.CSG n)
instance Diagrams.Core.Envelope.OrderedField n => Diagrams.Core.Envelope.Enveloped (Diagrams.ThreeD.Shapes.Ellipsoid n)
instance (Diagrams.Core.Envelope.OrderedField n, GHC.Internal.Float.RealFloat n) => Diagrams.Core.Envelope.Enveloped (Diagrams.ThreeD.Shapes.Frustum n)
instance (GHC.Internal.Num.Num n, GHC.Classes.Ord n) => Diagrams.Query.HasQuery (Diagrams.ThreeD.Shapes.Box n) GHC.Internal.Data.Semigroup.Internal.Any
instance (GHC.Internal.Float.Floating n, GHC.Classes.Ord n) => Diagrams.Query.HasQuery (Diagrams.ThreeD.Shapes.CSG n) GHC.Internal.Data.Semigroup.Internal.Any
instance (GHC.Internal.Num.Num n, GHC.Classes.Ord n) => Diagrams.Query.HasQuery (Diagrams.ThreeD.Shapes.Ellipsoid n) GHC.Internal.Data.Semigroup.Internal.Any
instance Diagrams.Core.Envelope.OrderedField n => Diagrams.Query.HasQuery (Diagrams.ThreeD.Shapes.Frustum n) GHC.Internal.Data.Semigroup.Internal.Any
instance GHC.Internal.Real.Fractional n => Diagrams.Core.Types.Renderable (Diagrams.ThreeD.Shapes.Box n) Diagrams.Core.Types.NullBackend
instance GHC.Internal.Real.Fractional n => Diagrams.Core.Types.Renderable (Diagrams.ThreeD.Shapes.Ellipsoid n) Diagrams.Core.Types.NullBackend
instance GHC.Internal.Real.Fractional n => Diagrams.Core.Types.Renderable (Diagrams.ThreeD.Shapes.Frustum n) Diagrams.Core.Types.NullBackend
instance Diagrams.Core.Envelope.OrderedField n => Diagrams.ThreeD.Shapes.Skinned (Diagrams.ThreeD.Shapes.Box n)
instance (GHC.Internal.Float.RealFloat n, GHC.Classes.Ord n) => Diagrams.ThreeD.Shapes.Skinned (Diagrams.ThreeD.Shapes.CSG n)
instance Diagrams.Core.Envelope.OrderedField n => Diagrams.ThreeD.Shapes.Skinned (Diagrams.ThreeD.Shapes.Ellipsoid n)
instance Diagrams.ThreeD.Shapes.Skinned (Diagrams.ThreeD.Shapes.Frustum n)
instance (GHC.Internal.Real.Fractional n, GHC.Classes.Ord n) => Diagrams.Core.Trace.Traced (Diagrams.ThreeD.Shapes.Box n)
instance (GHC.Internal.Float.RealFloat n, GHC.Classes.Ord n) => Diagrams.Core.Trace.Traced (Diagrams.ThreeD.Shapes.CSG n)
instance Diagrams.Core.Envelope.OrderedField n => Diagrams.Core.Trace.Traced (Diagrams.ThreeD.Shapes.Ellipsoid n)
instance (GHC.Internal.Float.RealFloat n, GHC.Classes.Ord n) => Diagrams.Core.Trace.Traced (Diagrams.ThreeD.Shapes.Frustum n)
instance GHC.Internal.Real.Fractional n => Diagrams.Core.Transform.Transformable (Diagrams.ThreeD.Shapes.Box n)
instance GHC.Internal.Real.Fractional n => Diagrams.Core.Transform.Transformable (Diagrams.ThreeD.Shapes.CSG n)
instance GHC.Internal.Real.Fractional n => Diagrams.Core.Transform.Transformable (Diagrams.ThreeD.Shapes.Ellipsoid n)
instance GHC.Internal.Real.Fractional n => Diagrams.Core.Transform.Transformable (Diagrams.ThreeD.Shapes.Frustum n)


-- | Types to specify viewpoint for 3D rendering.
module Diagrams.ThreeD.Camera
data Camera (l :: Type -> Type) n

-- | A perspective projection
data PerspectiveLens n
PerspectiveLens :: Angle n -> Angle n -> PerspectiveLens n

-- | Horizontal field of view.
[_horizontalFieldOfView] :: PerspectiveLens n -> Angle n

-- | Vertical field of view.
[_verticalFieldOfView] :: PerspectiveLens n -> Angle n

-- | An orthographic projection
data OrthoLens n
OrthoLens :: n -> n -> OrthoLens n

-- | Width
[_orthoWidth] :: OrthoLens n -> n

-- | Height
[_orthoHeight] :: OrthoLens n -> n
horizontalFieldOfView :: forall n f. Functor f => (Angle n -> f (Angle n)) -> PerspectiveLens n -> f (PerspectiveLens n)
verticalFieldOfView :: forall n f. Functor f => (Angle n -> f (Angle n)) -> PerspectiveLens n -> f (PerspectiveLens n)
orthoWidth :: forall n f. Functor f => (n -> f n) -> OrthoLens n -> f (OrthoLens n)
orthoHeight :: forall n f. Functor f => (n -> f n) -> OrthoLens n -> f (OrthoLens n)
camLoc :: Camera l n -> Point V3 n
camForward :: forall (l :: Type -> Type) n. Camera l n -> Direction V3 n
camUp :: forall (l :: Type -> Type) n. Camera l n -> Direction V3 n
camRight :: forall n (l :: Type -> Type). Fractional n => Camera l n -> Direction V3 n
camLens :: Camera l n -> l n

-- | 'facing_ZCamera l' is a camera at the origin facing along the negative
--   Z axis, with its up-axis coincident with the positive Y axis, with the
--   projection defined by l.
facing_ZCamera :: (Floating n, Ord n, Typeable n, CameraLens l, Renderable (Camera l n) b) => l n -> QDiagram b V3 n Any

-- | A camera at the origin facing along the negative Z axis, with its
--   up-axis coincident with the positive Y axis. The field of view is
--   chosen to match a 50mm camera on 35mm film. Note that Cameras take up
--   no space in the Diagram.
mm50Camera :: (Typeable n, Floating n, Ord n, Renderable (Camera PerspectiveLens n) b) => QDiagram b V3 n Any

-- | mm50 has the field of view of a 50mm lens on standard 35mm film, hence
--   an aspect ratio of 3:2.
mm50 :: Floating n => PerspectiveLens n

-- | mm50blWide has the same vertical field of view as mm50, but an aspect
--   ratio of 1.6, suitable for wide screen computer monitors.
mm50Wide :: Floating n => PerspectiveLens n

-- | mm50Narrow has the same vertical field of view as mm50, but an aspect
--   ratio of 4:3, for VGA and similar computer resolutions.
mm50Narrow :: Floating n => PerspectiveLens n

-- | The natural aspect ratio of the projection.
aspect :: (CameraLens l, Floating n) => l n -> n
camAspect :: forall n (l :: Type -> Type). (Floating n, CameraLens l) => Camera l n -> n
instance Diagrams.ThreeD.Camera.CameraLens Diagrams.ThreeD.Camera.OrthoLens
instance Diagrams.ThreeD.Camera.CameraLens Diagrams.ThreeD.Camera.PerspectiveLens
instance GHC.Internal.Num.Num n => Diagrams.Core.Types.Renderable (Diagrams.ThreeD.Camera.Camera l n) Diagrams.Core.Types.NullBackend
instance GHC.Internal.Num.Num n => Diagrams.Core.Transform.Transformable (Diagrams.ThreeD.Camera.Camera l n)


-- | Some miscellaneous utilities provided by the diagrams-lib package.
module Diagrams.Util

-- | Several functions exported by the diagrams library take a number of
--   arguments giving the user control to "tweak" various aspects of their
--   behavior. Rather than give such functions a long list of arguments,
--   and to make it possible for the user to selectively override only
--   certain arguments and use default values for others, such sets of
--   arguments are collected into a record with named fields (see
--   <tt>PolygonOpts</tt> in <a>Diagrams.TwoD.Shapes</a> for an example).
--   Such record types are made instances of the <a>Default</a> class,
--   which provides a single record structure (<a>def</a>) collecting the
--   "default" arguments to the function. <tt>with</tt> is a synonym for
--   <a>def</a>, which provides nice-looking syntax for simulating
--   optional, named arguments in Haskell. For example,
--   
--   <pre>
--   polygon with {sides = 7, edgeSkip = 2}
--   
--   </pre>
--   
--   calls the <tt>polygon</tt> function with a single argument (note that
--   record update binds more tightly than function application!), namely,
--   <a>with</a> (the record of default arguments) where the <tt>sides</tt>
--   and <tt>edgeSkip</tt> fields have been updated.
with :: Default d => d

-- | <tt>applyAll</tt> takes a list of functions and applies them all to a
--   value, in sequence from the last function in the list to the first.
--   For example, <tt>applyAll [f1, f2, f3] a == f1 . f2 . f3 $ a</tt>.
applyAll :: [a -> a] -> a -> a

-- | Postfix function application, for conveniently applying attributes.
--   Unlike <tt>($)</tt>, <tt>(#)</tt> has a high precedence (8), so <tt>d
--   # foo # bar</tt> can be combined with other things using operators
--   like <tt>(|||)</tt> or <tt>(&lt;&gt;)</tt> without needing
--   parentheses.
(#) :: a -> (a -> b) -> b
infixl 8 #

-- | A replacement for lenses' <a>#</a> operator.
(##) :: AReview t b -> b -> t
infixr 8 ##

-- | <tt>iterateN n f x</tt> returns the list of the first <tt>n</tt>
--   iterates of <tt>f</tt> starting at <tt>x</tt>, that is, the list
--   <tt>[x, f x, f (f x), ...]</tt> of length <tt>n</tt>. (Note that the
--   last element of the list will be <tt>f</tt> applied to <tt>x</tt>
--   <tt>(n-1)</tt> times.)
iterateN :: Int -> (a -> a) -> a -> [a]

-- | The circle constant, the ratio of a circle's circumference to its
--   <i>radius</i>. Note that <tt>pi = tau/2</tt>.
--   
--   For more information and a well-reasoned argument why we should all be
--   using tau instead of pi, see <i>The Tau Manifesto</i>,
--   <a>http://tauday.com/</a>.
--   
--   To hear what it sounds like (and to easily memorize the first 30
--   digits or so), try <a>http://youtu.be/3174T-3-59Q</a>.
tau :: Floating a => a

-- | Given some file (no extension or otherwise) try to find a haskell
--   source file.
findHsFile :: FilePath -> IO (Maybe FilePath)

-- | Search for a sandbox in the following order:
--   
--   <ul>
--   <li>Test given FilePaths if they point directly to a database or
--   contain a cabal config file (or any parent directory containing a
--   config file).</li>
--   <li>Same test for <tt>DIAGRAMS_SANDBOX</tt> environment value</li>
--   <li>Environment values of <tt>GHC_PACKAGE_PATH</tt>, <tt>HSENV</tt>
--   and <tt>PACKAGE_DB_FOR_GHC</tt> that point to a database.</li>
--   <li>Test for config file (cabal.sandbox.config) in the current
--   directory and its parents.</li>
--   </ul>
findSandbox :: [FilePath] -> IO (Maybe FilePath)

-- | Find ghc's global package database. Throws an error if it isn't found.
globalPackage :: IO FilePath

-- | Given an associative binary operation and a default value to use in
--   the case of an empty list, perform a <i>balanced</i> fold over a list.
--   For example,
--   
--   <pre>
--   foldB (+) z [a,b,c,d,e,f] == ((a+b) + (c+d)) + (e+f)
--   
--   </pre>
foldB :: (a -> a -> a) -> a -> [a] -> a


-- | The <i>alignment</i> of an object refers to the position of its local
--   origin with respect to its envelope. This module defines the
--   <a>Alignable</a> class for things which can be aligned, as well as a
--   default implementation in terms of <a>HasOrigin</a> and
--   <a>Enveloped</a>, along with several utility methods for alignment.
module Diagrams.Align

-- | Class of things which can be aligned.
class Alignable a

-- | <tt>alignBy v d a</tt> moves the origin of <tt>a</tt> along the vector
--   <tt>v</tt>. If <tt>d = 1</tt>, the origin is moved to the edge of the
--   boundary in the direction of <tt>v</tt>; if <tt>d = -1</tt>, it moves
--   to the edge of the boundary in the direction of the negation of
--   <tt>v</tt>. Other values of <tt>d</tt> interpolate linearly (so for
--   example, <tt>d = 0</tt> centers the origin along the direction of
--   <tt>v</tt>).
alignBy' :: (Alignable a, InSpace v n a, Fractional n, HasOrigin a) => (v n -> a -> Point v n) -> v n -> n -> a -> a
defaultBoundary :: (Alignable a, V a ~ v, N a ~ n) => v n -> a -> Point v n
alignBy :: (Alignable a, InSpace v n a, Fractional n, HasOrigin a) => v n -> n -> a -> a

-- | Default implementation of <a>alignBy</a> for types with
--   <a>HasOrigin</a> and <tt>AdditiveGroup</tt> instances.
alignBy'Default :: (InSpace v n a, Fractional n, HasOrigin a) => (v n -> a -> Point v n) -> v n -> n -> a -> a

-- | Some standard functions which can be used as the <tt>boundary</tt>
--   argument to <a>alignBy'</a>.
envelopeBoundary :: (V a ~ v, N a ~ n, Enveloped a) => v n -> a -> Point v n
traceBoundary :: (V a ~ v, N a ~ n, Num n, Traced a) => v n -> a -> Point v n

-- | <tt>align v</tt> aligns an enveloped object along the edge in the
--   direction of <tt>v</tt>. That is, it moves the local origin in the
--   direction of <tt>v</tt> until it is on the edge of the envelope. (Note
--   that if the local origin is outside the envelope to begin with, it may
--   have to move "backwards".)
align :: (InSpace v n a, Fractional n, Alignable a, HasOrigin a) => v n -> a -> a

-- | Like align but uses trace.
snug :: (InSpace v n a, Fractional n, Alignable a, Traced a, HasOrigin a) => v n -> a -> a

-- | <tt>centerV v</tt> centers an enveloped object along the direction of
--   <tt>v</tt>.
centerV :: (InSpace v n a, Fractional n, Alignable a, HasOrigin a) => v n -> a -> a

-- | <tt>center</tt> centers an enveloped object along all of its basis
--   vectors.
center :: forall (v :: Type -> Type) n a. (InSpace v n a, Fractional n, Traversable v, Alignable a, HasOrigin a) => a -> a

-- | Version of <tt>alignBy</tt> specialized to use <tt>traceBoundary</tt>
snugBy :: (InSpace v n a, Fractional n, Alignable a, Traced a, HasOrigin a) => v n -> n -> a -> a

-- | Like <tt>centerV</tt> using trace.
snugCenterV :: (InSpace v n a, Fractional n, Alignable a, Traced a, HasOrigin a) => v n -> a -> a

-- | Like <tt>center</tt> using trace.
snugCenter :: forall (v :: Type -> Type) n a. (InSpace v n a, Traversable v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Align.Alignable (Diagrams.Core.Envelope.Envelope v n)
instance (Diagrams.Core.V.InSpace v n a, Diagrams.Core.HasOrigin.HasOrigin a, Diagrams.Align.Alignable a) => Diagrams.Align.Alignable (b -> a)
instance (Diagrams.Core.V.V b GHC.Types.~ v, Diagrams.Core.V.N b GHC.Types.~ n, Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, Diagrams.Align.Alignable b) => Diagrams.Align.Alignable [b]
instance (Diagrams.Core.V.V b GHC.Types.~ v, Diagrams.Core.V.N b GHC.Types.~ n, Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, Diagrams.Align.Alignable b) => Diagrams.Align.Alignable (Data.Map.Internal.Map k b)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, Data.Monoid.WithSemigroup.Monoid' m) => Diagrams.Align.Alignable (Diagrams.Core.Types.QDiagram b v n m)
instance (Diagrams.Core.V.V b GHC.Types.~ v, Diagrams.Core.V.N b GHC.Types.~ n, Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, Diagrams.Align.Alignable b) => Diagrams.Align.Alignable (Data.Set.Internal.Set b)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Align.Alignable (Diagrams.Core.Trace.Trace v n)


-- | Alignment combinators specialized for two dimensions. See
--   <a>Diagrams.Align</a> for more general alignment combinators.
--   
--   The basic idea is that alignment is achieved by moving diagrams' local
--   origins relative to their envelopes or traces (or some other sort of
--   boundary). For example, to align several diagrams along their tops, we
--   first move their local origins to the upper edge of their boundary
--   (using e.g. <tt>map <tt>alignTop</tt></tt>), and then put them
--   together with their local origins along a horizontal line (using e.g.
--   <tt>hcat</tt> from <a>Diagrams.TwoD.Combinators</a>).
module Diagrams.TwoD.Align

-- | Align along the left edge, i.e. translate the diagram in a horizontal
--   direction so that the local origin is on the left edge of the
--   envelope.
alignL :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Align along the right edge.
alignR :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Align along the top edge.
alignT :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Align along the bottom edge.
alignB :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a
alignTL :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a
alignTR :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a
alignBL :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a
alignBR :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a
snugL :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugR :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugT :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugB :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a

-- | <tt>alignX</tt> and <tt>snugX</tt> move the local origin horizontally
--   as follows:
--   
--   <ul>
--   <li><tt>alignX (-1)</tt> moves the local origin to the left edge of
--   the boundary;</li>
--   <li><tt>align 1</tt> moves the local origin to the right edge;</li>
--   <li>any other argument interpolates linearly between these. For
--   example, <tt>alignX 0</tt> centers, <tt>alignX 2</tt> moves the origin
--   one "radius" to the right of the right edge, and so on.</li>
--   <li><tt>snugX</tt> works the same way.</li>
--   </ul>
alignX :: forall (v :: Type -> Type) n a. (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a) => n -> a -> a

-- | See the documentation for <a>alignX</a>.
snugX :: forall (v :: Type -> Type) n a. (InSpace v n a, R1 v, Fractional n, Alignable a, Traced a, HasOrigin a) => n -> a -> a

-- | Like <a>alignX</a>, but moving the local origin vertically, with an
--   argument of <tt>1</tt> corresponding to the top edge and <tt>(-1)</tt>
--   corresponding to the bottom edge.
alignY :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => n -> a -> a

-- | See the documentation for <a>alignY</a>.
snugY :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => n -> a -> a

-- | Center the local origin along the X-axis.
centerX :: forall (v :: Type -> Type) n a. (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Center the local origin along the Y-axis.
centerY :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Center along both the X- and Y-axes.
centerXY :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => a -> a
snugCenterX :: forall (v :: Type -> Type) n a. (InSpace v n a, R1 v, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugCenterY :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugCenterXY :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a


-- | Alignment combinators specialized for three dimensions. See
--   <a>Diagrams.Align</a> for more general alignment combinators.
--   
--   The basic idea is that alignment is achieved by moving diagrams' local
--   origins relative to their envelopes or traces (or some other sort of
--   boundary). For example, to align several diagrams along their tops, we
--   first move their local origins to the upper edge of their boundary
--   (using e.g. <tt>map <a>alignZMax</a></tt>), and then put them together
--   with their local origins along a line (using e.g. <tt>cat</tt> from
--   <a>Diagrams.Combinators</a>).
module Diagrams.ThreeD.Align

-- | Translate the diagram along unitX so that all points have positive
--   x-values.
alignXMin :: forall (v :: Type -> Type) n a. (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Translate the diagram along unitX so that all points have negative
--   x-values.
alignXMax :: forall (v :: Type -> Type) n a. (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Translate the diagram along unitY so that all points have positive
--   y-values.
alignYMin :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Translate the diagram along unitY so that all points have negative
--   y-values.
alignYMax :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Translate the diagram along unitZ so that all points have positive
--   z-values.
alignZMin :: forall (v :: Type -> Type) n a. (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Translate the diagram along unitZ so that all points have negative
--   z-values.
alignZMax :: forall (v :: Type -> Type) n a. (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a) => a -> a
snugXMin :: forall (v :: Type -> Type) n a. (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a
snugXMax :: forall (v :: Type -> Type) n a. (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a
snugYMin :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a
snugYMax :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a
snugZMin :: forall (v :: Type -> Type) n a. (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a
snugZMax :: forall (v :: Type -> Type) n a. (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a

-- | <tt>alignX</tt> and <tt>snugX</tt> move the local origin horizontally
--   as follows:
--   
--   <ul>
--   <li><tt>alignX (-1)</tt> moves the local origin to the left edge of
--   the boundary;</li>
--   <li><tt>align 1</tt> moves the local origin to the right edge;</li>
--   <li>any other argument interpolates linearly between these. For
--   example, <tt>alignX 0</tt> centers, <tt>alignX 2</tt> moves the origin
--   one "radius" to the right of the right edge, and so on.</li>
--   <li><tt>snugX</tt> works the same way.</li>
--   </ul>
alignX :: forall (v :: Type -> Type) n a. (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a) => n -> a -> a

-- | See the documentation for <a>alignX</a>.
snugX :: forall (v :: Type -> Type) n a. (InSpace v n a, R1 v, Fractional n, Alignable a, Traced a, HasOrigin a) => n -> a -> a

-- | Like <a>alignX</a>, but moving the local origin vertically, with an
--   argument of <tt>1</tt> corresponding to the top edge and <tt>(-1)</tt>
--   corresponding to the bottom edge.
alignY :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => n -> a -> a

-- | See the documentation for <a>alignY</a>.
snugY :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => n -> a -> a

-- | Like <a>alignX</a>, but moving the local origin in the Z direction,
--   with an argument of <tt>1</tt> corresponding to the top edge and
--   <tt>(-1)</tt> corresponding to the bottom edge.
alignZ :: forall (v :: Type -> Type) n a. (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a) => n -> a -> a

-- | See the documentation for <a>alignZ</a>.
snugZ :: forall a (v :: Type -> Type) n. (V a ~ v, N a ~ n, Alignable a, Traced a, HasOrigin a, R3 v, Fractional n) => n -> a -> a

-- | Center the local origin along the X-axis.
centerX :: forall (v :: Type -> Type) n a. (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Center the local origin along the Y-axis.
centerY :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Center the local origin along the Z-axis.
centerZ :: forall (v :: Type -> Type) n a. (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Center along both the X- and Y-axes.
centerXY :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Center along both the X- and Z-axes.
centerXZ :: forall (v :: Type -> Type) n a. (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Center along both the Y- and Z-axes.
centerYZ :: forall (v :: Type -> Type) n a. (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Center an object in three dimensions.
centerXYZ :: forall (v :: Type -> Type) n a. (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a) => a -> a
snugCenterX :: forall (v :: Type -> Type) n a. (InSpace v n a, R1 v, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugCenterY :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugCenterZ :: forall (v :: Type -> Type) n a. (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a
snugCenterXY :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugCenterXZ :: forall (v :: Type -> Type) n a. (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a
snugCenterYZ :: forall (v :: Type -> Type) n a. (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a
snugCenterXYZ :: forall (v :: Type -> Type) n a. (InSpace v n a, R3 v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a


-- | "Located" things, <i>i.e.</i> things with a concrete location:
--   intuitively, <tt>Located a ~ (a, Point)</tt>. Wrapping a
--   translationally invariant thing (<i>e.g.</i> a <tt>Segment</tt> or
--   <tt>Trail</tt>) in <tt>Located</tt> pins it down to a particular
--   location and makes it no longer translationally invariant.
module Diagrams.Located

-- | "Located" things, <i>i.e.</i> things with a concrete location:
--   intuitively, <tt>Located a ~ (Point, a)</tt>. Wrapping a
--   translationally invariant thing (<i>e.g.</i> a <tt>Segment</tt> or
--   <tt>Trail</tt>) in <a>Located</a> pins it down to a particular
--   location and makes it no longer translationally invariant.
--   
--   <tt>Located</tt> is intentionally abstract. To construct
--   <tt>Located</tt> values, use <a>at</a>. To destruct, use
--   <a>viewLoc</a>, <a>unLoc</a>, or <a>loc</a>. To map, use
--   <a>mapLoc</a>.
--   
--   Much of the utility of having a concrete type for the <tt>Located</tt>
--   concept lies in the type class instances we can give it. The
--   <a>HasOrigin</a>, <a>Transformable</a>, <a>Enveloped</a>,
--   <a>Traced</a>, and <tt>TrailLike</tt> instances are particularly
--   useful; see the documented instances below for more information.
data Located a
Loc :: Point (V a) (N a) -> a -> Located a

-- | Project out the location of a <tt>Located</tt> value.
[loc] :: Located a -> Point (V a) (N a)

-- | Project the value of type <tt>a</tt> out of a <tt>Located a</tt>,
--   discarding the location.
[unLoc] :: Located a -> a

-- | Construct a <tt>Located a</tt> from a value of type <tt>a</tt> and a
--   location. <tt>at</tt> is intended to be used infix, like <tt>x `at`
--   origin</tt>.
at :: a -> Point (V a) (N a) -> Located a
infix 5 `at`

-- | Deconstruct a <tt>Located a</tt> into a location and a value of type
--   <tt>a</tt>. <tt>viewLoc</tt> can be especially useful in conjunction
--   with the <tt>ViewPatterns</tt> extension.
viewLoc :: Located a -> (Point (V a) (N a), a)

-- | <a>Located</a> is not a <tt>Functor</tt>, since changing the type
--   could change the type of the associated vector space, in which case
--   the associated location would no longer have the right type.
--   <a>mapLoc</a> has an extra constraint specifying that the vector space
--   must stay the same.
--   
--   (Technically, one can say that for every vector space <tt>v</tt>,
--   <tt>Located</tt> is a little-f (endo)functor on the category of types
--   with associated vector space <tt>v</tt>; but that is not covered by
--   the standard <tt>Functor</tt> class.)
mapLoc :: SameSpace a b => (a -> b) -> Located a -> Located b

-- | A lens giving access to the object within a <a>Located</a> wrapper.
located :: SameSpace a b => Lens (Located a) (Located b) a b

-- | Lens onto the location of something <a>Located</a>.
_loc :: forall a f. Functor f => (Point (V a) (N a) -> f (Point (V a) (N a))) -> Located a -> f (Located a)
instance Diagrams.Align.Alignable a => Diagrams.Align.Alignable (Diagrams.Located.Located a)
instance Diagrams.Parametric.DomainBounds a => Diagrams.Parametric.DomainBounds (Diagrams.Located.Located a)
instance (Diagrams.Core.V.InSpace v n a, Diagrams.Parametric.EndValues a, Diagrams.Parametric.Codomain a GHC.Types.~ v) => Diagrams.Parametric.EndValues (Diagrams.Located.Located a)
instance Diagrams.Core.Envelope.Enveloped a => Diagrams.Core.Envelope.Enveloped (Diagrams.Located.Located a)
instance (GHC.Classes.Eq (Diagrams.Core.V.V a (Diagrams.Core.V.N a)), GHC.Classes.Eq a) => GHC.Classes.Eq (Diagrams.Located.Located a)
instance GHC.Internal.Generics.Generic (Diagrams.Located.Located a)
instance (Diagrams.Core.V.InSpace v n a, GHC.Internal.Real.Fractional n, Diagrams.Parametric.HasArcLength a, Diagrams.Parametric.Codomain a GHC.Types.~ v) => Diagrams.Parametric.HasArcLength (Diagrams.Located.Located a)
instance (GHC.Internal.Num.Num (Diagrams.Core.V.N a), Linear.Vector.Additive (Diagrams.Core.V.V a)) => Diagrams.Core.HasOrigin.HasOrigin (Diagrams.Located.Located a)
instance Diagrams.Core.Envelope.Enveloped a => Diagrams.Core.Juxtapose.Juxtaposable (Diagrams.Located.Located a)
instance (GHC.Classes.Ord (Diagrams.Core.V.V a (Diagrams.Core.V.N a)), GHC.Classes.Ord a) => GHC.Classes.Ord (Diagrams.Located.Located a)
instance (Diagrams.Core.V.InSpace v n a, Diagrams.Parametric.Parametric a, Diagrams.Parametric.Codomain a GHC.Types.~ v) => Diagrams.Parametric.Parametric (Diagrams.Located.Located a)
instance Diagrams.Core.Names.Qualifiable a => Diagrams.Core.Names.Qualifiable (Diagrams.Located.Located a)
instance (GHC.Internal.Read.Read (Diagrams.Core.V.V a (Diagrams.Core.V.N a)), GHC.Internal.Read.Read a) => GHC.Internal.Read.Read (Diagrams.Located.Located a)
instance (Diagrams.Core.V.InSpace v n a, GHC.Internal.Real.Fractional n, Diagrams.Parametric.Parametric a, Diagrams.Parametric.Sectionable a, Diagrams.Parametric.Codomain a GHC.Types.~ v) => Diagrams.Parametric.Sectionable (Diagrams.Located.Located a)
instance (Data.Serialize.Serialize a, Data.Serialize.Serialize (Diagrams.Core.V.V a (Diagrams.Core.V.N a))) => Data.Serialize.Serialize (Diagrams.Located.Located a)
instance (GHC.Internal.Show.Show (Diagrams.Core.V.V a (Diagrams.Core.V.N a)), GHC.Internal.Show.Show a) => GHC.Internal.Show.Show (Diagrams.Located.Located a)
instance (Diagrams.Core.Trace.Traced a, GHC.Internal.Num.Num (Diagrams.Core.V.N a)) => Diagrams.Core.Trace.Traced (Diagrams.Located.Located a)
instance (Linear.Vector.Additive (Diagrams.Core.V.V a), GHC.Internal.Num.Num (Diagrams.Core.V.N a), Diagrams.Core.Transform.Transformable a) => Diagrams.Core.Transform.Transformable (Diagrams.Located.Located a)


-- | A <i>segment</i> is a translation-invariant, atomic path. Currently,
--   there are two types: linear (<i>i.e.</i> just a straight line to the
--   endpoint) and cubic Bézier curves (<i>i.e.</i> a curve to an endpoint
--   with two control points). This module contains tools for creating and
--   manipulating segments, as well as a definition of segments with a
--   fixed location (useful for backend implementors).
--   
--   Generally speaking, casual users of diagrams should not need this
--   module; the higher-level functionality provided by
--   <a>Diagrams.Trail</a>, <a>Diagrams.TrailLike</a>, and
--   <a>Diagrams.Path</a> should usually suffice. However, directly
--   manipulating segments can occasionally be useful.
module Diagrams.Segment

-- | Type tag for open segments.
data Open

-- | Type tag for closed segments.
data Closed

-- | The <i>offset</i> of a segment is the vector from its starting point
--   to its end. The offset for an <i>open</i> segment is determined by the
--   context, <i>i.e.</i> its endpoint is not fixed. The offset for a
--   <i>closed</i> segment is stored explicitly, <i>i.e.</i> its endpoint
--   is at a fixed offset from its start.
data Offset c (v :: Type -> Type) n
[OffsetOpen] :: forall (v :: Type -> Type) n. Offset Open v n
[OffsetClosed] :: forall (v :: Type -> Type) n. v n -> Offset Closed v n

-- | Compute the offset from the start of a segment to the end. Note that
--   in the case of a Bézier segment this is <i>not</i> the same as the
--   length of the curve itself; for that, see <a>arcLength</a>.
segOffset :: Segment Closed v n -> v n

-- | The atomic constituents of the concrete representation currently used
--   for trails are <i>segments</i>, currently limited to single straight
--   lines or cubic Bézier curves. Segments are <i>translationally
--   invariant</i>, that is, they have no particular "location" and are
--   unaffected by translations. They are, however, affected by other
--   transformations such as rotations and scales.
data Segment c (v :: Type -> Type) n

-- | A linear segment with given offset.
Linear :: !Offset c v n -> Segment c (v :: Type -> Type) n

-- | A cubic Bézier segment specified by three offsets from the starting
--   point to the first control point, second control point, and ending
--   point, respectively.
Cubic :: !v n -> !v n -> !Offset c v n -> Segment c (v :: Type -> Type) n

-- | <tt><a>straight</a> v</tt> constructs a translationally invariant
--   linear segment with direction and length given by the vector
--   <tt>v</tt>.
straight :: v n -> Segment Closed v n

-- | <tt>bezier3 c1 c2 x</tt> constructs a translationally invariant cubic
--   Bézier curve where the offsets from the first endpoint to the first
--   and second control point and endpoint are respectively given by
--   <tt>c1</tt>, <tt>c2</tt>, and <tt>x</tt>.
bezier3 :: v n -> v n -> v n -> Segment Closed v n

-- | <tt>bézier3</tt> is the same as <tt>bezier3</tt>, but with more
--   snobbery.
bézier3 :: v n -> v n -> v n -> Segment Closed v n

-- | Reverse the direction of a segment.
reverseSegment :: forall n (v :: Type -> Type). (Num n, Additive v) => Segment Closed v n -> Segment Closed v n

-- | Map over the vectors of each segment.
mapSegmentVectors :: (v n -> v' n') -> Segment c v n -> Segment c v' n'

-- | An open linear segment. This means the trail makes a straight line
--   from the last segment the beginning to form a loop.
openLinear :: forall (v :: Type -> Type) n. Segment Open v n

-- | An open cubic segment. This means the trail makes a cubic bézier with
--   control vectors <tt>v1</tt> and <tt>v2</tt> to form a loop.
openCubic :: v n -> v n -> Segment Open v n

-- | <tt>FixedSegment</tt>s are like <a>Segment</a>s except that they have
--   absolute locations. <tt>FixedSegment v</tt> is isomorphic to
--   <tt>Located (Segment Closed v)</tt>, as witnessed by <a>mkFixedSeg</a>
--   and <a>fromFixedSeg</a>, but <tt>FixedSegment</tt> is convenient when
--   one needs the absolute locations of the vertices and control points.
data FixedSegment (v :: Type -> Type) n
FLinear :: Point v n -> Point v n -> FixedSegment (v :: Type -> Type) n
FCubic :: Point v n -> Point v n -> Point v n -> Point v n -> FixedSegment (v :: Type -> Type) n

-- | Create a <a>FixedSegment</a> from a located <a>Segment</a>.
mkFixedSeg :: forall n (v :: Type -> Type). (Num n, Additive v) => Located (Segment Closed v n) -> FixedSegment v n

-- | Convert a <a>FixedSegment</a> back into a located <a>Segment</a>.
fromFixedSeg :: forall n (v :: Type -> Type). (Num n, Additive v) => FixedSegment v n -> Located (Segment Closed v n)

-- | Use a <a>FixedSegment</a> to make an <a>Iso</a> between an a fixed
--   segment and a located segment.
fixedSegIso :: forall n (v :: Type -> Type). (Num n, Additive v) => Iso' (FixedSegment v n) (Located (Segment Closed v n))

-- | A type to track the count of segments in a <tt>Trail</tt>.
newtype SegCount
SegCount :: Sum Int -> SegCount

-- | A type to represent the total arc length of a chain of segments. The
--   first component is a "standard" arc length, computed to within a
--   tolerance of <tt>10e-6</tt>. The second component is a generic arc
--   length function taking the tolerance as an argument.
newtype ArcLength n
ArcLength :: (Sum (Interval n), n -> Sum (Interval n)) -> ArcLength n

-- | Project out the cached arc length, stored together with error bounds.
getArcLengthCached :: ArcLength n -> Interval n

-- | Project out the generic arc length function taking the tolerance as an
--   argument.
getArcLengthFun :: ArcLength n -> n -> Interval n

-- | Given a specified tolerance, project out the cached arc length if it
--   is accurate enough; otherwise call the generic arc length function
--   with the given tolerance.
getArcLengthBounded :: (Num n, Ord n) => n -> ArcLength n -> Interval n

-- | A type to represent the total cumulative offset of a chain of
--   segments.
newtype TotalOffset (v :: Type -> Type) n
TotalOffset :: v n -> TotalOffset (v :: Type -> Type) n

-- | A type to represent the offset and envelope of a chain of segments.
--   They have to be paired into one data structure, since combining the
--   envelopes of two consecutive chains needs to take the offset of the
--   first into account.
data OffsetEnvelope (v :: Type -> Type) n
OffsetEnvelope :: !TotalOffset v n -> Envelope v n -> OffsetEnvelope (v :: Type -> Type) n
[_oeOffset] :: OffsetEnvelope (v :: Type -> Type) n -> !TotalOffset v n
[_oeEnvelope] :: OffsetEnvelope (v :: Type -> Type) n -> Envelope v n
oeOffset :: forall (v :: Type -> Type) n f. Functor f => (TotalOffset v n -> f (TotalOffset v n)) -> OffsetEnvelope v n -> f (OffsetEnvelope v n)
oeEnvelope :: forall (v :: Type -> Type) n f. Functor f => (Envelope v n -> f (Envelope v n)) -> OffsetEnvelope v n -> f (OffsetEnvelope v n)

-- | <tt>SegMeasure</tt> collects up all the measurements over a chain of
--   segments.
type SegMeasure (v :: Type -> Type) n = SegCount ::: ArcLength n ::: OffsetEnvelope v n ::: ()
instance GHC.Internal.Num.Num n => Diagrams.Parametric.DomainBounds (Diagrams.Segment.FixedSegment v n)
instance GHC.Internal.Num.Num n => Diagrams.Parametric.DomainBounds (Diagrams.Segment.Segment Diagrams.Segment.Closed v n)
instance Control.Lens.Each.Each (Diagrams.Segment.FixedSegment v n) (Diagrams.Segment.FixedSegment v' n') (Linear.Affine.Point v n) (Linear.Affine.Point v' n')
instance Control.Lens.Each.Each (Diagrams.Segment.Offset c v n) (Diagrams.Segment.Offset c v' n') (v n) (v' n')
instance Control.Lens.Each.Each (Diagrams.Segment.Segment c v n) (Diagrams.Segment.Segment c v' n') (v n) (v' n')
instance (Linear.Vector.Additive v, GHC.Internal.Num.Num n) => Diagrams.Parametric.EndValues (Diagrams.Segment.FixedSegment v n)
instance (Linear.Vector.Additive v, GHC.Internal.Num.Num n) => Diagrams.Parametric.EndValues (Diagrams.Segment.Segment Diagrams.Segment.Closed v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Envelope.Enveloped (Diagrams.Segment.FixedSegment v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Envelope.Enveloped (Diagrams.Segment.Segment Diagrams.Segment.Closed v n)
instance GHC.Classes.Eq (v n) => GHC.Classes.Eq (Diagrams.Segment.FixedSegment v n)
instance GHC.Classes.Eq (v n) => GHC.Classes.Eq (Diagrams.Segment.Offset c v n)
instance GHC.Classes.Eq (v n) => GHC.Classes.Eq (Diagrams.Segment.Segment c v n)
instance GHC.Internal.Base.Functor v => GHC.Internal.Base.Functor (Diagrams.Segment.Offset c v)
instance GHC.Internal.Base.Functor v => GHC.Internal.Base.Functor (Diagrams.Segment.Segment c v)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Parametric.HasArcLength (Diagrams.Segment.FixedSegment v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Parametric.HasArcLength (Diagrams.Segment.Segment Diagrams.Segment.Closed v n)
instance (Linear.Vector.Additive v, GHC.Internal.Num.Num n) => Diagrams.Core.HasOrigin.HasOrigin (Diagrams.Segment.FixedSegment v n)
instance (Diagrams.Core.Envelope.OrderedField n, Linear.Metric.Metric v) => Data.FingerTree.Measured (Diagrams.Segment.SegMeasure v n) (Diagrams.Segment.Segment Diagrams.Segment.Closed v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Data.FingerTree.Measured (Diagrams.Segment.SegMeasure v n) (Diagrams.Segment.SegMeasure v n)
instance (GHC.Internal.Num.Num n, GHC.Classes.Ord n) => GHC.Internal.Base.Monoid (Diagrams.Segment.ArcLength n)
instance GHC.Internal.Base.Monoid Diagrams.Segment.SegCount
instance (GHC.Internal.Num.Num n, Linear.Vector.Additive v) => GHC.Internal.Base.Monoid (Diagrams.Segment.TotalOffset v n)
instance GHC.Classes.Ord (v n) => GHC.Classes.Ord (Diagrams.Segment.FixedSegment v n)
instance GHC.Classes.Ord (v n) => GHC.Classes.Ord (Diagrams.Segment.Offset c v n)
instance GHC.Classes.Ord (v n) => GHC.Classes.Ord (Diagrams.Segment.Segment c v n)
instance (Linear.Vector.Additive v, GHC.Internal.Num.Num n) => Diagrams.Parametric.Parametric (Diagrams.Segment.FixedSegment v n)
instance (Linear.Vector.Additive v, GHC.Internal.Num.Num n) => Diagrams.Parametric.Parametric (Diagrams.Segment.Segment Diagrams.Segment.Closed v n)
instance Diagrams.Core.Types.Renderable (Diagrams.Segment.Segment c v n) Diagrams.Core.Types.NullBackend
instance Control.Lens.Internal.Iso.Reversing (Diagrams.Segment.FixedSegment v n)
instance (Linear.Vector.Additive v, GHC.Internal.Num.Num n) => Control.Lens.Internal.Iso.Reversing (Diagrams.Segment.Offset c v n)
instance (Linear.Vector.Additive v, GHC.Internal.Num.Num n) => Control.Lens.Internal.Iso.Reversing (Diagrams.Segment.Segment Diagrams.Segment.Closed v n)
instance Control.Lens.Wrapped.Rewrapped (Diagrams.Segment.ArcLength n) (Diagrams.Segment.ArcLength n')
instance Control.Lens.Wrapped.Rewrapped Diagrams.Segment.SegCount Diagrams.Segment.SegCount
instance Control.Lens.Wrapped.Rewrapped (Diagrams.Segment.TotalOffset v n) (Diagrams.Segment.TotalOffset v' n')
instance (Linear.Vector.Additive v, GHC.Internal.Real.Fractional n) => Diagrams.Parametric.Sectionable (Diagrams.Segment.FixedSegment v n)
instance (Linear.Vector.Additive v, GHC.Internal.Real.Fractional n) => Diagrams.Parametric.Sectionable (Diagrams.Segment.Segment Diagrams.Segment.Closed v n)
instance (GHC.Internal.Num.Num n, GHC.Classes.Ord n) => GHC.Internal.Base.Semigroup (Diagrams.Segment.ArcLength n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => GHC.Internal.Base.Semigroup (Diagrams.Segment.OffsetEnvelope v n)
instance GHC.Internal.Base.Semigroup Diagrams.Segment.SegCount
instance (GHC.Internal.Num.Num n, Linear.Vector.Additive v) => GHC.Internal.Base.Semigroup (Diagrams.Segment.TotalOffset v n)
instance Data.Serialize.Serialize (v n) => Data.Serialize.Serialize (Diagrams.Segment.Segment Diagrams.Segment.Open v n)
instance Data.Serialize.Serialize (v n) => Data.Serialize.Serialize (Diagrams.Segment.Segment Diagrams.Segment.Closed v n)
instance GHC.Internal.Show.Show (v n) => GHC.Internal.Show.Show (Diagrams.Segment.FixedSegment v n)
instance GHC.Internal.Show.Show (v n) => GHC.Internal.Show.Show (Diagrams.Segment.Offset c v n)
instance GHC.Internal.Show.Show (v n) => GHC.Internal.Show.Show (Diagrams.Segment.Segment c v n)
instance (Linear.Vector.Additive v, GHC.Internal.Num.Num n) => Diagrams.Core.Transform.Transformable (Diagrams.Segment.FixedSegment v n)
instance Diagrams.Core.Transform.Transformable (Diagrams.Segment.Offset c v n)
instance Diagrams.Core.Transform.Transformable (Diagrams.Segment.Segment c v n)
instance Control.Lens.Wrapped.Wrapped (Diagrams.Segment.ArcLength n)
instance Control.Lens.Wrapped.Wrapped Diagrams.Segment.SegCount
instance Control.Lens.Wrapped.Wrapped (Diagrams.Segment.TotalOffset v n)


-- | Segments in two dimensions are special since we may meaningfully
--   compute their point of intersection with a ray.
module Diagrams.TwoD.Segment

-- | Compute the intersections between two fixed segments.
intersectPointsS :: OrderedField n => FixedSegment V2 n -> FixedSegment V2 n -> [P2 n]

-- | Compute the intersections between two segments using the given
--   tolerance.
intersectPointsS' :: OrderedField n => n -> FixedSegment V2 n -> FixedSegment V2 n -> [P2 n]

-- | Get the closest point(s) on a <a>FixedSegment</a> from a point.
closestPoint :: OrderedField n => FixedSegment V2 n -> P2 n -> [P2 n]

-- | Get the closest point(s) on a <a>FixedSegment</a> from a point within
--   given tolerance.
closestPoint' :: OrderedField n => n -> FixedSegment V2 n -> P2 n -> [P2 n]

-- | Get the closest distance(s) from a point to a <a>FixedSegment</a>.
closestDistance :: OrderedField n => FixedSegment V2 n -> P2 n -> [n]

-- | Get the closest distance(s) from a point to a <a>FixedSegment</a>
--   within given tolerance.
closestDistance' :: OrderedField n => n -> FixedSegment V2 n -> P2 n -> [n]

-- | Find the closest value(s) on the Bêzier to the given point.
closestParam :: OrderedField n => FixedSegment V2 n -> P2 n -> [n]

-- | Find the closest value(s) on the Bêzier to the given point within
--   given tolerance.
closestParam' :: OrderedField n => n -> FixedSegment V2 n -> P2 n -> [n]

-- | Return the intersection points with the parameters at which each
--   segment intersects.
segmentSegment :: OrderedField n => n -> FixedSegment V2 n -> FixedSegment V2 n -> [(n, n, P2 n)]

-- | Return the intersection points with the parameters at which the line
--   and segment intersect.
lineSegment :: OrderedField n => n -> Located (V2 n) -> FixedSegment V2 n -> [(n, n, P2 n)]
instance Diagrams.Core.Envelope.OrderedField n => Diagrams.Core.Trace.Traced (Diagrams.Segment.FixedSegment Linear.V2.V2 n)
instance Diagrams.Core.Envelope.OrderedField n => Diagrams.Core.Trace.Traced (Diagrams.Segment.Segment Diagrams.Segment.Closed Linear.V2.V2 n)


-- | Computing tangent and normal vectors for segments and trails.
module Diagrams.Tangent

-- | Compute the tangent vector to a segment or trail at a particular
--   parameter.
--   
--   Examples of more specific types this function can have include
--   
--   <ul>
--   <li><pre>Segment Closed V2 -&gt; Double -&gt; V2 Double</pre></li>
--   <li><pre>Trail' Line V2 -&gt; Double -&gt; V2 Double</pre></li>
--   <li><pre>Located (Trail V2) -&gt; Double -&gt; V2 Double</pre></li>
--   </ul>
--   
--   See the instances listed for the <a>Tangent</a> newtype for more.
tangentAtParam :: Parametric (Tangent t) => t -> N t -> Vn t

-- | Compute the tangent vector at the start of a segment or trail.
tangentAtStart :: EndValues (Tangent t) => t -> Vn t

-- | Compute the tangent vector at the end of a segment or trail.
tangentAtEnd :: EndValues (Tangent t) => t -> Vn t

-- | Compute the (unit) normal vector to a segment or trail at a particular
--   parameter.
--   
--   Examples of more specific types this function can have include
--   
--   <ul>
--   <li><pre>Segment Closed V2 Double -&gt; Double -&gt; V2
--   Double</pre></li>
--   <li><pre>Trail' Line V2 Double -&gt; Double -&gt; V2 Double</pre></li>
--   <li><pre>Located (Trail V2 Double) -&gt; Double -&gt; V2
--   Double</pre></li>
--   </ul>
--   
--   See the instances listed for the <a>Tangent</a> newtype for more.
normalAtParam :: (InSpace V2 n t, Parametric (Tangent t), Floating n) => t -> n -> V2 n

-- | Compute the normal vector at the start of a segment or trail.
normalAtStart :: (InSpace V2 n t, EndValues (Tangent t), Floating n) => t -> V2 n

-- | Compute the normal vector at the end of a segment or trail.
normalAtEnd :: (InSpace V2 n t, EndValues (Tangent t), Floating n) => t -> V2 n

-- | A newtype wrapper used to give different instances of
--   <a>Parametric</a> and <a>EndValues</a> that compute tangent vectors.
newtype Tangent t
Tangent :: t -> Tangent t
instance Diagrams.Parametric.DomainBounds t => Diagrams.Parametric.DomainBounds (Diagrams.Tangent.Tangent t)
instance (Diagrams.Parametric.DomainBounds t, Diagrams.Parametric.EndValues (Diagrams.Tangent.Tangent t)) => Diagrams.Parametric.EndValues (Diagrams.Tangent.Tangent (Diagrams.Located.Located t))
instance (Linear.Vector.Additive v, GHC.Internal.Num.Num n) => Diagrams.Parametric.EndValues (Diagrams.Tangent.Tangent (Diagrams.Segment.Segment Diagrams.Segment.Closed v n))
instance (Linear.Vector.Additive v, GHC.Internal.Num.Num n) => Diagrams.Parametric.EndValues (Diagrams.Tangent.Tangent (Diagrams.Segment.FixedSegment v n))
instance Diagrams.Parametric.Parametric (Diagrams.Tangent.Tangent t) => Diagrams.Parametric.Parametric (Diagrams.Tangent.Tangent (Diagrams.Located.Located t))
instance (Linear.Vector.Additive v, GHC.Internal.Num.Num n) => Diagrams.Parametric.Parametric (Diagrams.Tangent.Tangent (Diagrams.Segment.Segment Diagrams.Segment.Closed v n))
instance (Linear.Vector.Additive v, GHC.Internal.Num.Num n) => Diagrams.Parametric.Parametric (Diagrams.Tangent.Tangent (Diagrams.Segment.FixedSegment v n))


-- | Compute curvature for segments in two dimensions.
module Diagrams.TwoD.Curvature

-- | Curvature measures how curved the segment is at a point. One intuition
--   for the concept is how much you would turn the wheel when driving a
--   car along the curve. When the wheel is held straight there is zero
--   curvature. When turning a corner to the left we will have positive
--   curvature. When turning to the right we will have negative curvature.
--   
--   Another way to measure this idea is to find the largest circle that we
--   can push up against the curve and have it touch (locally) at exactly
--   the point and not cross the curve. This is a tangent circle. The
--   radius of that circle is the "Radius of Curvature" and it is the
--   reciprocal of curvature. Note that if the circle is on the "left" of
--   the curve, we have a positive radius, and if it is to the right we
--   have a negative radius. Straight segments have an infinite radius
--   which leads us to our representation. We result in a pair of numerator
--   and denominator so we can include infinity and zero for both the
--   radius and the curvature.
--   
--   Lets consider the following curve:
--   
--   
--   The curve starts with positive curvature,
--   
--   
--   approaches zero curvature
--   
--   
--   then has negative curvature
--   
--   
--   <pre>
--   {-# LANGUAGE GADTs #-}
--   
--   import Diagrams.TwoD.Curvature
--   import Data.Monoid.Inf
--   import Diagrams.Coordinates
--   
--   segmentA :: Segment Closed V2 Double
--   segmentA = Cubic (12 ^&amp; 0) (8 ^&amp; 10) (OffsetClosed (20 ^&amp; 8))
--   
--   curveA = lw thick . strokeP . fromSegments $ [segmentA]
--   
--   diagramA = pad 1.1 . centerXY $ curveA
--   
--   diagramPos = diagramWithRadius 0.2
--   
--   diagramZero = diagramWithRadius 0.45
--   
--   diagramNeg = diagramWithRadius 0.8
--   
--   diagramWithRadius t = pad 1.1 . centerXY
--            $ curveA
--           &lt;&gt; showCurvature segmentA t
--            # withEnvelope (curveA :: D V2 Double)
--            # lc red
--   
--   showCurvature :: Segment Closed V2 Double -&gt; Double -&gt; Diagram SVG
--   showCurvature bez@(Cubic b c (OffsetClosed d)) t
--     | v == (0,0) = mempty
--     | otherwise  = go (radiusOfCurvature bez t)
--     where
--       v@(x,y) = unr2 $ firstDerivative b c d t
--       vp = (-y) ^&amp; x
--   
--       firstDerivative b c d t = let tt = t*t in (3*(3*tt-4*t+1))*^b + (3*(2-3*t)*t)*^c + (3*tt)*^d
--   
--       go Infinity   = mempty
--       go (Finite r) = (circle (abs r) # translate vpr
--                    &lt;&gt; strokeP (origin ~~ (origin .+^ vpr)))
--                     # moveTo (origin .+^ atParam bez t)
--         where
--           vpr = signorm vp ^* r
--   </pre>
curvature :: RealFloat n => Segment Closed V2 n -> n -> PosInf n

-- | Reciprocal of <tt>curvature</tt>.
radiusOfCurvature :: RealFloat n => Segment Closed V2 n -> n -> PosInf n

-- | With <tt>squaredCurvature</tt> we can compute values in spaces that do
--   not support <a>sqrt</a> and it is just as useful for relative ordering
--   of curvatures or looking for zeros.
squaredCurvature :: RealFloat n => Segment Closed V2 n -> n -> PosInf n

-- | Reciprocal of <tt>squaredCurvature</tt>
squaredRadiusOfCurvature :: RealFloat n => Segment Closed V2 n -> n -> PosInf n


-- | This module defines <i>trails</i>, translationally invariant paths
--   through space. Trails form a central part of the diagrams-lib API, so
--   the documentation for this module merits careful study.
--   
--   Related modules include:
--   
--   <ul>
--   <li>The <tt>TrailLike</tt> class (<a>Diagrams.TrailLike</a>) exposes a
--   generic API for building a wide range of things out of trails.</li>
--   <li><tt>Path</tt>s (<a>Diagrams.Path</a>) are collections of
--   <a>Located</a> (<a>Diagrams.Located</a>) trails.</li>
--   <li>Trails are composed of <a>Segment</a>s (see
--   <a>Diagrams.Segment</a>), though most users should not need to work
--   with segments directly.</li>
--   </ul>
module Diagrams.Trail

-- | Intuitively, a trail is a single, continuous path through space.
--   However, a trail has no fixed starting point; it merely specifies
--   <i>how</i> to move through space, not <i>where</i>. For example, "take
--   three steps forward, then turn right twenty degrees and take two more
--   steps" is an intuitive analog of a trail; these instructions specify a
--   path through space from any given starting location. To be precise,
--   trails are <i>translation-invariant</i>; applying a translation to a
--   trail has no effect.
--   
--   A <tt><a>Located</a> Trail</tt>, on the other hand, is a trail paired
--   with some concrete starting location ("start at the big tree on the
--   corner, then take three steps forward, ..."). See the
--   <a>Diagrams.Located</a> module for help working with <a>Located</a>
--   values.
--   
--   Formally, the semantics of a trail is a continuous (though not
--   necessarily differentiable) function from the real interval [0,1] to
--   vectors in some vector space. (In contrast, a <a>Located</a> trail is
--   a continuous function from [0,1] to <i>points</i> in some
--   <i>affine</i> space.)
--   
--   There are two types of trails:
--   
--   <ul>
--   <li>A "line" (think of the "train", "subway", or "bus" variety, rather
--   than the "straight" variety...) is a trail with two distinct
--   endpoints. Actually, a line can have the same start and end points,
--   but it is still <i>drawn</i> as if it had distinct endpoints: the two
--   endpoints will have the appropriate end caps, and the trail will not
--   be filled. Lines have a <tt>Monoid</tt> instance where
--   <tt>mappend</tt> corresponds to concatenation, <i>i.e.</i> chaining
--   one line after the other.</li>
--   <li>A "loop" is required to end in the same place it starts (that is,
--   t(0) = t(1)). Loops are filled and are drawn as one continuous loop,
--   with the appropriate join at the start/endpoint rather than end caps.
--   Loops do not have a <tt>Monoid</tt> instance.</li>
--   </ul>
--   
--   To convert between lines and loops, see <a>glueLine</a>,
--   <a>closeLine</a>, and <a>cutLoop</a>.
--   
--   To construct trails, see <a>emptyTrail</a>, <a>trailFromSegments</a>,
--   <a>trailFromVertices</a>, <a>trailFromOffsets</a>, and friends. You
--   can also get any type of trail from any function which returns a
--   <tt>TrailLike</tt> (<i>e.g.</i> functions in
--   <a>Diagrams.TwoD.Shapes</a>, and many others; see
--   <a>Diagrams.TrailLike</a>).
--   
--   To extract information from trails, see <a>withLine</a>,
--   <a>isLoop</a>, <a>trailSegments</a>, <a>trailOffsets</a>,
--   <a>trailVertices</a>, and friends.
data Trail' l (v :: Type -> Type) n
[Line] :: forall (v :: Type -> Type) n. SegTree v n -> Trail' Line v n
[Loop] :: forall (v :: Type -> Type) n. SegTree v n -> Segment Open v n -> Trail' Loop v n

-- | Make a line into a loop by "gluing" the endpoint to the starting
--   point. In particular, the offset of the final segment is modified so
--   that it ends at the starting point of the entire trail. Typically, you
--   would first construct a line which you know happens to end where it
--   starts, and then call <a>glueLine</a> to turn it into a loop.
--   
--   
--   <pre>
--   glueLineEx = pad 1.1 . hsep 1
--     $ [almostClosed # strokeLine, almostClosed # glueLine # strokeLoop]
--   
--   almostClosed :: Trail' Line V2 Double
--   almostClosed = fromOffsets $ map r2 [(2, -1), (-3, -0.5), (-2, 1), (1, 0.5)]
--   </pre>
--   
--   <tt>glueLine</tt> is left inverse to <a>cutLoop</a>, that is,
--   
--   <pre>
--   glueLine . cutLoop === id
--   
--   </pre>
glueLine :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail' Line v n -> Trail' Loop v n

-- | Make a line into a loop by adding a new linear segment from the line's
--   end to its start.
--   
--   <tt>closeLine</tt> does not have any particularly nice theoretical
--   properties, but can be useful <i>e.g.</i> when you want to make a
--   closed polygon out of a list of points where the initial point is not
--   repeated at the end. To use <a>glueLine</a>, one would first have to
--   duplicate the initial vertex, like
--   
--   <pre>
--   <a>glueLine</a> . <a>lineFromVertices</a> $ ps ++ [head ps]
--   </pre>
--   
--   Using <tt>closeLine</tt>, however, one can simply
--   
--   <pre>
--   closeLine . lineFromVertices $ ps
--   </pre>
--   
--   
--   <pre>
--   closeLineEx = pad 1.1 . centerXY . hcat' (with &amp; sep .~ 1)
--     $ [almostClosed # strokeLine, almostClosed # closeLine # strokeLoop]
--   </pre>
closeLine :: forall (v :: Type -> Type) n. Trail' Line v n -> Trail' Loop v n

-- | Turn a loop into a line by "cutting" it at the common start/end point,
--   resulting in a line which just happens to start and end at the same
--   place.
--   
--   <tt>cutLoop</tt> is right inverse to <a>glueLine</a>, that is,
--   
--   <pre>
--   glueLine . cutLoop === id
--   
--   </pre>
cutLoop :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail' Loop v n -> Trail' Line v n

-- | <tt>Trail</tt> is a wrapper around <tt>Trail'</tt>, hiding whether the
--   underlying <tt>Trail'</tt> is a line or loop (though which it is can
--   be recovered; see <i>e.g.</i> <a>withTrail</a>).
data Trail (v :: Type -> Type) n
[Trail] :: forall l (v :: Type -> Type) n. Trail' l v n -> Trail v n

-- | Prism onto a <a>Line</a>.
_Line :: forall (v :: Type -> Type) n p f. (Choice p, Applicative f) => p (Trail' Line v n) (f (Trail' Line v n)) -> p (Trail v n) (f (Trail v n))

-- | Prism onto a <a>Loop</a>.
_Loop :: forall (v :: Type -> Type) n p f. (Choice p, Applicative f) => p (Trail' Loop v n) (f (Trail' Loop v n)) -> p (Trail v n) (f (Trail v n))

-- | Prism onto a <a>Located</a> <a>Line</a>.
_LocLine :: forall (v :: Type -> Type) n p f. (Choice p, Applicative f) => p (Located (Trail' Line v n)) (f (Located (Trail' Line v n))) -> p (Located (Trail v n)) (f (Located (Trail v n)))

-- | Prism onto a <a>Located</a> <a>Loop</a>.
_LocLoop :: forall (v :: Type -> Type) n p f. (Choice p, Applicative f) => p (Located (Trail' Loop v n)) (f (Located (Trail' Loop v n))) -> p (Located (Trail v n)) (f (Located (Trail v n)))

-- | Convert a <a>Trail'</a> into a <a>Trail</a>, hiding the type-level
--   distinction between lines and loops.
wrapTrail :: forall l (v :: Type -> Type) n. Trail' l v n -> Trail v n

-- | Convert a line into a <a>Trail</a>. This is the same as
--   <a>wrapTrail</a>, but with a more specific type, which can
--   occasionally be convenient for fixing the type of a polymorphic
--   expression.
wrapLine :: forall (v :: Type -> Type) n. Trail' Line v n -> Trail v n

-- | Convert a loop into a <a>Trail</a>. This is the same as
--   <a>wrapTrail</a>, but with a more specific type, which can
--   occasionally be convenient for fixing the type of a polymorphic
--   expression.
wrapLoop :: forall (v :: Type -> Type) n. Trail' Loop v n -> Trail v n

-- | Modify a <tt>Trail</tt>, specifying two separate transformations for
--   the cases of a line or a loop.
onTrail :: forall (v :: Type -> Type) n l1 l2. (Trail' Line v n -> Trail' l1 v n) -> (Trail' Loop v n -> Trail' l2 v n) -> Trail v n -> Trail v n

-- | Modify a <tt>Trail</tt> by specifying a transformation on lines. If
--   the trail is a line, the transformation will be applied directly. If
--   it is a loop, it will first be cut using <a>cutLoop</a>, the
--   transformation applied, and then glued back into a loop with
--   <a>glueLine</a>. That is,
--   
--   <pre>
--   onLine f === onTrail f (glueLine . f . cutLoop)
--   
--   </pre>
--   
--   Note that there is no corresponding <tt>onLoop</tt> function, because
--   there is no nice way in general to convert a line into a loop, operate
--   on it, and then convert back.
onLine :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => (Trail' Line v n -> Trail' Line v n) -> Trail v n -> Trail v n

-- | <tt>glueTrail</tt> is a variant of <a>glueLine</a> which works on
--   <a>Trail</a>s. It performs <a>glueLine</a> on lines and is the
--   identity on loops.
glueTrail :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail v n -> Trail v n

-- | <tt>closeTrail</tt> is a variant of <a>closeLine</a> for <a>Trail</a>,
--   which performs <a>closeLine</a> on lines and is the identity on loops.
closeTrail :: forall (v :: Type -> Type) n. Trail v n -> Trail v n

-- | <tt>cutTrail</tt> is a variant of <a>cutLoop</a> for <a>Trail</a>; it
--   is the is the identity on lines and performs <a>cutLoop</a> on loops.
cutTrail :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail v n -> Trail v n

-- | The empty line, which is the identity for concatenation of lines.
emptyLine :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail' Line v n

-- | A wrapped variant of <a>emptyLine</a>.
emptyTrail :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail v n

-- | Construct a line containing only linear segments from a list of
--   vertices. Note that only the relative offsets between the vertices
--   matters; the information about their absolute position will be
--   discarded. That is, for all vectors <tt>v</tt>,
--   
--   <pre>
--   lineFromVertices === lineFromVertices . <a>translate</a> v
--   </pre>
--   
--   If you want to retain the position information, you should instead use
--   the more general <tt>fromVertices</tt> function to construct, say, a
--   <tt><a>Located</a> (<a>Trail'</a> <a>Line</a> v)</tt> or a
--   <tt><a>Located</a> (<a>Trail</a> v)</tt>.
--   
--   
--   <pre>
--   import Diagrams.Coordinates
--   lineFromVerticesEx = pad 1.1 . centerXY . strokeLine
--     $ lineFromVertices [origin, 0 ^&amp; 1, 1 ^&amp; 2, 5 ^&amp; 1]
--   </pre>
lineFromVertices :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => [Point v n] -> Trail' Line v n

-- | <tt>trailFromVertices === <a>wrapTrail</a> .
--   <a>lineFromVertices</a></tt>, for conveniently constructing a
--   <tt>Trail</tt> instead of a <tt>Trail' Line</tt>.
trailFromVertices :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => [Point v n] -> Trail v n

-- | Construct a line containing only linear segments from a list of
--   vectors, where each vector represents the offset from one vertex to
--   the next. See also <tt>fromOffsets</tt>.
--   
--   
--   <pre>
--   import Diagrams.Coordinates
--   lineFromOffsetsEx = strokeLine $ lineFromOffsets [ 2 ^&amp; 1, 2 ^&amp; (-1), 2 ^&amp; 0.5 ]
--   </pre>
lineFromOffsets :: (Metric v, OrderedField n) => [v n] -> Trail' Line v n

-- | <tt>trailFromOffsets === <a>wrapTrail</a> .
--   <a>lineFromOffsets</a></tt>, for conveniently constructing a
--   <tt>Trail</tt> instead of a <tt>Trail' Line</tt>.
trailFromOffsets :: (Metric v, OrderedField n) => [v n] -> Trail v n

-- | Construct a line from a list of closed segments.
lineFromSegments :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => [Segment Closed v n] -> Trail' Line v n

-- | <tt>trailFromSegments === <a>wrapTrail</a> .
--   <a>lineFromSegments</a></tt>, for conveniently constructing a
--   <tt>Trail</tt> instead of a <tt>Trail'</tt>.
trailFromSegments :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => [Segment Closed v n] -> Trail v n

-- | Construct a loop from a list of closed segments and an open segment
--   that completes the loop.
loopFromSegments :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => [Segment Closed v n] -> Segment Open v n -> Trail' Loop v n

-- | A generic eliminator for <a>Trail'</a>, taking functions specifying
--   what to do in the case of a line or a loop.
withTrail' :: forall (v :: Type -> Type) n r l. (Trail' Line v n -> r) -> (Trail' Loop v n -> r) -> Trail' l v n -> r

-- | A generic eliminator for <a>Trail</a>, taking functions specifying
--   what to do in the case of a line or a loop.
withTrail :: forall (v :: Type -> Type) n r. (Trail' Line v n -> r) -> (Trail' Loop v n -> r) -> Trail v n -> r

-- | An eliminator for <tt>Trail</tt> based on eliminating lines: if the
--   trail is a line, the given function is applied; if it is a loop, it is
--   first converted to a line with <a>cutLoop</a>. That is,
--   
--   <pre>
--   withLine f === <a>withTrail</a> f (f . <a>cutLoop</a>)
--   </pre>
withLine :: forall (v :: Type -> Type) n r. (Metric v, OrderedField n) => (Trail' Line v n -> r) -> Trail v n -> r

-- | Test whether a line is empty.
isLineEmpty :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail' Line v n -> Bool

-- | Test whether a trail is empty. Note that loops are never empty.
isTrailEmpty :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail v n -> Bool

-- | Determine whether a trail is a line.
isLine :: forall (v :: Type -> Type) n. Trail v n -> Bool

-- | Determine whether a trail is a loop.
isLoop :: forall (v :: Type -> Type) n. Trail v n -> Bool

-- | Extract the segments of a trail. If the trail is a loop it will first
--   have <a>cutLoop</a> applied.
trailSegments :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail v n -> [Segment Closed v n]

-- | Extract the segments comprising a line.
lineSegments :: forall (v :: Type -> Type) n. Trail' Line v n -> [Segment Closed v n]

-- | Extract the segments comprising a loop: a list of closed segments, and
--   one final open segment.
loopSegments :: forall (v :: Type -> Type) n. Trail' Loop v n -> ([Segment Closed v n], Segment Open v n)

-- | Modify a line by applying a function to its list of segments.
onLineSegments :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => ([Segment Closed v n] -> [Segment Closed v n]) -> Trail' Line v n -> Trail' Line v n

-- | Extract the offsets of the segments of a trail.
trailOffsets :: (Metric v, OrderedField n) => Trail v n -> [v n]

-- | Compute the offset from the start of a trail to the end. Satisfies
--   
--   <pre>
--   trailOffset === sumV . trailOffsets
--   
--   </pre>
--   
--   but is more efficient.
--   
--   
--   <pre>
--   trailOffsetEx = (strokeLine almostClosed &lt;&gt; showOffset) # centerXY # pad 1.1
--     where showOffset = fromOffsets [trailOffset (wrapLine almostClosed)]
--                      # strokeP # lc red
--   </pre>
trailOffset :: (Metric v, OrderedField n) => Trail v n -> v n

-- | Extract the offsets of the segments of a line.
lineOffsets :: Trail' Line v n -> [v n]

-- | Compute the offset from the start of a line to the end. (Note, there
--   is no corresponding <tt>loopOffset</tt> function because by definition
--   it would be constantly zero.)
lineOffset :: (Metric v, OrderedField n) => Trail' Line v n -> v n

-- | Extract the offsets of the segments of a loop.
loopOffsets :: (Metric v, OrderedField n) => Trail' Loop v n -> [v n]

-- | Extract the points of a concretely located trail, <i>i.e.</i> the
--   points where one segment ends and the next begins. Note that for
--   loops, the starting point will <i>not</i> be repeated at the end. If
--   you want this behavior, you can use <a>cutTrail</a> to make the loop
--   into a line first, which happens to repeat the same point at the start
--   and end, <i>e.g.</i> with <tt>trailPoints . mapLoc cutTrail</tt>.
--   
--   Note that it does not make sense to ask for the points of a
--   <a>Trail</a> by itself; if you want the points of a trail with the
--   first point at, say, the origin, you can use <tt>trailPoints . (`at`
--   origin)</tt>.
--   
--   This function allows you "observe" the fact that trails are
--   implemented as lists of segments, which may be problematic if we want
--   to think of trails as parametric vector functions. This also means
--   that the behavior of this function may not be stable under future
--   changes to the implementation of trails. For an unproblematic version
--   which only yields vertices at which there is a sharp corner, excluding
--   points where the trail is differentiable, see <a>trailVertices</a>.
--   
--   This function is not re-exported from <a>Diagrams.Prelude</a>; to use
--   it, import <a>Diagrams.Trail</a>.
trailPoints :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Located (Trail v n) -> [Point v n]

-- | Extract the segment join points of a concretely located line. See
--   <a>trailPoints</a> for more information.
--   
--   This function allows you "observe" the fact that lines are implemented
--   as lists of segments, which may be problematic if we want to think of
--   lines as parametric vector functions. This also means that the
--   behavior of this function may not be stable under future changes to
--   the implementation of trails. For an unproblematic version which only
--   yields vertices at which there is a sharp corner, excluding points
--   where the trail is differentiable, see <a>lineVertices</a>.
--   
--   This function is not re-exported from <a>Diagrams.Prelude</a>; to use
--   it, import <a>Diagrams.Trail</a>.
linePoints :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Located (Trail' Line v n) -> [Point v n]

-- | Extract the segment join points of a concretely located loop. Note
--   that the initial vertex is not repeated at the end. See
--   <a>trailPoints</a> for more information.
--   
--   This function allows you "observe" the fact that lines are implemented
--   as lists of segments, which may be problematic if we want to think of
--   lines as parametric vector functions. This also means that the
--   behavior of this function may not be stable under future changes to
--   the implementation of trails. For an unproblematic version which only
--   yields vertices at which there is a sharp corner, excluding points
--   where the trail is differentiable, see <a>lineVertices</a>.
--   
--   This function is not re-exported from <a>Diagrams.Prelude</a>; to use
--   it, import <a>Diagrams.Trail</a>.
loopPoints :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Located (Trail' Loop v n) -> [Point v n]

-- | Extract the vertices of a concretely located trail. Here a
--   <i>vertex</i> is defined as a non-differentiable point on the trail,
--   <i>i.e.</i> a sharp corner. (Vertices are thus a subset of the places
--   where segments join; if you want all joins between segments, see
--   <a>trailPoints</a>.) The tolerance determines how close the tangents
--   of two segments must be at their endpoints to consider the transition
--   point to be differentiable.
--   
--   Note that for loops, the starting vertex will <i>not</i> be repeated
--   at the end. If you want this behavior, you can use <a>cutTrail</a> to
--   make the loop into a line first, which happens to repeat the same
--   vertex at the start and end, <i>e.g.</i> with <tt>trailVertices .
--   mapLoc cutTrail</tt>.
--   
--   It does not make sense to ask for the vertices of a <a>Trail</a> by
--   itself; if you want the vertices of a trail with the first vertex at,
--   say, the origin, you can use <tt>trailVertices . (`at` origin)</tt>.
trailVertices' :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => n -> Located (Trail v n) -> [Point v n]

-- | Extract the vertices of a concretely located line. See
--   <a>trailVertices</a> for more information.
lineVertices' :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => n -> Located (Trail' Line v n) -> [Point v n]

-- | Extract the vertices of a concretely located loop. Note that the
--   initial vertex is not repeated at the end. See <a>trailVertices</a>
--   for more information.
loopVertices' :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => n -> Located (Trail' Loop v n) -> [Point v n]

-- | Like <a>trailVertices'</a>, with a default tolerance.
trailVertices :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Located (Trail v n) -> [Point v n]

-- | Like <a>lineVertices'</a>, with a default tolerance.
lineVertices :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Located (Trail' Line v n) -> [Point v n]

-- | Same as <a>loopVertices'</a>, with a default tolerance.
loopVertices :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Located (Trail' Loop v n) -> [Point v n]

-- | Convert a concretely located trail into a list of located segments.
trailLocSegments :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Located (Trail v n) -> [Located (Segment Closed v n)]

-- | Convert a concretely located trail into a list of fixed segments.
--   <a>unfixTrail</a> is almost its left inverse.
fixTrail :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Located (Trail v n) -> [FixedSegment v n]

-- | Convert a list of fixed segments into a located trail. Note that this
--   may lose information: it throws away the locations of all but the
--   first <tt>FixedSegment</tt>. This does not matter precisely when each
--   <tt>FixedSegment</tt> begins where the previous one ends.
--   
--   This is almost left inverse to <a>fixTrail</a>, that is,
--   <tt>unfixTrail . fixTrail == id</tt>, except for the fact that
--   <tt>unfixTrail</tt> will never yield a <tt>Loop</tt>. In the case of a
--   loop, we instead have <tt>glueTrail . unfixTrail . fixTrail ==
--   id</tt>. On the other hand, it is not the case that <tt>fixTrail .
--   unfixTrail == id</tt> since <tt>unfixTrail</tt> may lose information.
unfixTrail :: forall (v :: Type -> Type) n. (Metric v, Ord n, Floating n) => [FixedSegment v n] -> Located (Trail v n)

-- | Reverse a trail. Semantically, if a trail given by a function t from
--   [0,1] to vectors, then the reverse of t is given by t'(s) = t(1-s).
--   <tt>reverseTrail</tt> is an involution, that is,
--   
--   <pre>
--   reverseTrail . reverseTrail === id
--   
--   </pre>
reverseTrail :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail v n -> Trail v n

-- | Reverse a concretely located trail. The endpoint of the original trail
--   becomes the starting point of the reversed trail, so the original and
--   reversed trails comprise exactly the same set of points.
--   <tt>reverseLocTrail</tt> is an involution, <i>i.e.</i>
--   
--   <pre>
--   reverseLocTrail . reverseLocTrail === id
--   
--   </pre>
reverseLocTrail :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Located (Trail v n) -> Located (Trail v n)

-- | Reverse a line. See <a>reverseTrail</a>.
reverseLine :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail' Line v n -> Trail' Line v n

-- | Reverse a concretely located line. See <a>reverseLocTrail</a>.
reverseLocLine :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Located (Trail' Line v n) -> Located (Trail' Line v n)

-- | Reverse a loop. See <a>reverseTrail</a>.
reverseLoop :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail' Loop v n -> Trail' Loop v n

-- | Reverse a concretely located loop. See <a>reverseLocTrail</a>. Note
--   that this is guaranteed to preserve the location.
reverseLocLoop :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Located (Trail' Loop v n) -> Located (Trail' Loop v n)

-- | Type tag for trails with distinct endpoints.
data Line

-- | Type tag for "loopy" trails which return to their starting point.
data Loop

-- | A <tt>SegTree</tt> represents a sequence of closed segments, stored in
--   a fingertree so we can easily recover various monoidal measures of the
--   segments (number of segments, arc length, envelope...) and also easily
--   slice and dice them according to the measures (<i>e.g.</i>, split off
--   the smallest number of segments from the beginning which have a
--   combined arc length of at least 5).
newtype SegTree (v :: Type -> Type) n
SegTree :: FingerTree (SegMeasure v n) (Segment Closed v n) -> SegTree (v :: Type -> Type) n

-- | Given a default result (to be used in the case of an empty trail), and
--   a function to map a single measure to a result, extract the given
--   measure for a trail and use it to compute a result. Put another way,
--   lift a function on a single measure (along with a default value) to a
--   function on an entire trail.
trailMeasure :: forall (v :: Type -> Type) n m t a. (SegMeasure v n :>: m, Measured (SegMeasure v n) t) => a -> (m -> a) -> t -> a

-- | Compute the number of segments of anything measured by
--   <a>SegMeasure</a> (<i>e.g.</i> <tt>SegMeasure</tt> itself,
--   <tt>Segment</tt>, <tt>SegTree</tt>, <tt>Trail</tt>s...)
numSegs :: forall c (v :: Type -> Type) n a. (Num c, Measured (SegMeasure v n) a) => a -> c

-- | Compute the total offset of anything measured by <a>SegMeasure</a>.
offset :: (OrderedField n, Metric v, Measured (SegMeasure v n) t) => t -> v n

-- | A newtype wrapper around trails which exists solely for its
--   <a>Parametric</a>, <a>DomainBounds</a> and <a>EndValues</a> instances.
--   The idea is that if <tt>tr</tt> is a trail, you can write, <i>e.g.</i>
--   
--   <pre>
--   getSegment tr <a>atParam</a> 0.6
--   
--   </pre>
--   
--   or
--   
--   <pre>
--   atStart (getSegment tr)
--   
--   </pre>
--   
--   to get the segment at parameter 0.6 or the first segment in the trail,
--   respectively.
--   
--   The codomain for <a>GetSegment</a>, <i>i.e.</i> the result you get
--   from calling <a>atParam</a>, <a>atStart</a>, or <a>atEnd</a>, is
--   <a>GetSegmentCodomain</a>, which is a newtype wrapper around <tt>Maybe
--   (v, Segment Closed v, AnIso' n n)</tt>. <tt>Nothing</tt> results if
--   the trail is empty; otherwise, you get:
--   
--   <ul>
--   <li>the offset from the start of the trail to the beginning of the
--   segment,</li>
--   <li>the segment itself, and</li>
--   <li>a reparameterization isomorphism: in the forward direction, it
--   translates from parameters on the whole trail to a parameters on the
--   segment. Note that for technical reasons you have to call
--   <a>cloneIso</a> on the <tt>AnIso'</tt> value to get a real isomorphism
--   you can use.</li>
--   </ul>
newtype GetSegment t
GetSegment :: t -> GetSegment t

-- | Create a <a>GetSegment</a> wrapper around a trail, after which you can
--   call <a>atParam</a>, <a>atStart</a>, or <a>atEnd</a> to extract a
--   segment.
getSegment :: t -> GetSegment t
newtype GetSegmentCodomain (v :: Type -> Type) n
GetSegmentCodomain :: Maybe (v n, Segment Closed v n, AnIso' n n) -> GetSegmentCodomain (v :: Type -> Type) n
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Control.Lens.Empty.AsEmpty (Diagrams.Trail.Trail v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Control.Lens.Empty.AsEmpty (Diagrams.Trail.Trail' Diagrams.Trail.Line v n)
instance (Data.FingerTree.Measured m a, Data.FingerTree.Measured n b) => Control.Lens.Cons.Cons (Data.FingerTree.FingerTree m a) (Data.FingerTree.FingerTree n b) a b
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n') => Control.Lens.Cons.Cons (Diagrams.Trail.SegTree v n) (Diagrams.Trail.SegTree u n') (Diagrams.Segment.Segment Diagrams.Segment.Closed v n) (Diagrams.Segment.Segment Diagrams.Segment.Closed u n')
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n') => Control.Lens.Cons.Cons (Diagrams.Trail.Trail' Diagrams.Trail.Line v n) (Diagrams.Trail.Trail' Diagrams.Trail.Line u n') (Diagrams.Segment.Segment Diagrams.Segment.Closed v n) (Diagrams.Segment.Segment Diagrams.Segment.Closed u n')
instance Diagrams.Parametric.DomainBounds t => Diagrams.Parametric.DomainBounds (Diagrams.Trail.GetSegment t)
instance GHC.Internal.Num.Num n => Diagrams.Parametric.DomainBounds (Diagrams.Trail.SegTree v n)
instance GHC.Internal.Num.Num n => Diagrams.Parametric.DomainBounds (Diagrams.Trail.Trail v n)
instance GHC.Internal.Num.Num n => Diagrams.Parametric.DomainBounds (Diagrams.Trail.Trail' l v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Internal.Real.Real n) => Diagrams.Parametric.EndValues (Diagrams.Trail.GetSegment (Diagrams.Trail.Trail v n))
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Parametric.EndValues (Diagrams.Trail.GetSegment (Diagrams.Trail.Trail' Diagrams.Trail.Line v n))
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Internal.Real.Real n) => Diagrams.Parametric.EndValues (Diagrams.Trail.GetSegment (Diagrams.Trail.Trail' Diagrams.Trail.Loop v n))
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Internal.Real.Real n) => Diagrams.Parametric.EndValues (Diagrams.Trail.SegTree v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Internal.Real.Real n) => Diagrams.Parametric.EndValues (Diagrams.Tangent.Tangent (Diagrams.Trail.Trail v n))
instance (Diagrams.Parametric.Parametric (Diagrams.Trail.GetSegment (Diagrams.Trail.Trail' c v n)), Diagrams.Parametric.EndValues (Diagrams.Trail.GetSegment (Diagrams.Trail.Trail' c v n)), Linear.Vector.Additive v, GHC.Internal.Num.Num n) => Diagrams.Parametric.EndValues (Diagrams.Tangent.Tangent (Diagrams.Trail.Trail' c v n))
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Internal.Real.Real n) => Diagrams.Parametric.EndValues (Diagrams.Trail.Trail v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Internal.Real.Real n) => Diagrams.Parametric.EndValues (Diagrams.Trail.Trail' l v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Envelope.Enveloped (Diagrams.Trail.Trail v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Envelope.Enveloped (Diagrams.Trail.Trail' l v n)
instance GHC.Classes.Eq (v n) => GHC.Classes.Eq (Diagrams.Trail.SegTree v n)
instance GHC.Classes.Eq (v n) => GHC.Classes.Eq (Diagrams.Trail.Trail v n)
instance GHC.Classes.Eq (v n) => GHC.Classes.Eq (Diagrams.Trail.Trail' l v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Internal.Real.Real n) => Diagrams.Parametric.HasArcLength (Diagrams.Trail.SegTree v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Internal.Real.Real n) => Diagrams.Parametric.HasArcLength (Diagrams.Trail.Trail v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Internal.Real.Real n) => Diagrams.Parametric.HasArcLength (Diagrams.Trail.Trail' l v n)
instance (GHC.Classes.Ord n, Linear.Metric.Metric v, GHC.Internal.Float.Floating n) => Data.FingerTree.Measured (Diagrams.Segment.SegMeasure v n) (Diagrams.Trail.SegTree v n)
instance (GHC.Classes.Ord n, GHC.Internal.Float.Floating n, Linear.Metric.Metric v) => GHC.Internal.Base.Monoid (Diagrams.Trail.SegTree v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => GHC.Internal.Base.Monoid (Diagrams.Trail.Trail v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => GHC.Internal.Base.Monoid (Diagrams.Trail.Trail' Diagrams.Trail.Line v n)
instance GHC.Classes.Ord (v n) => GHC.Classes.Ord (Diagrams.Trail.SegTree v n)
instance GHC.Classes.Ord (v n) => GHC.Classes.Ord (Diagrams.Trail.Trail v n)
instance GHC.Classes.Ord (v n) => GHC.Classes.Ord (Diagrams.Trail.Trail' l v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Internal.Real.Real n) => Diagrams.Parametric.Parametric (Diagrams.Trail.GetSegment (Diagrams.Trail.Trail v n))
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Parametric.Parametric (Diagrams.Trail.GetSegment (Diagrams.Trail.Trail' Diagrams.Trail.Line v n))
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Internal.Real.Real n) => Diagrams.Parametric.Parametric (Diagrams.Trail.GetSegment (Diagrams.Trail.Trail' Diagrams.Trail.Loop v n))
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Internal.Real.Real n) => Diagrams.Parametric.Parametric (Diagrams.Trail.SegTree v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Internal.Real.Real n) => Diagrams.Parametric.Parametric (Diagrams.Tangent.Tangent (Diagrams.Trail.Trail v n))
instance (Diagrams.Parametric.Parametric (Diagrams.Trail.GetSegment (Diagrams.Trail.Trail' c v n)), Linear.Vector.Additive v, GHC.Internal.Num.Num n) => Diagrams.Parametric.Parametric (Diagrams.Tangent.Tangent (Diagrams.Trail.Trail' c v n))
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Internal.Real.Real n) => Diagrams.Parametric.Parametric (Diagrams.Trail.Trail v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Internal.Real.Real n) => Diagrams.Parametric.Parametric (Diagrams.Trail.Trail' l v n)
instance (Diagrams.Core.Transform.HasLinearMap v, Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Types.Renderable (Diagrams.Trail.Trail' o v n) Diagrams.Core.Types.NullBackend
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Control.Lens.Internal.Iso.Reversing (Diagrams.Located.Located (Diagrams.Trail.Trail v n))
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Control.Lens.Internal.Iso.Reversing (Diagrams.Located.Located (Diagrams.Trail.Trail' l v n))
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Control.Lens.Internal.Iso.Reversing (Diagrams.Trail.Trail v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Control.Lens.Internal.Iso.Reversing (Diagrams.Trail.Trail' l v n)
instance Control.Lens.Wrapped.Rewrapped (Diagrams.Trail.SegTree v n) (Diagrams.Trail.SegTree v' n')
instance Control.Lens.Wrapped.Rewrapped (Diagrams.Trail.Trail' Diagrams.Trail.Line v n) (Diagrams.Trail.Trail' Diagrams.Trail.Line v' n')
instance Control.Lens.Wrapped.Rewrapped (Diagrams.Trail.Trail v n) (Diagrams.Trail.Trail v' n')
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Internal.Real.Real n) => Diagrams.Parametric.Sectionable (Diagrams.Trail.SegTree v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Internal.Real.Real n) => Diagrams.Parametric.Sectionable (Diagrams.Trail.Trail v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, GHC.Internal.Real.Real n) => Diagrams.Parametric.Sectionable (Diagrams.Trail.Trail' Diagrams.Trail.Line v n)
instance (GHC.Internal.Real.Real n, GHC.Internal.Float.Floating n, Linear.Metric.Metric v) => GHC.Internal.Base.Semigroup (Diagrams.Located.Located (Diagrams.Trail.Trail' Diagrams.Trail.Line v n))
instance (GHC.Classes.Ord n, GHC.Internal.Float.Floating n, Linear.Metric.Metric v) => GHC.Internal.Base.Semigroup (Diagrams.Trail.SegTree v n)
instance (Diagrams.Core.Envelope.OrderedField n, Linear.Metric.Metric v) => GHC.Internal.Base.Semigroup (Diagrams.Trail.Trail v n)
instance (Diagrams.Core.Envelope.OrderedField n, Linear.Metric.Metric v) => GHC.Internal.Base.Semigroup (Diagrams.Trail.Trail' Diagrams.Trail.Line v n)
instance (Diagrams.Core.Envelope.OrderedField n, Linear.Metric.Metric v, Data.Serialize.Serialize (v n)) => Data.Serialize.Serialize (Diagrams.Trail.SegTree v n)
instance (Data.Serialize.Serialize (v n), Diagrams.Core.Envelope.OrderedField n, Linear.Metric.Metric v) => Data.Serialize.Serialize (Diagrams.Trail.Trail v n)
instance GHC.Internal.Show.Show (v n) => GHC.Internal.Show.Show (Diagrams.Trail.SegTree v n)
instance GHC.Internal.Show.Show (v n) => GHC.Internal.Show.Show (Diagrams.Trail.Trail v n)
instance GHC.Internal.Show.Show (v n) => GHC.Internal.Show.Show (Diagrams.Trail.Trail' l v n)
instance (Data.FingerTree.Measured m a, Data.FingerTree.Measured n b) => Control.Lens.Cons.Snoc (Data.FingerTree.FingerTree m a) (Data.FingerTree.FingerTree n b) a b
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n') => Control.Lens.Cons.Snoc (Diagrams.Trail.SegTree v n) (Diagrams.Trail.SegTree u n') (Diagrams.Segment.Segment Diagrams.Segment.Closed v n) (Diagrams.Segment.Segment Diagrams.Segment.Closed u n')
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n') => Control.Lens.Cons.Snoc (Diagrams.Trail.Trail' Diagrams.Trail.Line v n) (Diagrams.Trail.Trail' Diagrams.Trail.Line u n') (Diagrams.Segment.Segment Diagrams.Segment.Closed v n) (Diagrams.Segment.Segment Diagrams.Segment.Closed u n')
instance (Data.FingerTree.Measured m a, Diagrams.Core.Transform.Transformable a) => Diagrams.Core.Transform.Transformable (Data.FingerTree.FingerTree m a)
instance (GHC.Internal.Float.Floating n, GHC.Classes.Ord n, Linear.Metric.Metric v) => Diagrams.Core.Transform.Transformable (Diagrams.Trail.SegTree v n)
instance (Diagrams.Core.Transform.HasLinearMap v, Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Transform.Transformable (Diagrams.Trail.Trail v n)
instance (Diagrams.Core.Transform.HasLinearMap v, Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Transform.Transformable (Diagrams.Trail.Trail' l v n)
instance Control.Lens.Wrapped.Wrapped (Diagrams.Trail.SegTree v n)
instance Control.Lens.Wrapped.Wrapped (Diagrams.Trail.Trail v n)
instance Control.Lens.Wrapped.Wrapped (Diagrams.Trail.Trail' Diagrams.Trail.Line v n)


-- | The <a>TrailLike</a> class abstracts over anything which can be
--   constructed from a concretely located <a>Trail</a>, including lines,
--   loops, trails, paths, vertex lists, and diagrams.
module Diagrams.TrailLike

-- | A type class for trail-like things, <i>i.e.</i> things which can be
--   constructed from a concretely located <a>Trail</a>. Instances include
--   lines, loops, trails, paths, lists of vertices, two-dimensional
--   <a>Diagram</a>s, and <a>Located</a> variants of all the above.
--   
--   Usually, type variables with <a>TrailLike</a> constraints are used as
--   the <i>output</i> types of functions, like
--   
--   <pre>
--   foo :: (TrailLike t) =&gt; ... -&gt; t
--   
--   </pre>
--   
--   Functions with such a type can be used to construct trails, paths,
--   diagrams, lists of points, and so on, depending on the context.
--   
--   To write a function with a signature like the above, you can of course
--   call <a>trailLike</a> directly; more typically, one would use one of
--   the provided functions like <a>fromOffsets</a>, <a>fromVertices</a>,
--   <a>fromSegments</a>, or <a>~~</a>.
class (Metric V t, OrderedField N t) => TrailLike t
trailLike :: TrailLike t => Located (Trail (V t) (N t)) -> t

-- | Construct a trail-like thing from a list of segments, with the origin
--   as the location.
--   
--   
--   <pre>
--   fromSegmentsEx = fromSegments
--     [ straight (r2 (1,1))
--     , bézier3  (r2 (1,1)) unitX unit_Y
--     , straight unit_X
--     ]
--     # centerXY # pad 1.1
--   </pre>
fromSegments :: TrailLike t => [Segment Closed (V t) (N t)] -> t

-- | Construct a trail-like thing from a located list of segments.
fromLocSegments :: TrailLike t => Located [Segment Closed (V t) (N t)] -> t

-- | Construct a trail-like thing of linear segments from a list of
--   offsets, with the origin as the location.
--   
--   
--   <pre>
--   fromOffsetsEx = fromOffsets
--     [ unitX
--     , unitX # rotateBy (1/6)
--     , unitX # rotateBy (-1/6)
--     , unitX
--     ]
--     # centerXY # pad 1.1
--   </pre>
fromOffsets :: TrailLike t => [Vn t] -> t

-- | Construct a trail-like thing of linear segments from a located list of
--   offsets.
fromLocOffsets :: (V t ~ v, N t ~ n, V (v n) ~ v, N (v n) ~ n, TrailLike t) => Located [v n] -> t

-- | Construct a trail-like thing connecting the given vertices with linear
--   segments, with the first vertex as the location. If no vertices are
--   given, the empty trail is used with the origin as the location.
--   
--   
--   <pre>
--   import Data.List (transpose)
--   
--   fromVerticesEx =
--     ( [ pentagon 1
--       , pentagon 1.3 # rotateBy (1/15)
--       , pentagon 1.5 # rotateBy (2/15)
--       ]
--       # transpose
--       # concat
--     )
--     # fromVertices
--     # closeTrail # strokeTrail
--     # centerXY # pad 1.1
--   </pre>
fromVertices :: TrailLike t => [Point (V t) (N t)] -> t

-- | Create a linear trail between two given points.
--   
--   
--   <pre>
--   twiddleEx
--     = mconcat ((~~) &lt;$&gt; hexagon 1 &lt;*&gt; hexagon 1)
--     # centerXY # pad 1.1
--   </pre>
(~~) :: forall t (v :: Type -> Type) n. (V t ~ v, N t ~ n, TrailLike t) => Point v n -> Point v n -> t

-- | Given a concretely located trail, "explode" it by turning each segment
--   into its own separate trail. Useful for (say) applying a different
--   style to each segment.
--   
--   
--   <pre>
--   explodeTrailEx
--     = pentagon 1
--     # explodeTrail  -- generate a list of diagrams
--     # zipWith lc [orange, green, yellow, red, blue]
--     # mconcat # centerXY # pad 1.1
--   </pre>
explodeTrail :: forall t (v :: Type -> Type) n. (V t ~ v, N t ~ n, TrailLike t) => Located (Trail v n) -> [t]
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.TrailLike.TrailLike [Linear.Affine.Point v n]
instance Diagrams.TrailLike.TrailLike t => Diagrams.TrailLike.TrailLike (Diagrams.Located.Located t)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.TrailLike.TrailLike (Diagrams.Trail.Trail v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.TrailLike.TrailLike (Diagrams.Trail.Trail' Diagrams.Trail.Line v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.TrailLike.TrailLike (Diagrams.Trail.Trail' Diagrams.Trail.Loop v n)
instance Diagrams.TrailLike.TrailLike t => Diagrams.TrailLike.TrailLike (Diagrams.Core.Transform.TransInv t)


-- | Two-dimensional arcs, approximated by cubic bezier curves.
module Diagrams.TwoD.Arc

-- | Given a start direction <tt>d</tt> and a sweep angle <tt>s</tt>,
--   <tt><a>arc</a> d s</tt> is the path of a radius one arc starting at
--   <tt>d</tt> and sweeping out the angle <tt>s</tt> counterclockwise (for
--   positive s). The resulting <tt>Trail</tt> is allowed to wrap around
--   and overlap itself.
arc :: (InSpace V2 n t, OrderedField n, TrailLike t) => Direction V2 n -> Angle n -> t

-- | Given a radus <tt>r</tt>, a start direction <tt>d</tt> and an angle
--   <tt>s</tt>, <tt><a>arc'</a> r d s</tt> is the path of a radius
--   <tt>(abs r)</tt> arc starting at <tt>d</tt> and sweeping out the angle
--   <tt>s</tt> counterclockwise (for positive s). The origin of the arc is
--   its center.
--   
--   
--   <pre>
--   arc'Ex = mconcat [ arc' r xDir (1/4 @@ turn) | r &lt;- [0.5,-1,1.5] ]
--          # centerXY # pad 1.1
--   </pre>
arc' :: (InSpace V2 n t, OrderedField n, TrailLike t) => n -> Direction V2 n -> Angle n -> t

-- | Given a start direction <tt>d</tt> and a sweep angle <tt>s</tt>,
--   <tt><a>arcT</a> d s</tt> is the <a>Trail</a> of a radius one arc
--   starting at <tt>d</tt> and sweeping out the angle <tt>s</tt>
--   counterclockwise (for positive s). The resulting <tt>Trail</tt> is
--   allowed to wrap around and overlap itself.
arcT :: OrderedField n => Direction V2 n -> Angle n -> Trail V2 n

-- | Given a start direction <tt>s</tt> and end direction <tt>e</tt>,
--   <tt>arcCCW s e</tt> is the path of a radius one arc counterclockwise
--   between the two directions. The origin of the arc is its center.
arcCCW :: (InSpace V2 n t, RealFloat n, TrailLike t) => Direction V2 n -> Direction V2 n -> t

-- | Like <tt>arcAngleCCW</tt> but clockwise.
arcCW :: (InSpace V2 n t, RealFloat n, TrailLike t) => Direction V2 n -> Direction V2 n -> t

-- | <tt>bezierFromSweep s</tt> constructs a series of <a>Cubic</a>
--   segments that start in the positive y direction and sweep counter
--   clockwise through the angle <tt>s</tt>. If <tt>s</tt> is negative, it
--   will start in the negative y direction and sweep clockwise. When
--   <tt>s</tt> is less than 0.0001 the empty list results. If the sweep is
--   greater than <tt>fullTurn</tt> later segments will overlap earlier
--   segments.
bezierFromSweep :: OrderedField n => Angle n -> [Segment Closed V2 n]

-- | Create a circular wedge of the given radius, beginning at the given
--   direction and extending through the given angle.
--   
--   
--   <pre>
--   wedgeEx = hcat' (with &amp; sep .~ 0.5)
--     [ wedge 1 xDir (1/4 @@ turn)
--     , wedge 1 (rotate (7/30 @@ turn) xDir) (4/30 @@ turn)
--     , wedge 1 (rotate (1/8 @@ turn) xDir) (3/4 @@ turn)
--     ]
--     # fc blue
--     # centerXY # pad 1.1
--   </pre>
wedge :: (InSpace V2 n t, OrderedField n, TrailLike t) => n -> Direction V2 n -> Angle n -> t

-- | <tt>arcBetween p q height</tt> creates an arc beginning at <tt>p</tt>
--   and ending at <tt>q</tt>, with its midpoint at a distance of <tt>abs
--   height</tt> away from the straight line from <tt>p</tt> to <tt>q</tt>.
--   A positive value of <tt>height</tt> results in an arc to the left of
--   the line from <tt>p</tt> to <tt>q</tt>; a negative value yields one to
--   the right.
--   
--   
--   <pre>
--   arcBetweenEx = mconcat
--     [ arcBetween origin (p2 (2,1)) ht | ht &lt;- [-0.2, -0.1 .. 0.2] ]
--     # centerXY # pad 1.1
--   </pre>
arcBetween :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => Point V2 n -> Point V2 n -> n -> t

-- | Create an annular wedge of the given radii, beginning at the first
--   direction and extending through the given sweep angle. The radius of
--   the outer circle is given first.
--   
--   
--   <pre>
--   annularWedgeEx = hsep 0.50
--     [ annularWedge 1 0.5 xDir (1/4 @@ turn)
--     , annularWedge 1 0.3 (rotate (7/30 @@ turn) xDir) (4/30 @@ turn)
--     , annularWedge 1 0.7 (rotate (1/8 @@ turn) xDir) (3/4 @@ turn)
--     ]
--     # fc blue
--     # centerXY # pad 1.1
--   </pre>
annularWedge :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => n -> n -> Direction V2 n -> Angle n -> t


-- | Two-dimensional ellipses (and, as a special case, circles).
module Diagrams.TwoD.Ellipse

-- | A circle of radius 1, with center at the origin.
unitCircle :: (TrailLike t, V t ~ V2, N t ~ n) => t

-- | A circle of the given radius, centered at the origin. As a path, it
--   begins at (r,0).
circle :: (TrailLike t, V t ~ V2, N t ~ n, Transformable t) => n -> t

-- | <tt>ellipse e</tt> constructs an ellipse with eccentricity <tt>e</tt>
--   by scaling the unit circle in the X direction. The eccentricity must
--   be within the interval [0,1).
ellipse :: (TrailLike t, V t ~ V2, N t ~ n, Transformable t) => n -> t

-- | <tt>ellipseXY x y</tt> creates an axis-aligned ellipse, centered at
--   the origin, with radius <tt>x</tt> along the x-axis and radius
--   <tt>y</tt> along the y-axis.
ellipseXY :: (TrailLike t, V t ~ V2, N t ~ n, Transformable t) => n -> n -> t


-- | A few utilities and class instances for <a>Active</a> (from the
--   <tt>active</tt> package). In particular, this module defines
--   
--   <ul>
--   <li>An instance of <a>V</a> for <a>Active</a>: <tt><a>V</a>
--   (<a>Active</a> a) = <a>V</a> a</tt></li>
--   <li><a>HasOrigin</a>, <a>Transformable</a>, and <a>HasStyle</a>
--   instances for <a>Active</a> which all work pointwise.</li>
--   <li>A <a>TrailLike</a> instance for <tt><a>Active</a> p</tt> where
--   <tt>p</tt> is also <a>TrailLike</a>, which simply lifts a pathlike
--   thing to a constant active value.</li>
--   <li>A <a>Juxtaposable</a> instance for <tt><a>Active</a> a</tt> where
--   <tt>a</tt> is also <a>Juxtaposable</a>. An active value can be
--   juxtaposed against another by doing the juxtaposition pointwise over
--   time. The era of <tt>juxtapose v a1 a2</tt> will be the same as the
--   era of <tt>a2</tt>, unless <tt>a2</tt> is constant, in which case it
--   will be the era of <tt>a1</tt>. (Note that <tt>juxtapose v a1 a2</tt>
--   and <tt>liftA2 (juxtapose v) a1 a2</tt> therefore have different
--   semantics: the second is an active value whose era is the
--   <i>combination</i> of the eras of <tt>a1</tt> and <tt>a2</tt>).</li>
--   <li>An <tt>Alignable</tt> instance for <tt><a>Active</a> a</tt> where
--   <tt>a</tt> is also <tt>Alignable</tt>; the active value is aligned
--   pointwise over time.</li>
--   </ul>
module Diagrams.Animation.Active
instance Diagrams.Core.HasOrigin.HasOrigin a => Diagrams.Core.HasOrigin.HasOrigin (Data.Active.Active a)
instance Diagrams.Core.Style.HasStyle a => Diagrams.Core.Style.HasStyle (Data.Active.Active a)
instance Diagrams.Core.Juxtapose.Juxtaposable a => Diagrams.Core.Juxtapose.Juxtaposable (Data.Active.Active a)
instance Diagrams.TrailLike.TrailLike t => Diagrams.TrailLike.TrailLike (Data.Active.Active t)
instance Diagrams.Core.Transform.Transformable a => Diagrams.Core.Transform.Transformable (Data.Active.Active a)


-- | Higher-level tools for combining diagrams.
module Diagrams.Combinators

-- | Use the envelope from some object as the envelope for a diagram, in
--   place of the diagram's default envelope.
--   
--   
--   <pre>
--   sqNewEnv =
--       circle 1 # fc green
--       |||
--       (    c # dashingG [0.1,0.1] 0 # lc white
--         &lt;&gt; square 2 # withEnvelope (c :: D V2 Double) # fc blue
--       )
--   c = circle 0.8
--   withEnvelopeEx = sqNewEnv # centerXY # pad 1.5
--   </pre>
withEnvelope :: forall (v :: Type -> Type) n a m b. (InSpace v n a, Monoid' m, Enveloped a) => a -> QDiagram b v n m -> QDiagram b v n m

-- | Use the trace from some object as the trace for a diagram, in place of
--   the diagram's default trace.
withTrace :: forall (v :: Type -> Type) n a m b. (InSpace v n a, Metric v, OrderedField n, Monoid' m, Traced a) => a -> QDiagram b v n m -> QDiagram b v n m

-- | <tt>phantom x</tt> produces a "phantom" diagram, which has the same
--   envelope and trace as <tt>x</tt> but produces no output.
phantom :: forall (v :: Type -> Type) n a m b. (InSpace v n a, Monoid' m, Enveloped a, Traced a) => a -> QDiagram b v n m

-- | <tt>strut v</tt> is a diagram which produces no output, but with
--   respect to alignment and envelope acts like a 1-dimensional segment
--   oriented along the vector <tt>v</tt>, with local origin at its center.
--   (Note, however, that it has an empty trace; for 2D struts with a
--   nonempty trace see <tt>strutR2</tt> from
--   <a>Diagrams.TwoD.Combinators</a>.) Useful for manually creating
--   separation between two diagrams.
--   
--   
--   <pre>
--   strutEx = (circle 1 ||| strut unitX ||| circle 1) # centerXY # pad 1.1
--   </pre>
strut :: (Metric v, OrderedField n) => v n -> QDiagram b v n m

-- | <tt>pad s</tt> "pads" a diagram, expanding its envelope by a factor of
--   <tt>s</tt> (factors between 0 and 1 can be used to shrink the
--   envelope). Note that the envelope will expand with respect to the
--   local origin, so if the origin is not centered the padding may appear
--   "uneven". If this is not desired, the origin can be centered (using,
--   e.g., <tt>centerXY</tt> for 2D diagrams) before applying <tt>pad</tt>.
pad :: forall (v :: Type -> Type) n m b. (Metric v, OrderedField n, Monoid' m) => n -> QDiagram b v n m -> QDiagram b v n m

-- | <tt>frame s</tt> increases the envelope of a diagram by and absolute
--   amount <tt>s</tt>, s is in the local units of the diagram. This
--   function is similar to <tt>pad</tt>, only it takes an absolute
--   quantity and pre-centering should not be necessary.
frame :: forall (v :: Type -> Type) n m b. (Metric v, OrderedField n, Monoid' m) => n -> QDiagram b v n m -> QDiagram b v n m

-- | <tt>extrudeEnvelope v d</tt> asymmetrically "extrudes" the envelope of
--   a diagram in the given direction. All parts of the envelope within 90
--   degrees of this direction are modified, offset outwards by the
--   magnitude of the vector.
--   
--   This works by offsetting the envelope distance proportionally to the
--   cosine of the difference in angle, and leaving it unchanged when this
--   factor is negative.
extrudeEnvelope :: (Metric v, OrderedField n, Monoid' m) => v n -> QDiagram b v n m -> QDiagram b v n m

-- | <tt>intrudeEnvelope v d</tt> asymmetrically "intrudes" the envelope of
--   a diagram away from the given direction. All parts of the envelope
--   within 90 degrees of this direction are modified, offset inwards by
--   the magnitude of the vector.
--   
--   Note that this could create strange inverted envelopes, where <tt>
--   diameter v d &lt; 0 </tt>.
intrudeEnvelope :: (Metric v, OrderedField n, Monoid' m) => v n -> QDiagram b v n m -> QDiagram b v n m

-- | A convenient synonym for <a>mappend</a> on diagrams, designed to be
--   used infix (to help remember which diagram goes on top of which when
--   combining them, namely, the first on top of the second).
atop :: forall n (v :: Type -> Type) m b. (OrderedField n, Metric v, Semigroup m) => QDiagram b v n m -> QDiagram b v n m -> QDiagram b v n m
infixl 6 `atop`

-- | <tt>beneath</tt> is just a convenient synonym for <tt><a>flip</a>
--   <a>atop</a></tt>; that is, <tt>d1 `beneath` d2</tt> is the diagram
--   with <tt>d2</tt> superimposed on top of <tt>d1</tt>.
beneath :: forall (v :: Type -> Type) n m b. (Metric v, OrderedField n, Monoid' m) => QDiagram b v n m -> QDiagram b v n m -> QDiagram b v n m
infixl 6 `beneath`

-- | Place two monoidal objects (<i>i.e.</i> diagrams, paths,
--   animations...) next to each other along the given vector. In
--   particular, place the second object so that the vector points from the
--   local origin of the first object to the local origin of the second
--   object, at a distance so that their envelopes are just tangent. The
--   local origin of the new, combined object is the local origin of the
--   first object (unless the first object is the identity element, in
--   which case the second object is returned unchanged).
--   
--   
--   <pre>
--   besideEx = beside (r2 (20,30))
--                     (circle 1 # fc orange)
--                     (circle 1.5 # fc purple)
--              # showOrigin
--              # centerXY # pad 1.1
--   </pre>
--   
--   Note that <tt>beside v</tt> is associative, so objects under
--   <tt>beside v</tt> form a semigroup for any given vector <tt>v</tt>. In
--   fact, they also form a monoid: <a>mempty</a> is clearly a right
--   identity (<tt>beside v d1 mempty === d1</tt>), and there should also
--   be a special case to make it a left identity, as described above.
--   
--   In older versions of diagrams, <tt>beside</tt> put the local origin of
--   the result at the point of tangency between the two inputs. That
--   semantics can easily be recovered by performing an alignment on the
--   first input before combining. That is, if <tt>beside'</tt> denotes the
--   old semantics,
--   
--   <pre>
--   beside' v x1 x2 = beside v (x1 # align v) x2
--   </pre>
--   
--   To get something like <tt>beside v x1 x2</tt> whose local origin is
--   identified with that of <tt>x2</tt> instead of <tt>x1</tt>, use
--   <tt>beside (negateV v) x2 x1</tt>.
beside :: (Juxtaposable a, Semigroup a) => Vn a -> a -> a -> a

-- | Place two diagrams (or other juxtaposable objects) adjacent to one
--   another, with the second diagram placed in the direction <tt>d</tt>
--   from the first. The local origin of the resulting combined diagram is
--   the same as the local origin of the first. See the documentation of
--   <a>beside</a> for more information.
atDirection :: forall (v :: Type -> Type) n a. (InSpace v n a, Metric v, Floating n, Juxtaposable a, Semigroup a) => Direction v n -> a -> a -> a

-- | <tt>appends x ys</tt> appends each of the objects in <tt>ys</tt> to
--   the object <tt>x</tt> in the corresponding direction. Note that each
--   object in <tt>ys</tt> is positioned beside <tt>x</tt> <i>without</i>
--   reference to the other objects in <tt>ys</tt>, so this is not the same
--   as iterating <a>beside</a>.
--   
--   
--   <pre>
--   appendsEx = appends c (zip (iterateN 6 (rotateBy (1/6)) unitX) (repeat c))
--               # centerXY # pad 1.1
--     where c = circle 1
--   </pre>
appends :: (Juxtaposable a, Monoid' a) => a -> [(Vn a, a)] -> a

-- | Position things absolutely: combine a list of objects (e.g. diagrams
--   or paths) by assigning them absolute positions in the vector space of
--   the combined object.
--   
--   
--   <pre>
--   positionEx = position (zip (map mkPoint [-3, -2.8 .. 3]) (repeat spot))
--     where spot      = circle 0.2 # fc black
--           mkPoint :: Double -&gt; P2 Double
--           mkPoint x = p2 (x,x*x)
--   </pre>
position :: forall (v :: Type -> Type) n a. (InSpace v n a, HasOrigin a, Monoid' a) => [(Point v n, a)] -> a

-- | Curried version of <tt>position</tt>, takes a list of points and a
--   list of objects.
atPoints :: forall (v :: Type -> Type) n a. (InSpace v n a, HasOrigin a, Monoid' a) => [Point v n] -> [a] -> a

-- | <tt>cat v</tt> positions a list of objects so that their local origins
--   lie along a line in the direction of <tt>v</tt>. Successive objects
--   will have their envelopes just touching. The local origin of the
--   result will be the same as the local origin of the first object.
--   
--   See also <a>cat'</a>, which takes an extra options record allowing
--   certain aspects of the operation to be tweaked.
cat :: (InSpace v n a, Metric v, Floating n, Juxtaposable a, Monoid' a, HasOrigin a) => v n -> [a] -> a

-- | Like <a>cat</a>, but taking an extra <a>CatOpts</a> arguments allowing
--   the user to specify
--   
--   <ul>
--   <li>The spacing method: catenation (uniform spacing between envelopes)
--   or distribution (uniform spacing between local origins). The default
--   is catenation.</li>
--   <li>The amount of separation between successive diagram
--   envelopes/origins (depending on the spacing method). The default is
--   0.</li>
--   </ul>
--   
--   <a>CatOpts</a> is an instance of <a>Default</a>, so <a>with</a> may be
--   used for the second argument, as in <tt>cat' (1,2) (with &amp; sep .~
--   2)</tt>.
--   
--   Note that <tt>cat' v (with &amp; catMethod .~ Distrib) ===
--   mconcat</tt> (distributing with a separation of 0 is the same as
--   superimposing).
cat' :: (InSpace v n a, Metric v, Floating n, Juxtaposable a, Monoid' a, HasOrigin a) => v n -> CatOpts n -> [a] -> a

-- | Options for <tt>cat'</tt>.
data CatOpts n

-- | Which <a>CatMethod</a> should be used: normal catenation (default), or
--   distribution?
catMethod :: forall n f. Functor f => (CatMethod -> f CatMethod) -> CatOpts n -> f (CatOpts n)

-- | How much separation should be used between successive diagrams
--   (default: 0)? When <tt>catMethod = Cat</tt>, this is the distance
--   between <i>envelopes</i>; when <tt>catMethod = Distrib</tt>, this is
--   the distance between <i>origins</i>.
sep :: forall n f. Functor f => (n -> f n) -> CatOpts n -> f (CatOpts n)

-- | Methods for concatenating diagrams.
data CatMethod

-- | Normal catenation: simply put diagrams next to one another (possibly
--   with a certain distance in between each). The distance between
--   successive diagram <i>envelopes</i> will be consistent; the distance
--   between <i>origins</i> may vary if the diagrams are of different
--   sizes.
Cat :: CatMethod

-- | Distribution: place the local origins of diagrams at regular
--   intervals. With this method, the distance between successive
--   <i>origins</i> will be consistent but the distance between envelopes
--   may not be. Indeed, depending on the amount of separation, diagrams
--   may overlap.
Distrib :: CatMethod

-- | Compose a list of diagrams using the given composition function, first
--   aligning them all according to the given alignment, <i>but</i> retain
--   the local origin of the first diagram, as it would be if the
--   composition function were applied directly. That is,
--   <tt>composeAligned algn comp</tt> is equivalent to <tt>translate v .
--   comp . map algn</tt> for some appropriate translation vector
--   <tt>v</tt>.
--   
--   Unfortunately, this only works for diagrams (and not, say, paths)
--   because there is no most general type for alignment functions, and no
--   generic way to find out what an alignment function does to the origin
--   of things. (However, it should be possible to make a version of this
--   function that works <i>specifically</i> on paths, if such a thing were
--   deemed useful.)
--   
--   
--   <pre>
--   alignedEx1 = (hsep 2 # composeAligned alignT) (map circle [1,3,5,2])
--              # showOrigin
--              # frame 0.5
--   </pre>
--   
--   
--   <pre>
--   alignedEx2 = (mconcat # composeAligned alignTL) [circle 1, square 1, triangle 1, pentagon 1]
--              # showOrigin
--              # frame 0.1
--   </pre>
composeAligned :: forall m n (v :: Type -> Type) b. (Monoid' m, Floating n, Ord n, Metric v) => (QDiagram b v n m -> QDiagram b v n m) -> ([QDiagram b v n m] -> QDiagram b v n m) -> [QDiagram b v n m] -> QDiagram b v n m
instance GHC.Internal.Num.Num n => Data.Default.Internal.Default (Diagrams.Combinators.CatOpts n)


-- | "Traces", aka embedded raytracers, for finding points on the edge of a
--   diagram. See <a>Diagrams.Core.Trace</a> for internal implementation
--   details.
module Diagrams.Trace

-- | Every diagram comes equipped with a <i>trace</i>. Intuitively, the
--   trace for a diagram is like a raytracer: given a line (represented as
--   a base point and a direction vector), the trace computes a sorted list
--   of signed distances from the base point to all intersections of the
--   line with the boundary of the diagram.
--   
--   Note that the outputs are not absolute distances, but multipliers
--   relative to the input vector. That is, if the base point is <tt>p</tt>
--   and direction vector is <tt>v</tt>, and one of the output scalars is
--   <tt>s</tt>, then there is an intersection at the point <tt>p .+^ (s *^
--   v)</tt>.
--   
data Trace (v :: Type -> Type) n

-- | <tt>Traced</tt> abstracts over things which have a trace.
class (Additive V a, Ord N a) => Traced a

-- | Lens onto the <a>Trace</a> of a <a>QDiagram</a>.
trace :: forall (v :: Type -> Type) n m b. (Metric v, OrderedField n, Semigroup m) => Lens' (QDiagram b v n m) (Trace v n)

-- | Replace the trace of a diagram.
setTrace :: forall b (v :: Type -> Type) n m. (OrderedField n, Metric v, Semigroup m) => Trace v n -> QDiagram b v n m -> QDiagram b v n m

-- | Use the trace from some object as the trace for a diagram, in place of
--   the diagram's default trace.
withTrace :: forall (v :: Type -> Type) n a m b. (InSpace v n a, Metric v, OrderedField n, Monoid' m, Traced a) => a -> QDiagram b v n m -> QDiagram b v n m

-- | Compute the vector from the given point <tt>p</tt> to the "smallest"
--   boundary intersection along the given vector <tt>v</tt>. The
--   "smallest" boundary intersection is defined as the one given by <tt>p
--   .+^ (s *^ v)</tt> for the smallest (most negative) value of
--   <tt>s</tt>. Return <tt>Nothing</tt> if there is no intersection. See
--   also <a>traceP</a>.
--   
--   See also <a>rayTraceV</a> which uses the smallest <i>positive</i>
--   intersection, which is often more intuitive behavior.
--   
traceV :: (n ~ N a, Num n, Traced a) => Point (V a) n -> V a n -> a -> Maybe (V a n)

-- | Compute the "smallest" boundary point along the line determined by the
--   given point <tt>p</tt> and vector <tt>v</tt>. The "smallest" boundary
--   point is defined as the one given by <tt>p .+^ (s *^ v)</tt> for the
--   smallest (most negative) value of <tt>s</tt>. Return <tt>Nothing</tt>
--   if there is no such boundary point. See also <a>traceV</a>.
--   
--   See also <a>rayTraceP</a> which uses the smallest <i>positive</i>
--   intersection, which is often more intuitive behavior.
--   
traceP :: (n ~ N a, Traced a, Num n) => Point (V a) n -> V a n -> a -> Maybe (Point (V a) n)

-- | Like <a>traceV</a>, but computes a vector to the "largest" boundary
--   point instead of the smallest. (Note, however, the "largest" boundary
--   point may still be in the opposite direction from the given vector, if
--   all the boundary points are, as in the third example shown below.)
--   
maxTraceV :: (n ~ N a, Num n, Traced a) => Point (V a) n -> V a n -> a -> Maybe (V a n)

-- | Like <a>traceP</a>, but computes the "largest" boundary point instead
--   of the smallest. (Note, however, the "largest" boundary point may
--   still be in the opposite direction from the given vector, if all the
--   boundary points are.)
--   
maxTraceP :: (n ~ N a, Num n, Traced a) => Point (V a) n -> V a n -> a -> Maybe (Point (V a) n)

-- | Compute the furthest point on the boundary of a subdiagram, beginning
--   from the location (local origin) of the subdiagram and moving in the
--   direction of the given vector. If there is no such point, the origin
--   is returned; see also <a>boundaryFromMay</a>.
boundaryFrom :: (OrderedField n, Metric v, Semigroup m) => Subdiagram b v n m -> v n -> Point v n

-- | Compute the furthest point on the boundary of a subdiagram, beginning
--   from the location (local origin) of the subdiagram and moving in the
--   direction of the given vector, or <tt>Nothing</tt> if there is no such
--   point.
boundaryFromMay :: (Metric v, OrderedField n, Semigroup m) => Subdiagram b v n m -> v n -> Maybe (Point v n)


-- | "Envelopes", aka functional bounding regions. See
--   <a>Diagrams.Core.Envelope</a> for internal implementation details.
module Diagrams.Envelope

-- | Every diagram comes equipped with an <i>envelope</i>. What is an
--   envelope?
--   
--   Consider first the idea of a <i>bounding box</i>. A bounding box
--   expresses the distance to a bounding plane in every direction parallel
--   to an axis. That is, a bounding box can be thought of as the
--   intersection of a collection of half-planes, two perpendicular to each
--   axis.
--   
--   More generally, the intersection of half-planes in <i>every</i>
--   direction would give a tight "bounding region", or convex hull.
--   However, representing such a thing intensionally would be impossible;
--   hence bounding boxes are often used as an approximation.
--   
--   An envelope is an <i>extensional</i> representation of such a
--   "bounding region". Instead of storing some sort of direct
--   representation, we store a <i>function</i> which takes a direction as
--   input and gives a distance to a bounding half-plane as output. The
--   important point is that envelopes can be composed, and transformed by
--   any affine transformation.
--   
--   Formally, given a vector <tt>v</tt>, the envelope computes a scalar
--   <tt>s</tt> such that
--   
--   <ul>
--   <li>for every point <tt>u</tt> inside the diagram, if the projection
--   of <tt>(u - origin)</tt> onto <tt>v</tt> is <tt>s' *^ v</tt>, then
--   <tt>s' &lt;= s</tt>.</li>
--   <li><tt>s</tt> is the smallest such scalar.</li>
--   </ul>
--   
--   There is also a special "empty envelope".
--   
--   The idea for envelopes came from Sebastian Setzer; see
--   <a>http://byorgey.wordpress.com/2009/10/28/collecting-attributes/#comment-2030</a>.
--   See also Brent Yorgey, <i>Monoids: Theme and Variations</i>, published
--   in the 2012 Haskell Symposium:
--   <a>http://ozark.hendrix.edu/~yorgey/pub/monoid-pearl.pdf</a>; video:
--   <a>http://www.youtube.com/watch?v=X-8NCkD2vOw</a>.
data Envelope (v :: Type -> Type) n

-- | <tt>Enveloped</tt> abstracts over things which have an envelope.
class (Metric V a, OrderedField N a) => Enveloped a

-- | Lens onto the <a>Envelope</a> of a <a>QDiagram</a>.
envelope :: forall n (v :: Type -> Type) m b. (OrderedField n, Metric v, Monoid' m) => Lens' (QDiagram b v n m) (Envelope v n)

-- | Replace the envelope of a diagram.
setEnvelope :: forall b (v :: Type -> Type) n m. (OrderedField n, Metric v, Monoid' m) => Envelope v n -> QDiagram b v n m -> QDiagram b v n m

-- | Use the envelope from some object as the envelope for a diagram, in
--   place of the diagram's default envelope.
--   
--   
--   <pre>
--   sqNewEnv =
--       circle 1 # fc green
--       |||
--       (    c # dashingG [0.1,0.1] 0 # lc white
--         &lt;&gt; square 2 # withEnvelope (c :: D V2 Double) # fc blue
--       )
--   c = circle 0.8
--   withEnvelopeEx = sqNewEnv # centerXY # pad 1.5
--   </pre>
withEnvelope :: forall (v :: Type -> Type) n a m b. (InSpace v n a, Monoid' m, Enveloped a) => a -> QDiagram b v n m -> QDiagram b v n m

-- | <tt>phantom x</tt> produces a "phantom" diagram, which has the same
--   envelope and trace as <tt>x</tt> but produces no output.
phantom :: forall (v :: Type -> Type) n a m b. (InSpace v n a, Monoid' m, Enveloped a, Traced a) => a -> QDiagram b v n m

-- | <tt>pad s</tt> "pads" a diagram, expanding its envelope by a factor of
--   <tt>s</tt> (factors between 0 and 1 can be used to shrink the
--   envelope). Note that the envelope will expand with respect to the
--   local origin, so if the origin is not centered the padding may appear
--   "uneven". If this is not desired, the origin can be centered (using,
--   e.g., <tt>centerXY</tt> for 2D diagrams) before applying <tt>pad</tt>.
pad :: forall (v :: Type -> Type) n m b. (Metric v, OrderedField n, Monoid' m) => n -> QDiagram b v n m -> QDiagram b v n m

-- | <tt>extrudeEnvelope v d</tt> asymmetrically "extrudes" the envelope of
--   a diagram in the given direction. All parts of the envelope within 90
--   degrees of this direction are modified, offset outwards by the
--   magnitude of the vector.
--   
--   This works by offsetting the envelope distance proportionally to the
--   cosine of the difference in angle, and leaving it unchanged when this
--   factor is negative.
extrudeEnvelope :: (Metric v, OrderedField n, Monoid' m) => v n -> QDiagram b v n m -> QDiagram b v n m

-- | <tt>intrudeEnvelope v d</tt> asymmetrically "intrudes" the envelope of
--   a diagram away from the given direction. All parts of the envelope
--   within 90 degrees of this direction are modified, offset inwards by
--   the magnitude of the vector.
--   
--   Note that this could create strange inverted envelopes, where <tt>
--   diameter v d &lt; 0 </tt>.
intrudeEnvelope :: (Metric v, OrderedField n, Monoid' m) => v n -> QDiagram b v n m -> QDiagram b v n m

-- | Compute the vector from the local origin to a separating hyperplane in
--   the given direction, or <tt>Nothing</tt> for the empty envelope.
envelopeVMay :: Enveloped a => Vn a -> a -> Maybe (Vn a)

-- | Compute the vector from the local origin to a separating hyperplane in
--   the given direction. Returns the zero vector for the empty envelope.
envelopeV :: Enveloped a => Vn a -> a -> Vn a

-- | Compute the point on a separating hyperplane in the given direction,
--   or <tt>Nothing</tt> for the empty envelope.
envelopePMay :: (V a ~ v, N a ~ n, Enveloped a) => v n -> a -> Maybe (Point v n)

-- | Compute the point on a separating hyperplane in the given direction.
--   Returns the origin for the empty envelope.
envelopeP :: (V a ~ v, N a ~ n, Enveloped a) => v n -> a -> Point v n

-- | Compute the diameter of a enveloped object along a particular vector.
--   Returns zero for the empty envelope.
diameter :: (V a ~ v, N a ~ n, Enveloped a) => v n -> a -> n

-- | Compute the "radius" (1/2 the diameter) of an enveloped object along a
--   particular vector.
radius :: (V a ~ v, N a ~ n, Enveloped a) => v n -> a -> n


-- | This module defines <i>paths</i>, which are collections of concretely
--   located <a>Trail</a>s. Many drawing systems (cairo, svg, ...) have a
--   similar notion of "path". Note that paths with multiple trails are
--   necessary for being able to draw <i>e.g.</i> filled objects with holes
--   in them.
module Diagrams.Path

-- | A <i>path</i> is a (possibly empty) list of <a>Located</a>
--   <a>Trail</a>s. Hence, unlike trails, paths are not translationally
--   invariant, and they form a monoid under <i>superposition</i> (placing
--   one path on top of another) rather than concatenation.
newtype Path (v :: Type -> Type) n
Path :: [Located (Trail v n)] -> Path (v :: Type -> Type) n

-- | Extract the located trails making up a <a>Path</a>.
pathTrails :: forall (v :: Type -> Type) n. Path v n -> [Located (Trail v n)]

-- | Type class for things that can be converted to a <a>Path</a>.
--   
--   Note that this class is very different from <a>TrailLike</a>.
--   <a>TrailLike</a> is usually the result of a library function to give
--   you a convenient, polymorphic result (<a>Path</a>, <a>Diagram</a>
--   etc.).
class ToPath t

-- | <a>toPath</a> takes something that can be converted to <a>Path</a> and
--   returns the <a>Path</a>.
toPath :: ToPath t => t -> Path (V t) (N t)

-- | Convert a trail to a path beginning at the origin.
pathFromTrail :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail v n -> Path v n

-- | Convert a trail to a path with a particular starting point.
pathFromTrailAt :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail v n -> Point v n -> Path v n

-- | Convert a located trail to a singleton path. This is equivalent to
--   <a>trailLike</a>, but provided with a more specific name and type for
--   convenience.
pathFromLocTrail :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Located (Trail v n) -> Path v n

-- | Extract the points of a path, resulting in a separate list of points
--   for each component trail. Here a <i>point</i> is any place where two
--   segments join; see also <a>pathVertices</a> and <a>trailPoints</a>.
--   
--   This function allows you "observe" the fact that trails are
--   implemented as lists of segments, which may be problematic if we want
--   to think of trails as parametric vector functions. This also means
--   that the behavior of this function may not be stable under future
--   changes to the implementation of trails and paths. For an
--   unproblematic version which only yields vertices at which there is a
--   sharp corner, excluding points differentiable points, see
--   <a>pathVertices</a>.
--   
--   This function is not re-exported from <a>Diagrams.Prelude</a>; to use
--   it, import <a>Diagrams.Path</a>.
pathPoints :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Path v n -> [[Point v n]]

-- | Extract the vertices of a path, resulting in a separate list of
--   vertices for each component trail. Here a <i>vertex</i> is defined as
--   a non-differentiable point on the trail, <i>i.e.</i> a sharp corner.
--   (Vertices are thus a subset of the places where segments join; if you
--   want all joins between segments, see <a>pathPoints</a>.) The tolerance
--   determines how close the tangents of two segments must be at their
--   endpoints to consider the transition point to be differentiable. See
--   <a>trailVertices</a> for more information.
pathVertices' :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => n -> Path v n -> [[Point v n]]

-- | Like <a>pathVertices'</a>, with a default tolerance.
pathVertices :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Path v n -> [[Point v n]]

-- | Compute the total offset of each trail comprising a path (see
--   <a>trailOffset</a>).
pathOffsets :: (Metric v, OrderedField n) => Path v n -> [v n]

-- | Compute the <i>centroid</i> of a path (<i>i.e.</i> the average
--   location of its <i>vertices</i>; see <a>pathVertices</a>).
pathCentroid :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Path v n -> Point v n

-- | Convert a path into a list of lists of located segments.
pathLocSegments :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Path v n -> [[Located (Segment Closed v n)]]

-- | Convert a path into a list of lists of <a>FixedSegment</a>s.
fixPath :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Path v n -> [[FixedSegment v n]]

-- | Scale a path using its centroid (see <a>pathCentroid</a>) as the base
--   point for the scale.
scalePath :: forall (v :: Type -> Type) n. (HasLinearMap v, Metric v, OrderedField n) => n -> Path v n -> Path v n

-- | Reverse all the component trails of a path.
reversePath :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Path v n -> Path v n

-- | "Explode" a path by exploding every component trail (see
--   <a>explodeTrail</a>).
explodePath :: forall t (v :: Type -> Type) n. (V t ~ v, N t ~ n, TrailLike t) => Path v n -> [[t]]

-- | Partition a path into two paths based on a predicate on trails: the
--   first containing all the trails for which the predicate returns
--   <tt>True</tt>, and the second containing the remaining trails.
partitionPath :: forall (v :: Type -> Type) n. (Located (Trail v n) -> Bool) -> Path v n -> (Path v n, Path v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Align.Alignable (Diagrams.Path.Path v n)
instance Control.Lens.Empty.AsEmpty (Diagrams.Path.Path v n)
instance Control.Lens.Cons.Cons (Diagrams.Path.Path v n) (Diagrams.Path.Path v' n') (Diagrams.Located.Located (Diagrams.Trail.Trail v n)) (Diagrams.Located.Located (Diagrams.Trail.Trail v' n'))
instance Control.Lens.Each.Each (Diagrams.Path.Path v n) (Diagrams.Path.Path v' n') (Diagrams.Located.Located (Diagrams.Trail.Trail v n)) (Diagrams.Located.Located (Diagrams.Trail.Trail v' n'))
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Envelope.Enveloped (Diagrams.Path.Path v n)
instance GHC.Classes.Eq (v n) => GHC.Classes.Eq (Diagrams.Path.Path v n)
instance GHC.Internal.Generics.Generic (Diagrams.Path.Path v n)
instance (Linear.Vector.Additive v, GHC.Internal.Num.Num n) => Diagrams.Core.HasOrigin.HasOrigin (Diagrams.Path.Path v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Juxtapose.Juxtaposable (Diagrams.Path.Path v n)
instance GHC.Internal.Base.Monoid (Diagrams.Path.Path v n)
instance GHC.Classes.Ord (v n) => GHC.Classes.Ord (Diagrams.Path.Path v n)
instance (Diagrams.Core.Transform.HasLinearMap v, Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Types.Renderable (Diagrams.Path.Path v n) Diagrams.Core.Types.NullBackend
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Control.Lens.Internal.Iso.Reversing (Diagrams.Path.Path v n)
instance Control.Lens.Wrapped.Rewrapped (Diagrams.Path.Path v n) (Diagrams.Path.Path v' n')
instance GHC.Internal.Base.Semigroup (Diagrams.Path.Path v n)
instance (Diagrams.Core.Envelope.OrderedField n, Linear.Metric.Metric v, Data.Serialize.Serialize (v n), Data.Serialize.Serialize (Diagrams.Core.V.V (v n) (Diagrams.Core.V.N (v n)))) => Data.Serialize.Serialize (Diagrams.Path.Path v n)
instance GHC.Internal.Show.Show (v n) => GHC.Internal.Show.Show (Diagrams.Path.Path v n)
instance Control.Lens.Cons.Snoc (Diagrams.Path.Path v n) (Diagrams.Path.Path v' n') (Diagrams.Located.Located (Diagrams.Trail.Trail v n)) (Diagrams.Located.Located (Diagrams.Trail.Trail v' n'))
instance Diagrams.Path.ToPath (Diagrams.Segment.FixedSegment v n)
instance Diagrams.Path.ToPath a => Diagrams.Path.ToPath [a]
instance Diagrams.Path.ToPath (Diagrams.Located.Located (Diagrams.Trail.Trail v n))
instance Diagrams.Path.ToPath (Diagrams.Located.Located (Diagrams.Trail.Trail' l v n))
instance Diagrams.Path.ToPath (Diagrams.Located.Located (Diagrams.Segment.Segment Diagrams.Segment.Closed v n))
instance Diagrams.Path.ToPath (Diagrams.Located.Located [Diagrams.Segment.Segment Diagrams.Segment.Closed v n])
instance Diagrams.Path.ToPath (Diagrams.Path.Path v n)
instance Diagrams.Path.ToPath (Diagrams.Trail.Trail v n)
instance Diagrams.Path.ToPath (Diagrams.Trail.Trail' l v n)
instance (Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.TrailLike.TrailLike (Diagrams.Path.Path v n)
instance (Diagrams.Core.Transform.HasLinearMap v, Linear.Metric.Metric v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Transform.Transformable (Diagrams.Path.Path v n)
instance Control.Lens.Wrapped.Wrapped (Diagrams.Path.Path v n)


-- | This module defines a general API for creating various types of
--   polygons.
module Diagrams.TwoD.Polygons

-- | Method used to determine the vertices of a polygon.
data PolyType n

-- | A "polar" polygon.
--   
--   <ul>
--   <li>The first argument is a list of <i>central</i> <i>angles</i> from
--   each vertex to the next.</li>
--   <li>The second argument is a list of <i>radii</i> from the origin to
--   each successive vertex.</li>
--   </ul>
--   
--   To construct an <i>n</i>-gon, use a list of <i>n-1</i> angles and
--   <i>n</i> radii. Extra angles or radii are ignored.
--   
--   Cyclic polygons (with all vertices lying on a circle) can be
--   constructed using a second argument of <tt>(repeat r)</tt>.
PolyPolar :: [Angle n] -> [n] -> PolyType n

-- | A polygon determined by the distance between successive vertices and
--   the external angles formed by each three successive vertices. In other
--   words, a polygon specified by "turtle graphics": go straight ahead x1
--   units; turn by external angle a1; go straight ahead x2 units; turn by
--   external angle a2; etc. The polygon will be centered at the
--   <i>centroid</i> of its vertices.
--   
--   <ul>
--   <li>The first argument is a list of <i>vertex</i> <i>angles</i>,
--   giving the external angle at each vertex from the previous vertex to
--   the next. The first angle in the list is the external angle at the
--   <i>second</i> vertex; the first edge always starts out heading in the
--   positive y direction from the first vertex.</li>
--   <li>The second argument is a list of distances between successive
--   vertices.</li>
--   </ul>
--   
--   To construct an <i>n</i>-gon, use a list of <i>n-2</i> angles and
--   <i>n-1</i> edge lengths. Extra angles or lengths are ignored.
PolySides :: [Angle n] -> [n] -> PolyType n

-- | A regular polygon with the given number of sides (first argument) and
--   the given radius (second argument).
PolyRegular :: Int -> n -> PolyType n

-- | Determine how a polygon should be oriented.
data PolyOrientation n

-- | No special orientation; the first vertex will be at (1,0).
NoOrient :: PolyOrientation n

-- | Orient <i>horizontally</i>, so the bottommost edge is parallel to the
--   x-axis. This is the default.
OrientH :: PolyOrientation n

-- | Orient <i>vertically</i>, so the leftmost edge is parallel to the
--   y-axis.
OrientV :: PolyOrientation n

-- | Orient so some edge is <i>facing</i> <i>in</i> <i>the</i>
--   <i>direction</i> <i>of</i>, that is, perpendicular to, the given
--   vector.
OrientTo :: V2 n -> PolyOrientation n

-- | Options for specifying a polygon.
data PolygonOpts n
PolygonOpts :: PolyType n -> PolyOrientation n -> Point V2 n -> PolygonOpts n
[_polyType] :: PolygonOpts n -> PolyType n
[_polyOrient] :: PolygonOpts n -> PolyOrientation n
[_polyCenter] :: PolygonOpts n -> Point V2 n

-- | Specification for the polygon's vertices.
polyType :: forall n f. Functor f => (PolyType n -> f (PolyType n)) -> PolygonOpts n -> f (PolygonOpts n)

-- | Should a rotation be applied to the polygon in order to orient it in a
--   particular way?
polyOrient :: forall n f. Functor f => (PolyOrientation n -> f (PolyOrientation n)) -> PolygonOpts n -> f (PolygonOpts n)

-- | Should a translation be applied to the polygon in order to place the
--   center at a particular location?
polyCenter :: forall n f. Functor f => (Point V2 n -> f (Point V2 n)) -> PolygonOpts n -> f (PolygonOpts n)

-- | Generate the polygon described by the given options.
polygon :: (InSpace V2 n t, TrailLike t) => PolygonOpts n -> t

-- | Generate a polygon. See <a>PolygonOpts</a> for more information.
polyTrail :: OrderedField n => PolygonOpts n -> Located (Trail V2 n)

-- | Generate the located trail of a polygon specified by polar data
--   (central angles and radii). See <a>PolyPolar</a>.
polyPolarTrail :: OrderedField n => [Angle n] -> [n] -> Located (Trail V2 n)

-- | Generate the vertices of a polygon specified by side length and
--   angles, and a starting point for the trail such that the origin is at
--   the centroid of the vertices. See <a>PolySides</a>.
polySidesTrail :: OrderedField n => [Angle n] -> [n] -> Located (Trail V2 n)

-- | Generate the vertices of a regular polygon. See <a>PolyRegular</a>.
polyRegularTrail :: OrderedField n => Int -> n -> Located (Trail V2 n)

-- | Generate a transformation to orient a trail. <tt>orient v t</tt>
--   generates the smallest rotation such that one of the segments adjacent
--   to the vertex furthest in the direction of <tt>v</tt> is perpendicular
--   to <tt>v</tt>.
orient :: OrderedField n => V2 n -> Located (Trail V2 n) -> Transformation V2 n

-- | Options for creating "star" polygons, where the edges connect possibly
--   non-adjacent vertices.
data StarOpts

-- | Specify the order in which the vertices should be connected by a
--   function that maps each vertex index to the index of the vertex that
--   should come next. Indexing of vertices begins at 0.
StarFun :: (Int -> Int) -> StarOpts

-- | Specify a star polygon by a "skip". A skip of 1 indicates a normal
--   polygon, where edges go between successive vertices. A skip of 2 means
--   that edges will connect every second vertex, skipping one in between.
--   Generally, a skip of <i>n</i> means that edges will connect every
--   <i>n</i>th vertex.
StarSkip :: Int -> StarOpts

-- | Create a generalized <i>star</i> <i>polygon</i>. The <a>StarOpts</a>
--   are used to determine in which order the given vertices should be
--   connected. The intention is that the second argument of type
--   <tt>[Point v]</tt> could be generated by a call to <a>polygon</a>,
--   <tt>regPoly</tt>, or the like, since a list of vertices is
--   <a>TrailLike</a>. But of course the list can be generated any way you
--   like. A <tt><a>Path</a> <tt>v</tt></tt> is returned (instead of any
--   <a>TrailLike</a>) because the resulting path may have more than one
--   component, for example if the vertices are to be connected in several
--   disjoint cycles.
star :: OrderedField n => StarOpts -> [Point V2 n] -> Path V2 n

-- | Pieces of a function graph can either be cycles or "hairs".
data GraphPart a
Cycle :: [a] -> GraphPart a
Hair :: [a] -> GraphPart a

-- | <tt>orbits f n</tt> computes the graph of <tt>f</tt> on the integers
--   mod <tt>n</tt>.
orbits :: (Int -> Int) -> Int -> [GraphPart Int]

-- | Generate a function graph from the given function and labels.
mkGraph :: (Int -> Int) -> [a] -> [GraphPart a]
instance GHC.Internal.Num.Num n => Data.Default.Internal.Default (Diagrams.TwoD.Polygons.PolygonOpts n)
instance GHC.Classes.Eq n => GHC.Classes.Eq (Diagrams.TwoD.Polygons.PolyOrientation n)
instance GHC.Internal.Base.Functor Diagrams.TwoD.Polygons.GraphPart
instance GHC.Classes.Ord n => GHC.Classes.Ord (Diagrams.TwoD.Polygons.PolyOrientation n)
instance GHC.Internal.Read.Read n => GHC.Internal.Read.Read (Diagrams.TwoD.Polygons.PolyOrientation n)
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Diagrams.TwoD.Polygons.GraphPart a)
instance GHC.Internal.Show.Show n => GHC.Internal.Show.Show (Diagrams.TwoD.Polygons.PolyOrientation n)


-- | Various two-dimensional shapes.
module Diagrams.TwoD.Shapes

-- | Create a centered horizontal (L-R) line of the given length.
--   
--   
--   <pre>
--   hruleEx = vcat' (with &amp; sep .~ 0.2) (map hrule [1..5])
--           # centerXY # pad 1.1
--   </pre>
hrule :: (InSpace V2 n t, TrailLike t) => n -> t

-- | Create a centered vertical (T-B) line of the given length.
--   
--   
--   <pre>
--   vruleEx = hcat' (with &amp; sep .~ 0.2) (map vrule [1, 1.2 .. 2])
--           # centerXY # pad 1.1
--   </pre>
vrule :: (InSpace V2 n t, TrailLike t) => n -> t

-- | Create a regular polygon. The first argument is the number of sides,
--   and the second is the <i>length</i> of the sides. (Compare to the
--   <a>polygon</a> function with a <a>PolyRegular</a> option, which
--   produces polygons of a given <i>radius</i>).
--   
--   The polygon will be oriented with one edge parallel to the x-axis.
regPoly :: (InSpace V2 n t, TrailLike t) => Int -> n -> t

-- | An equilateral triangle, with sides of the given length and base
--   parallel to the x-axis.
--   
triangle :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A synonym for <a>triangle</a>, provided for backwards compatibility.
eqTriangle :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A square with its center at the origin and sides of the given length,
--   oriented parallel to the axes.
--   
square :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A regular pentagon, with sides of the given length and base parallel
--   to the x-axis.
--   
pentagon :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A regular hexagon, with sides of the given length and base parallel to
--   the x-axis.
--   
hexagon :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A regular heptagon, with sides of the given length and base parallel
--   to the x-axis.
--   
heptagon :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A synonym for <a>heptagon</a>. It is, however, completely inferior,
--   being a base admixture of the Latin <i>septum</i> (seven) and the
--   Greek γωνία (angle).
septagon :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A regular octagon, with sides of the given length and base parallel to
--   the x-axis.
--   
octagon :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A regular nonagon, with sides of the given length and base parallel to
--   the x-axis.
--   
nonagon :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A regular decagon, with sides of the given length and base parallel to
--   the x-axis.
--   
decagon :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A regular hendecagon, with sides of the given length and base parallel
--   to the x-axis.
--   
hendecagon :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A regular dodecagon, with sides of the given length and base parallel
--   to the x-axis.
--   
dodecagon :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A square with its center at the origin and sides of length 1, oriented
--   parallel to the axes.
--   
unitSquare :: (InSpace V2 n t, TrailLike t) => t

-- | <tt>rect w h</tt> is an axis-aligned rectangle of width <tt>w</tt> and
--   height <tt>h</tt>, centered at the origin.
--   
rect :: (InSpace V2 n t, TrailLike t) => n -> n -> t

-- | <tt>roundedRect w h r</tt> generates a closed trail, or closed path
--   centered at the origin, of an axis-aligned rectangle with width
--   <tt>w</tt>, height <tt>h</tt>, and circular rounded corners of radius
--   <tt>r</tt>. If <tt>r</tt> is negative the corner will be cut out in a
--   reverse arc. If the size of <tt>r</tt> is larger than half the smaller
--   dimension of <tt>w</tt> and <tt>h</tt>, then it will be reduced to fit
--   in that range, to prevent the corners from overlapping. The trail or
--   path begins with the right edge and proceeds counterclockwise. If you
--   need to specify a different radius for each corner individually, use
--   <a>roundedRect'</a> instead.
--   
--   
--   <pre>
--   roundedRectEx = pad 1.1 . centerXY $ hcat' (with &amp; sep .~ 0.2)
--     [ roundedRect  0.5 0.4 0.1
--     , roundedRect  0.5 0.4 (-0.1)
--     , roundedRect' 0.7 0.4 (with &amp; radiusTL .~ 0.2
--                                  &amp; radiusTR .~ -0.2
--                                  &amp; radiusBR .~ 0.1)
--     ]
--   </pre>
roundedRect :: (InSpace V2 n t, TrailLike t, RealFloat n) => n -> n -> n -> t
data RoundedRectOpts d
RoundedRectOpts :: d -> d -> d -> d -> RoundedRectOpts d
[_radiusTL] :: RoundedRectOpts d -> d
[_radiusTR] :: RoundedRectOpts d -> d
[_radiusBL] :: RoundedRectOpts d -> d
[_radiusBR] :: RoundedRectOpts d -> d
radiusTL :: forall d f. Functor f => (d -> f d) -> RoundedRectOpts d -> f (RoundedRectOpts d)
radiusTR :: forall d f. Functor f => (d -> f d) -> RoundedRectOpts d -> f (RoundedRectOpts d)
radiusBL :: forall d f. Functor f => (d -> f d) -> RoundedRectOpts d -> f (RoundedRectOpts d)
radiusBR :: forall d f. Functor f => (d -> f d) -> RoundedRectOpts d -> f (RoundedRectOpts d)

-- | <tt>roundedRect'</tt> works like <tt>roundedRect</tt> but allows you
--   to set the radius of each corner indivually, using
--   <tt>RoundedRectOpts</tt>. The default corner radius is 0. Each radius
--   can also be negative, which results in the curves being reversed to be
--   inward instead of outward.
roundedRect' :: (InSpace V2 n t, TrailLike t, RealFloat n) => n -> n -> RoundedRectOpts n -> t
instance GHC.Internal.Num.Num d => Data.Default.Internal.Default (Diagrams.TwoD.Shapes.RoundedRectOpts d)


-- | Paths in two dimensions are special since we may stroke them to create
--   a 2D diagram, and (eventually) perform operations such as intersection
--   and union. They also have a trace, whereas paths in higher dimensions
--   do not.
module Diagrams.TwoD.Path

-- | Convert a <a>ToPath</a> object into a diagram. The resulting diagram
--   has the names 0, 1, ... assigned to each of the path's vertices.
--   
--   See also <a>stroke'</a>, which takes an extra options record allowing
--   its behaviour to be customized.
--   
--   <pre>
--   <a>stroke</a> :: <a>Path</a> <a>V2</a> <a>Double</a>                  -&gt; <a>Diagram</a> b
--   <a>stroke</a> :: <a>Located</a> (<a>Trail</a> <a>V2</a> <a>Double</a>)       -&gt; <a>Diagram</a> b
--   <a>stroke</a> :: <a>Located</a> (<a>Trail'</a> <a>Loop</a> <a>V2</a> <a>Double</a>) -&gt; <a>Diagram</a> b
--   <a>stroke</a> :: <a>Located</a> (<a>Trail'</a> <a>Line</a> <a>V2</a> <a>Double</a>) -&gt; <a>Diagram</a> b
--   </pre>
stroke :: (InSpace V2 n t, ToPath t, TypeableFloat n, Renderable (Path V2 n) b) => t -> QDiagram b V2 n Any

-- | A variant of <a>stroke</a> that takes an extra record of options to
--   customize its behaviour. In particular:
--   
--   <ul>
--   <li>Names can be assigned to the path's vertices</li>
--   </ul>
--   
--   <a>StrokeOpts</a> is an instance of <a>Default</a>, so <tt>stroke'
--   (<tt>with</tt> &amp; ... )</tt> syntax may be used.
stroke' :: (InSpace V2 n t, ToPath t, TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> t -> QDiagram b V2 n Any

-- | <a>stroke</a> specialised to <a>Path</a>.
strokePath :: (TypeableFloat n, Renderable (Path V2 n) b) => Path V2 n -> QDiagram b V2 n Any

-- | <a>stroke</a> specialised to <a>Path</a>.
strokeP :: (TypeableFloat n, Renderable (Path V2 n) b) => Path V2 n -> QDiagram b V2 n Any

-- | <a>stroke'</a> specialised to <a>Path</a>.
strokePath' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Path V2 n -> QDiagram b V2 n Any

-- | <a>stroke'</a> specialised to <a>Path</a>.
strokeP' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Path V2 n -> QDiagram b V2 n Any

-- | <a>stroke</a> specialised to <a>Trail</a>.
strokeTrail :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail V2 n -> QDiagram b V2 n Any

-- | <a>stroke</a> specialised to <a>Trail</a>.
strokeT :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail V2 n -> QDiagram b V2 n Any

-- | A composition of <a>stroke'</a> and <a>pathFromTrail</a> for
--   conveniently converting a trail directly into a diagram.
strokeTrail' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Trail V2 n -> QDiagram b V2 n Any

-- | Deprecated synonym for <a>strokeTrail'</a>.
strokeT' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Trail V2 n -> QDiagram b V2 n Any

-- | A composition of <a>strokeT</a> and <a>wrapLine</a> for conveniently
--   converting a line directly into a diagram.
strokeLine :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail' Line V2 n -> QDiagram b V2 n Any

-- | A composition of <a>strokeT</a> and <a>wrapLoop</a> for conveniently
--   converting a loop directly into a diagram.
strokeLoop :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail' Loop V2 n -> QDiagram b V2 n Any

-- | A convenience function for converting a <tt>Located Trail</tt>
--   directly into a diagram; <tt>strokeLocTrail = stroke . trailLike</tt>.
strokeLocTrail :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail V2 n) -> QDiagram b V2 n Any

-- | Deprecated synonym for <a>strokeLocTrail</a>.
strokeLocT :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail V2 n) -> QDiagram b V2 n Any

-- | A convenience function for converting a <tt>Located</tt> line directly
--   into a diagram; <tt>strokeLocLine = stroke . trailLike . mapLoc
--   wrapLine</tt>.
strokeLocLine :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail' Line V2 n) -> QDiagram b V2 n Any

-- | A convenience function for converting a <tt>Located</tt> loop directly
--   into a diagram; <tt>strokeLocLoop = stroke . trailLike . mapLoc
--   wrapLoop</tt>.
strokeLocLoop :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail' Loop V2 n) -> QDiagram b V2 n Any

-- | Enumeration of algorithms or "rules" for determining which points lie
--   in the interior of a (possibly self-intersecting) path.
data FillRule

-- | Interior points are those with a nonzero <i>winding</i> <i>number</i>.
--   See <a>http://en.wikipedia.org/wiki/Nonzero-rule</a>.
Winding :: FillRule

-- | Interior points are those where a ray extended infinitely in a
--   particular direction crosses the path an odd number of times. See
--   <a>http://en.wikipedia.org/wiki/Even-odd_rule</a>.
EvenOdd :: FillRule

-- | Extract the fill rule from a <tt>FillRuleA</tt> attribute.
getFillRule :: FillRule -> FillRule

-- | Specify the fill rule that should be used for determining which points
--   are inside a path.
fillRule :: HasStyle a => FillRule -> a -> a

-- | Lens onto the fill rule of a style.
_fillRule :: forall n f. Functor f => (FillRule -> f FillRule) -> Style V2 n -> f (Style V2 n)

-- | A record of options that control how a path is stroked.
--   <tt>StrokeOpts</tt> is an instance of <a>Default</a>, so a
--   <tt>StrokeOpts</tt> records can be created using <tt><tt>with</tt> {
--   ... }</tt> notation.
data StrokeOpts a
StrokeOpts :: [[a]] -> FillRule -> StrokeOpts a
[_vertexNames] :: StrokeOpts a -> [[a]]
[_queryFillRule] :: StrokeOpts a -> FillRule

-- | Atomic names that should be assigned to the vertices of the path so
--   that they can be referenced later. If there are not enough names, the
--   extra vertices are not assigned names; if there are too many, the
--   extra names are ignored. Note that this is a <i>list of lists</i> of
--   names, since paths can consist of multiple trails. The first list of
--   names are assigned to the vertices of the first trail, the second list
--   to the second trail, and so on.
--   
--   The default value is the empty list.
vertexNames :: forall a a' f. Functor f => ([[a]] -> f [[a']]) -> StrokeOpts a -> f (StrokeOpts a')

-- | The fill rule used for determining which points are inside the path.
--   The default is <a>Winding</a>. NOTE: for now, this only affects the
--   resulting diagram's <a>Query</a>, <i>not</i> how it will be drawn! To
--   set the fill rule determining how it is to be drawn, use the
--   <a>fillRule</a> function.
queryFillRule :: forall a f. Functor f => (FillRule -> f FillRule) -> StrokeOpts a -> f (StrokeOpts a)

-- | The sum of <i>signed</i> crossings of a path as we travel in the
--   positive x direction from a given point.
--   
--   <ul>
--   <li>A point is filled according to the <a>Winding</a> fill rule, if
--   the number of <a>Crossings</a> is non-zero (see
--   <a>isInsideWinding</a>).</li>
--   <li>A point is filled according to the <a>EvenOdd</a> fill rule, if
--   the number of <a>Crossings</a> is odd (see
--   <a>isInsideEvenOdd</a>).</li>
--   </ul>
--   
--   This is the <a>HasQuery</a> result for <a>Path</a>s, <a>Located</a>
--   <a>Trail</a>s and <a>Located</a> <tt>Loops</tt>.
--   
--   <pre>
--   <a>sample</a> :: <a>Path</a> <a>V2</a> <a>Double</a>                  -&gt; <a>Point</a> <a>V2</a> <a>Double</a> -&gt; <a>Crossings</a>
--   <a>sample</a> :: <a>Located</a> (<a>Trail</a> <a>V2</a> <a>Double</a>)       -&gt; <a>Point</a> <a>V2</a> <a>Double</a> -&gt; <a>Crossings</a>
--   <a>sample</a> :: <a>Located</a> (<a>Trail'</a> <a>Loop</a> <a>V2</a> <a>Double</a>) -&gt; <a>Point</a> <a>V2</a> <a>Double</a> -&gt; <a>Crossings</a>
--   </pre>
--   
--   Note that <a>Line</a>s have no inside or outside, so don't contribute
--   crossings
newtype Crossings
Crossings :: Int -> Crossings

-- | Test whether the given point is inside the given path, by testing
--   whether the point's <i>winding number</i> is nonzero. Note that
--   <tt>False</tt> is <i>always</i> returned for paths consisting of lines
--   (as opposed to loops), regardless of the winding number.
--   
--   <pre>
--   <a>isInsideWinding</a> :: <a>Path</a> <a>V2</a> <a>Double</a>                  -&gt; <a>Point</a> <a>V2</a> <a>Double</a> -&gt; <a>Bool</a>
--   <a>isInsideWinding</a> :: <a>Located</a> (<a>Trail</a> <a>V2</a> <a>Double</a>)       -&gt; <a>Point</a> <a>V2</a> <a>Double</a> -&gt; <a>Bool</a>
--   <a>isInsideWinding</a> :: <a>Located</a> (<a>Trail'</a> <a>Loop</a> <a>V2</a> <a>Double</a>) -&gt; <a>Point</a> <a>V2</a> <a>Double</a> -&gt; <a>Bool</a>
--   </pre>
isInsideWinding :: HasQuery t Crossings => t -> Point (V t) (N t) -> Bool

-- | Test whether the given point is inside the given path, by testing
--   whether a ray extending from the point in the positive x direction
--   crosses the path an even (outside) or odd (inside) number of times.
--   Note that <tt>False</tt> is <i>always</i> returned for paths
--   consisting of lines (as opposed to loops), regardless of the number of
--   crossings.
--   
--   <pre>
--   <a>isInsideEvenOdd</a> :: <a>Path</a> <a>V2</a> <a>Double</a>                  -&gt; <a>Point</a> <a>V2</a> <a>Double</a> -&gt; <a>Bool</a>
--   <a>isInsideEvenOdd</a> :: <a>Located</a> (<a>Trail</a> <a>V2</a> <a>Double</a>)       -&gt; <a>Point</a> <a>V2</a> <a>Double</a> -&gt; <a>Bool</a>
--   <a>isInsideEvenOdd</a> :: <a>Located</a> (<a>Trail'</a> <a>Loop</a> <a>V2</a> <a>Double</a>) -&gt; <a>Point</a> <a>V2</a> <a>Double</a> -&gt; <a>Bool</a>
--   </pre>
isInsideEvenOdd :: HasQuery t Crossings => t -> Point (V t) (N t) -> Bool

-- | <tt>Clip</tt> tracks the accumulated clipping paths applied to a
--   diagram. Note that the semigroup structure on <tt>Clip</tt> is list
--   concatenation, so applying multiple clipping paths is sensible. The
--   clipping region is the intersection of all the applied clipping paths.
newtype Clip n
Clip :: [Path V2 n] -> Clip n
_Clip :: forall n n' p f. (Profunctor p, Functor f) => p [Path V2 n] (f [Path V2 n']) -> p (Clip n) (f (Clip n'))

-- | Lens onto the Clip in a style. An empty list means no clipping.
_clip :: (Typeable n, OrderedField n) => Lens' (Style V2 n) [Path V2 n]

-- | Clip a diagram by the given path:
--   
--   <ul>
--   <li>Only the parts of the diagram which lie in the interior of the
--   path will be drawn.</li>
--   <li>The envelope of the diagram is unaffected.</li>
--   </ul>
clipBy :: (HasStyle a, V a ~ V2, N a ~ n, TypeableFloat n) => Path V2 n -> a -> a

-- | Clip a diagram to the given path setting its envelope to the pointwise
--   minimum of the envelopes of the diagram and path. The trace consists
--   of those parts of the original diagram's trace which fall within the
--   clipping path, or parts of the path's trace within the original
--   diagram.
clipTo :: TypeableFloat n => Path V2 n -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Clip a diagram to the clip path taking the envelope and trace of the
--   clip path.
clipped :: TypeableFloat n => Path V2 n -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Find the intersect points of two objects that can be converted to a
--   path.
intersectPoints :: (InSpace V2 n t, SameSpace t s, ToPath t, ToPath s, OrderedField n) => t -> s -> [P2 n]

-- | Find the intersect points of two objects that can be converted to a
--   path within the given tolerance.
intersectPoints' :: (InSpace V2 n t, SameSpace t s, ToPath t, ToPath s, OrderedField n) => n -> t -> s -> [P2 n]

-- | Compute the intersect points between two paths.
intersectPointsP :: OrderedField n => Path V2 n -> Path V2 n -> [P2 n]

-- | Compute the intersect points between two paths within given tolerance.
intersectPointsP' :: OrderedField n => n -> Path V2 n -> Path V2 n -> [P2 n]

-- | Compute the intersect points between two located trails.
intersectPointsT :: OrderedField n => Located (Trail V2 n) -> Located (Trail V2 n) -> [P2 n]

-- | Compute the intersect points between two located trails within the
--   given tolerance.
intersectPointsT' :: OrderedField n => n -> Located (Trail V2 n) -> Located (Trail V2 n) -> [P2 n]
instance Control.Lens.Empty.AsEmpty (Diagrams.TwoD.Path.Clip n)
instance GHC.Internal.Data.Typeable.Internal.Typeable n => Diagrams.Core.Style.AttributeClass (Diagrams.TwoD.Path.Clip n)
instance Diagrams.Core.Style.AttributeClass Diagrams.TwoD.Path.FillRule
instance Data.Default.Internal.Default Diagrams.TwoD.Path.FillRule
instance Data.Default.Internal.Default (Diagrams.TwoD.Path.StrokeOpts a)
instance GHC.Internal.Enum.Enum Diagrams.TwoD.Path.Crossings
instance GHC.Classes.Eq Diagrams.TwoD.Path.Crossings
instance GHC.Classes.Eq Diagrams.TwoD.Path.FillRule
instance GHC.Internal.Float.RealFloat n => Diagrams.Query.HasQuery (Diagrams.TwoD.Path.Clip n) GHC.Internal.Data.Semigroup.Internal.All
instance GHC.Internal.Float.RealFloat n => Diagrams.Query.HasQuery (Diagrams.Located.Located (Diagrams.Trail.Trail Linear.V2.V2 n)) Diagrams.TwoD.Path.Crossings
instance GHC.Internal.Float.RealFloat n => Diagrams.Query.HasQuery (Diagrams.Located.Located (Diagrams.Trail.Trail' l Linear.V2.V2 n)) Diagrams.TwoD.Path.Crossings
instance GHC.Internal.Float.RealFloat n => Diagrams.Query.HasQuery (Diagrams.Path.Path Linear.V2.V2 n) Diagrams.TwoD.Path.Crossings
instance GHC.Internal.Real.Integral Diagrams.TwoD.Path.Crossings
instance GHC.Internal.Base.Monoid Diagrams.TwoD.Path.Crossings
instance GHC.Internal.Num.Num Diagrams.TwoD.Path.Crossings
instance GHC.Classes.Ord Diagrams.TwoD.Path.Crossings
instance GHC.Classes.Ord Diagrams.TwoD.Path.FillRule
instance GHC.Internal.Real.Real Diagrams.TwoD.Path.Crossings
instance (Diagrams.TwoD.Path.Clip n1 GHC.Types.~ t) => Control.Lens.Wrapped.Rewrapped (Diagrams.TwoD.Path.Clip n2) t
instance GHC.Internal.Base.Semigroup (Diagrams.TwoD.Path.Clip n)
instance GHC.Internal.Base.Semigroup Diagrams.TwoD.Path.Crossings
instance GHC.Internal.Base.Semigroup Diagrams.TwoD.Path.FillRule
instance GHC.Internal.Show.Show Diagrams.TwoD.Path.Crossings
instance GHC.Internal.Show.Show Diagrams.TwoD.Path.FillRule
instance GHC.Internal.Float.RealFloat n => Diagrams.Core.Trace.Traced (Diagrams.Path.Path Linear.V2.V2 n)
instance GHC.Internal.Float.RealFloat n => Diagrams.Core.Trace.Traced (Diagrams.Trail.Trail Linear.V2.V2 n)
instance (Diagrams.Core.Types.TypeableFloat n, Diagrams.Core.Types.Renderable (Diagrams.Path.Path Linear.V2.V2 n) b) => Diagrams.TrailLike.TrailLike (Diagrams.Core.Types.QDiagram b Linear.V2.V2 n GHC.Internal.Data.Semigroup.Internal.Any)
instance Diagrams.Core.Envelope.OrderedField n => Diagrams.Core.Transform.Transformable (Diagrams.TwoD.Path.Clip n)
instance Control.Lens.Wrapped.Wrapped (Diagrams.TwoD.Path.Clip n)


-- | Compute offsets to segments in two dimensions. More details can be
--   found in the manual at
--   <a>https://diagrams.github.io/doc/manual.html#offsets-of-segments-trails-and-paths</a>.
module Diagrams.TwoD.Offset
offsetSegment :: RealFloat n => n -> n -> Segment Closed V2 n -> Located (Trail V2 n)

-- | Compute the offset of a segment. Given a segment compute the offset
--   curve that is a fixed distance from the original curve. For linear
--   segments nothing special happens, the same linear segment is returned
--   with a point that is offset by a perpendicular vector of the given
--   offset length.
--   
--   Cubic segments require a search for a subdivision of cubic segments
--   that gives an approximation of the offset within the given epsilon
--   factor (the given epsilon factor is applied to the radius giving a
--   concrete epsilon value). We must do this because the offset of a cubic
--   is not a cubic itself (the degree of the curve increases). Cubics do,
--   however, approach constant curvature as we subdivide. In light of this
--   we scale the handles of the offset cubic segment in proportion to the
--   radius of curvature difference between the original subsegment and the
--   offset which will have a radius increased by the offset parameter.
--   
--   In the following example the blue lines are the original segments and
--   the alternating green and red lines are the resulting offset trail
--   segments.
--   
--   
--   Note that when the original curve has a cusp, the offset curve forms a
--   radius around the cusp, and when there is a loop in the original
--   curve, there can be two cusps in the offset curve.
--   
--   Options for specifying line join and segment epsilon for an offset
--   involving multiple segments.
data OffsetOpts d
OffsetOpts :: LineJoin -> d -> d -> OffsetOpts d
[_offsetJoin] :: OffsetOpts d -> LineJoin
[_offsetMiterLimit] :: OffsetOpts d -> d
[_offsetEpsilon] :: OffsetOpts d -> d

-- | Specifies the style of join for between adjacent offset segments.
offsetJoin :: forall d f. Functor f => (LineJoin -> f LineJoin) -> OffsetOpts d -> f (OffsetOpts d)

-- | Specifies the miter limit for the join.
offsetMiterLimit :: forall d f. Functor f => (d -> f d) -> OffsetOpts d -> f (OffsetOpts d)

-- | Epsilon perimeter for <tt>offsetSegment</tt>.
offsetEpsilon :: forall d f. Functor f => (d -> f d) -> OffsetOpts d -> f (OffsetOpts d)

-- | Offset a <a>Trail</a> with the default options and a given radius. See
--   <a>offsetTrail'</a>.
offsetTrail :: RealFloat n => n -> Located (Trail V2 n) -> Located (Trail V2 n)

-- | Offset a <a>Trail</a> with options and by a given radius. This
--   generates a new trail that is always radius <tt>r</tt> away from the
--   given <a>Trail</a> (depending on the line join option) on the right.
--   
--   The styles applied to an outside corner can be seen here (with the
--   original trail in blue and the result of <a>offsetTrail'</a> in
--   green):
--   
--   
--   When a negative radius is given, the offset trail will be on the left:
--   
--   
--   When offseting a counter-clockwise loop a positive radius gives an
--   outer loop while a negative radius gives an inner loop (both
--   counter-clockwise).
--   
offsetTrail' :: RealFloat n => OffsetOpts n -> n -> Located (Trail V2 n) -> Located (Trail V2 n)

-- | Offset a <a>Path</a> with the default options and given radius. See
--   <a>offsetPath'</a>.
offsetPath :: RealFloat n => n -> Path V2 n -> Path V2 n

-- | Offset a <a>Path</a> by applying <a>offsetTrail'</a> to each trail in
--   the path.
offsetPath' :: RealFloat n => OffsetOpts n -> n -> Path V2 n -> Path V2 n

-- | Options for specifying how a <a>Trail</a> should be expanded.
data ExpandOpts d
ExpandOpts :: LineJoin -> d -> LineCap -> d -> ExpandOpts d
[_expandJoin] :: ExpandOpts d -> LineJoin
[_expandMiterLimit] :: ExpandOpts d -> d
[_expandCap] :: ExpandOpts d -> LineCap
[_expandEpsilon] :: ExpandOpts d -> d

-- | Specifies the style of join for between adjacent offset segments.
expandJoin :: forall d f. Functor f => (LineJoin -> f LineJoin) -> ExpandOpts d -> f (ExpandOpts d)

-- | Specifies the miter limit for the join.
expandMiterLimit :: forall d f. Functor f => (d -> f d) -> ExpandOpts d -> f (ExpandOpts d)

-- | Specifies how the ends are handled.
expandCap :: forall d f. Functor f => (LineCap -> f LineCap) -> ExpandOpts d -> f (ExpandOpts d)

-- | Epsilon perimeter for <a>offsetSegment</a>.
expandEpsilon :: forall d f. Functor f => (d -> f d) -> ExpandOpts d -> f (ExpandOpts d)

-- | Expand a <a>Trail</a> with the given radius and default options. See
--   <a>expandTrail'</a>.
expandTrail :: RealFloat n => n -> Located (Trail V2 n) -> Path V2 n

-- | Expand a <a>Trail</a> with the given options and radius <tt>r</tt>
--   around a given <a>Trail</a>. Expanding can be thought of as generating
--   the loop that, when filled, represents stroking the trail with a
--   radius <tt>r</tt> brush.
--   
--   The cap styles applied to an outside corner can be seen here (with the
--   original trail in white and the result of <a>expandTrail'</a> filled
--   in green):
--   
--   
--   Loops result in a path with an inner and outer loop:
--   
expandTrail' :: (OrderedField n, RealFloat n, RealFrac n) => ExpandOpts n -> n -> Located (Trail V2 n) -> Path V2 n

-- | Expand a <a>Path</a> with the given radius and default options. See
--   <a>expandPath'</a>.
expandPath :: RealFloat n => n -> Path V2 n -> Path V2 n

-- | Expand a <a>Path</a> using <a>expandTrail'</a> on each trail in the
--   path.
expandPath' :: RealFloat n => ExpandOpts n -> n -> Path V2 n -> Path V2 n
instance GHC.Internal.Real.Fractional d => Data.Default.Internal.Default (Diagrams.TwoD.Offset.ExpandOpts d)
instance GHC.Internal.Real.Fractional d => Data.Default.Internal.Default (Diagrams.TwoD.Offset.OffsetOpts d)
instance GHC.Classes.Eq d => GHC.Classes.Eq (Diagrams.TwoD.Offset.ExpandOpts d)
instance GHC.Classes.Eq d => GHC.Classes.Eq (Diagrams.TwoD.Offset.OffsetOpts d)
instance GHC.Internal.Show.Show d => GHC.Internal.Show.Show (Diagrams.TwoD.Offset.ExpandOpts d)
instance GHC.Internal.Show.Show d => GHC.Internal.Show.Show (Diagrams.TwoD.Offset.OffsetOpts d)


-- | Importing external images into diagrams. Usage example: To create a
--   diagram from an embedded image with width 1 and height set according
--   to the aspect ratio, use <tt>image img # scaleUToX 1</tt>, where
--   <tt>img</tt> is a value of type <tt>DImage n e</tt>, created with a
--   function like <a>loadImageEmb</a>, <a>loadImageExt</a>, or
--   <a>raster</a>.
module Diagrams.TwoD.Image

-- | An image primitive, the two ints are width followed by height. Will
--   typically be created by <tt>loadImageEmb</tt> or <tt>loadImageExt</tt>
--   which, will handle setting the width and height to the actual width
--   and height of the image.
data DImage a b
[DImage] :: forall b a. ImageData b -> Int -> Int -> Transformation V2 a -> DImage a b

-- | <a>ImageData</a> is either a JuicyPixels <tt>DynamicImage</tt> tagged
--   as <a>Embedded</a> or a reference tagged as <a>External</a>.
--   Additionally <a>Native</a> is provided for external libraries to hook
--   into.
data ImageData a
[ImageRaster] :: DynamicImage -> ImageData Embedded
[ImageRef] :: FilePath -> ImageData External
[ImageNative] :: forall t. t -> ImageData (Native t)
data Embedded
data External
data Native t

-- | Make a <a>DImage</a> into a <a>Diagram</a>.
image :: (TypeableFloat n, Typeable a, Renderable (DImage n a) b) => DImage n a -> QDiagram b V2 n Any

-- | Read a JuicyPixels <tt>DynamicImage</tt> and wrap it in a
--   <a>DImage</a>. The width and height of the image are set to their
--   actual values.
embeddedImage :: Num n => DynamicImage -> DImage n Embedded

-- | Use JuicyPixels to read a file in any format and wrap it in a
--   <a>DImage</a>. The width and height of the image are set to their
--   actual values.
loadImageEmb :: Num n => FilePath -> IO (Either String (DImage n Embedded))

-- | A pure variant of <a>loadImageEmb</a>
loadImageEmbBS :: Num n => ByteString -> Either String (DImage n Embedded)

-- | Check that a file exists, and use JuicyPixels to figure out the right
--   size, but save a reference to the image instead of the raster data
loadImageExt :: Num n => FilePath -> IO (Either String (DImage n External))

-- | Make an "unchecked" image reference; have to specify a width and
--   height. Unless the aspect ratio of the external image is the w :: h,
--   then the image will be distorted.
uncheckedImageRef :: Num n => FilePath -> Int -> Int -> DImage n External

-- | Create an image "from scratch" by specifying the pixel data
raster :: Num n => (Int -> Int -> AlphaColour Double) -> Int -> Int -> DImage n Embedded

-- | Crate a diagram from raw raster data.
rasterDia :: (TypeableFloat n, Renderable (DImage n Embedded) b) => (Int -> Int -> AlphaColour Double) -> Int -> Int -> QDiagram b V2 n Any
instance GHC.Internal.Real.Fractional n => Diagrams.Core.HasOrigin.HasOrigin (Diagrams.TwoD.Image.DImage n a)
instance GHC.Internal.Float.RealFloat n => Diagrams.Query.HasQuery (Diagrams.TwoD.Image.DImage n a) GHC.Internal.Data.Semigroup.Internal.Any
instance GHC.Internal.Real.Fractional n => Diagrams.Core.Types.Renderable (Diagrams.TwoD.Image.DImage n a) Diagrams.Core.Types.NullBackend
instance GHC.Internal.Real.Fractional n => Diagrams.Core.Transform.Transformable (Diagrams.TwoD.Image.DImage n a)


-- | Diagrams may have <i>attributes</i> which affect the way they are
--   rendered. This module defines <i>Textures</i> (Gradients and Colors)
--   in two dimensions. Like the attributes defined in the
--   Diagrams.Attributes module, all attributes defined here use the
--   <a>Last</a> or <a>Recommend</a> <i>semigroup</i> structure.
--   <tt>FillColor</tt> and <tt>LineColor</tt> attributes are provided so
--   that backends that don't support gradients need not be concerned with
--   using textures. Backends should only implement color attributes or
--   textures attributes, not both.
module Diagrams.TwoD.Attributes

-- | A Texture is either a color <a>SC</a>, linear gradient <a>LG</a>, or
--   radial gradient <a>RG</a>. An object can have only one texture which
--   is determined by the <a>Last</a> semigroup structure.
data Texture n
SC :: SomeColor -> Texture n
LG :: LGradient n -> Texture n
RG :: RGradient n -> Texture n

-- | Convert a solid colour into a texture.
solid :: Color a => a -> Texture n
_SC :: forall n p f. (Choice p, Applicative f) => p SomeColor (f SomeColor) -> p (Texture n) (f (Texture n))

-- | Prism onto an <a>AlphaColour</a> <a>Double</a> of a <a>SC</a> texture.
_AC :: forall n p f. (Choice p, Applicative f) => p (AlphaColour Double) (f (AlphaColour Double)) -> p (Texture n) (f (Texture n))
_LG :: forall n p f. (Choice p, Applicative f) => p (LGradient n) (f (LGradient n)) -> p (Texture n) (f (Texture n))
_RG :: forall n p f. (Choice p, Applicative f) => p (RGradient n) (f (RGradient n)) -> p (Texture n) (f (Texture n))

-- | A default is provided so that linear gradients can easily be created
--   using lenses. For example, <tt>lg = defaultLG &amp; lGradStart .~
--   (0.25 ^&amp; 0.33)</tt>. Note that no default value is provided for
--   <tt>lGradStops</tt>, this must be set before the gradient value is
--   used, otherwise the object will appear transparent.
defaultLG :: Fractional n => Texture n

-- | A default is provided so that radial gradients can easily be created
--   using lenses. For example, <tt>rg = defaultRG &amp; rGradRadius1 .~
--   0.25</tt>. Note that no default value is provided for
--   <tt>rGradStops</tt>, this must be set before the gradient value is
--   used, otherwise the object will appear transparent.
defaultRG :: Fractional n => Texture n

-- | A gradient stop contains a color and fraction (usually between 0 and
--   1)
data GradientStop d
GradientStop :: SomeColor -> d -> GradientStop d
[_stopColor] :: GradientStop d -> SomeColor
[_stopFraction] :: GradientStop d -> d

-- | A color for the stop.
stopColor :: forall n f. Functor f => (SomeColor -> f SomeColor) -> GradientStop n -> f (GradientStop n)

-- | The fraction for stop.
stopFraction :: forall n f. Functor f => (n -> f n) -> GradientStop n -> f (GradientStop n)

-- | A convenient function for making gradient stops from a list of
--   triples. (An opaque color, a stop fraction, an opacity).
mkStops :: [(Colour Double, d, Double)] -> [GradientStop d]

-- | The <a>SpreadMethod</a> determines what happens before
--   <tt>lGradStart</tt> and after <tt>lGradEnd</tt>. <a>GradPad</a> fills
--   the space before the start of the gradient with the color of the first
--   stop and the color after end of the gradient with the color of the
--   last stop. <a>GradRepeat</a> restarts the gradient and
--   <a>GradReflect</a> restarts the gradient with the stops in reverse
--   order.
data SpreadMethod
GradPad :: SpreadMethod
GradReflect :: SpreadMethod
GradRepeat :: SpreadMethod

-- | Apply a linear gradient.
lineLGradient :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => LGradient n -> a -> a

-- | Apply a radial gradient.
lineRGradient :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => RGradient n -> a -> a

-- | Linear Gradient
data LGradient n
LGradient :: [GradientStop n] -> Point V2 n -> Point V2 n -> Transformation V2 n -> SpreadMethod -> LGradient n
[_lGradStops] :: LGradient n -> [GradientStop n]
[_lGradStart] :: LGradient n -> Point V2 n
[_lGradEnd] :: LGradient n -> Point V2 n
[_lGradTrans] :: LGradient n -> Transformation V2 n
[_lGradSpreadMethod] :: LGradient n -> SpreadMethod

-- | A list of stops (colors and fractions).
lGradStops :: forall n f. Functor f => ([GradientStop n] -> f [GradientStop n]) -> LGradient n -> f (LGradient n)

-- | A transformation to be applied to the gradient. Usually this field
--   will start as the identity transform and capture the transforms that
--   are applied to the gradient.
lGradTrans :: forall n f. Functor f => (Transformation V2 n -> f (Transformation V2 n)) -> LGradient n -> f (LGradient n)

-- | The starting point for the first gradient stop. The coordinates are in
--   <a>local</a> units and the default is (-0.5, 0).
lGradStart :: forall n f. Functor f => (Point V2 n -> f (Point V2 n)) -> LGradient n -> f (LGradient n)

-- | The ending point for the last gradient stop.The coordinates are in
--   <a>local</a> units and the default is (0.5, 0).
lGradEnd :: forall n f. Functor f => (Point V2 n -> f (Point V2 n)) -> LGradient n -> f (LGradient n)

-- | For setting the spread method.
lGradSpreadMethod :: forall n f. Functor f => (SpreadMethod -> f SpreadMethod) -> LGradient n -> f (LGradient n)

-- | Make a linear gradient texture from a stop list, start point, end
--   point, and <a>SpreadMethod</a>. The <a>lGradTrans</a> field is set to
--   the identity transfrom, to change it use the <a>lGradTrans</a> lens.
mkLinearGradient :: Num n => [GradientStop n] -> Point V2 n -> Point V2 n -> SpreadMethod -> Texture n

-- | Radial Gradient
data RGradient n
RGradient :: [GradientStop n] -> Point V2 n -> n -> Point V2 n -> n -> Transformation V2 n -> SpreadMethod -> RGradient n
[_rGradStops] :: RGradient n -> [GradientStop n]
[_rGradCenter0] :: RGradient n -> Point V2 n
[_rGradRadius0] :: RGradient n -> n
[_rGradCenter1] :: RGradient n -> Point V2 n
[_rGradRadius1] :: RGradient n -> n
[_rGradTrans] :: RGradient n -> Transformation V2 n
[_rGradSpreadMethod] :: RGradient n -> SpreadMethod

-- | A list of stops (colors and fractions).
rGradStops :: forall n f. Functor f => ([GradientStop n] -> f [GradientStop n]) -> RGradient n -> f (RGradient n)

-- | A transformation to be applied to the gradient. Usually this field
--   will start as the identity transform and capture the transforms that
--   are applied to the gradient.
rGradTrans :: forall n f. Functor f => (Transformation V2 n -> f (Transformation V2 n)) -> RGradient n -> f (RGradient n)

-- | The center point of the inner circle.
rGradCenter0 :: forall n f. Functor f => (Point V2 n -> f (Point V2 n)) -> RGradient n -> f (RGradient n)

-- | The radius of the inner cirlce in <a>local</a> coordinates.
rGradRadius0 :: forall n f. Functor f => (n -> f n) -> RGradient n -> f (RGradient n)

-- | The center of the outer circle.
rGradCenter1 :: forall n f. Functor f => (Point V2 n -> f (Point V2 n)) -> RGradient n -> f (RGradient n)

-- | The radius of the outer circle in <a>local</a> coordinates.
rGradRadius1 :: forall n f. Functor f => (n -> f n) -> RGradient n -> f (RGradient n)

-- | For setting the spread method.
rGradSpreadMethod :: forall n f. Functor f => (SpreadMethod -> f SpreadMethod) -> RGradient n -> f (RGradient n)

-- | Make a radial gradient texture from a stop list, radius, start point,
--   end point, and <a>SpreadMethod</a>. The <a>rGradTrans</a> field is set
--   to the identity transfrom, to change it use the <a>rGradTrans</a>
--   lens.
mkRadialGradient :: Num n => [GradientStop n] -> Point V2 n -> n -> Point V2 n -> n -> SpreadMethod -> Texture n

-- | The texture with which lines are drawn. Note that child textures
--   always override parent textures. More precisely, the semigroup
--   structure on line texture attributes is that of <a>Last</a>.
newtype LineTexture n
LineTexture :: Last (Texture n) -> LineTexture n
_LineTexture :: forall n n' p f. (Profunctor p, Functor f) => p (Texture n) (f (Texture n')) -> p (LineTexture n) (f (LineTexture n'))
getLineTexture :: LineTexture n -> Texture n
lineTexture :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => Texture n -> a -> a
lineTextureA :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => LineTexture n -> a -> a
mkLineTexture :: Texture n -> LineTexture n
_lineTexture :: (Floating n, Typeable n) => Lens' (Style V2 n) (Texture n)

-- | Set the line (stroke) color. This function is polymorphic in the color
--   type (so it can be used with either <a>Colour</a> or
--   <a>AlphaColour</a>), but this can sometimes create problems for type
--   inference, so the <a>lc</a> and <a>lcA</a> variants are provided with
--   more concrete types.
lineColor :: (InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) => c -> a -> a

-- | A synonym for <a>lineColor</a>, specialized to <tt><a>Colour</a>
--   Double</tt> (i.e. opaque colors). See comment in <a>lineColor</a>
--   about backends.
lc :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => Colour Double -> a -> a

-- | A synonym for <a>lineColor</a>, specialized to <tt><a>AlphaColour</a>
--   Double</tt> (i.e. colors with transparency). See comment in
--   <a>lineColor</a> about backends.
lcA :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => AlphaColour Double -> a -> a

-- | The texture with which objects are filled. The semigroup structure on
--   fill texture attributes is that of 'Recommed . Last'.
newtype FillTexture n
FillTexture :: Recommend (Last (Texture n)) -> FillTexture n
_FillTexture :: forall n p f. (Profunctor p, Functor f) => p (Recommend (Texture n)) (f (Recommend (Texture n))) -> p (FillTexture n) (f (FillTexture n))
getFillTexture :: FillTexture n -> Texture n
fillTexture :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => Texture n -> a -> a
mkFillTexture :: Texture n -> FillTexture n

-- | Commit a fill texture in a style. This is <i>not</i> a valid setter
--   because it doesn't abide the functor law (see <a>committed</a>).
_fillTexture :: (Typeable n, Floating n) => Lens' (Style V2 n) (Texture n)

-- | Lens onto the <a>Recommend</a> of a fill texture in a style.
_fillTextureR :: (Typeable n, Floating n) => Lens' (Style V2 n) (Recommend (Texture n))

-- | Set the fill color. This function is polymorphic in the color type (so
--   it can be used with either <a>Colour</a> or <a>AlphaColour</a>), but
--   this can sometimes create problems for type inference, so the
--   <a>fc</a> and <a>fcA</a> variants are provided with more concrete
--   types.
fillColor :: (InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) => c -> a -> a

-- | A synonym for <a>fillColor</a>, specialized to <tt><a>Colour</a>
--   Double</tt> (i.e. opaque colors). See comment after <a>fillColor</a>
--   about backends.
fc :: (InSpace V2 n a, Floating n, Typeable n, HasStyle a) => Colour Double -> a -> a

-- | A synonym for <a>fillColor</a>, specialized to <tt><a>AlphaColour</a>
--   Double</tt> (i.e. colors with transparency). See comment after
--   <a>fillColor</a> about backends.
fcA :: (InSpace V2 n a, Floating n, Typeable n, HasStyle a) => AlphaColour Double -> a -> a

-- | Set a "recommended" fill color, to be used only if no explicit calls
--   to <a>fillColor</a> (or <a>fc</a>, or <a>fcA</a>) are used. See
--   comment after <a>fillColor</a> about backends.
recommendFillColor :: (InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) => c -> a -> a

-- | Push fill attributes down until they are at the root of subtrees
--   containing only loops. This makes life much easier for backends, which
--   typically have a semantics where fill attributes are applied to
--   lines<i>non-closed paths as well as loops</i>closed paths, whereas in
--   the semantics of diagrams, fill attributes only apply to loops.
splitTextureFills :: forall b (v :: Type -> Type) n a. Typeable n => RTree b v n a -> RTree b v n a
instance GHC.Internal.Data.Typeable.Internal.Typeable n => Diagrams.Core.Style.AttributeClass (Diagrams.TwoD.Attributes.FillTexture n)
instance GHC.Internal.Data.Typeable.Internal.Typeable n => Diagrams.Core.Style.AttributeClass (Diagrams.TwoD.Attributes.LineTexture n)
instance Data.Default.Internal.Default (Diagrams.TwoD.Attributes.FillTexture n)
instance Data.Default.Internal.Default (Diagrams.TwoD.Attributes.LineTexture n)
instance GHC.Internal.Base.Semigroup (Diagrams.TwoD.Attributes.FillTexture n)
instance GHC.Internal.Base.Semigroup (Diagrams.TwoD.Attributes.LineTexture n)
instance GHC.Internal.Data.Typeable.Internal.Typeable n => Diagrams.Attributes.Compile.SplitAttribute (Diagrams.TwoD.Attributes.FillTextureLoops n)
instance GHC.Internal.Float.Floating n => Diagrams.Core.Transform.Transformable (Diagrams.TwoD.Attributes.FillTexture n)
instance GHC.Internal.Real.Fractional n => Diagrams.Core.Transform.Transformable (Diagrams.TwoD.Attributes.LGradient n)
instance GHC.Internal.Float.Floating n => Diagrams.Core.Transform.Transformable (Diagrams.TwoD.Attributes.LineTexture n)
instance GHC.Internal.Real.Fractional n => Diagrams.Core.Transform.Transformable (Diagrams.TwoD.Attributes.RGradient n)
instance GHC.Internal.Float.Floating n => Diagrams.Core.Transform.Transformable (Diagrams.TwoD.Attributes.Texture n)


-- | Very basic text primitives along with associated attributes.
module Diagrams.TwoD.Text

-- | A <a>Text</a> primitive consists of the string contents, text
--   alignment and the transformation to be applied. The transformation is
--   scale invarient, the average scale of the transform should always be
--   1. All text scaling is obtained from the <a>FontSize</a> attribute.
--   
--   This constructor should not be used directly. Use <a>text</a>,
--   <a>alignedText</a> or <a>baselineText</a>.
data Text n
Text :: T2 n -> TextAlignment n -> String -> Text n

-- | <tt>TextAlignment</tt> specifies the alignment of the text's origin.
data TextAlignment n
BaselineText :: TextAlignment n
BoxAlignedText :: n -> n -> TextAlignment n

-- | Create a primitive text diagram from the given string, with center
--   alignment, equivalent to <tt><a>alignedText</a> 0.5 0.5</tt>.
--   
--   Note that it <i>takes up no space</i>, as text size information is not
--   available.
text :: (TypeableFloat n, Renderable (Text n) b) => String -> QDiagram b V2 n Any

-- | Create a primitive text diagram from the given string, origin at the
--   top left corner of the text's bounding box, equivalent to
--   <tt><a>alignedText</a> 0 1</tt>.
--   
--   Note that it <i>takes up no space</i>.
topLeftText :: (TypeableFloat n, Renderable (Text n) b) => String -> QDiagram b V2 n Any

-- | Create a primitive text diagram from the given string, with the origin
--   set to a point interpolated within the bounding box. The first
--   parameter varies from 0 (left) to 1 (right), and the second parameter
--   from 0 (bottom) to 1 (top). Some backends do not implement this and
--   instead snap to closest corner or the center.
--   
--   The height of this box is determined by the font's potential ascent
--   and descent, rather than the height of the particular string.
--   
--   Note that it <i>takes up no space</i>.
alignedText :: (TypeableFloat n, Renderable (Text n) b) => n -> n -> String -> QDiagram b V2 n Any

-- | Create a primitive text diagram from the given string, with the origin
--   set to be on the baseline, at the beginning (although not bounding).
--   This is the reference point of showText in the Cairo graphics library.
--   
--   Note that it <i>takes up no space</i>.
baselineText :: (TypeableFloat n, Renderable (Text n) b) => String -> QDiagram b V2 n Any

-- | Make a text from a <a>TextAlignment</a>, recommending a fill colour of
--   <a>black</a> and <a>fontSize</a> of <tt><a>local</a> 1</tt>.
mkText :: (TypeableFloat n, Renderable (Text n) b) => TextAlignment n -> String -> QDiagram b V2 n Any

-- | Make a text from a <a>TextAlignment</a> without any default size or
--   fill colour. This is useful is you want to recommend your own using
--   <a>recommendFillColor</a> or <a>recommendFontSize</a>.
mkText' :: (TypeableFloat n, Renderable (Text n) b) => TextAlignment n -> String -> QDiagram b V2 n Any

-- | The <tt>Font</tt> attribute specifies the name of a font family. Inner
--   <tt>Font</tt> attributes override outer ones.
newtype Font
Font :: Last String -> Font
_Font :: Iso' Font String

-- | Extract the font family name from a <tt>Font</tt> attribute.
getFont :: Font -> String

-- | Specify a font family to be used for all text within a diagram.
font :: HasStyle a => String -> a -> a

-- | Lens onto the font name of a style.
_font :: forall (v :: Type -> Type) n f. Functor f => (Maybe String -> f (Maybe String)) -> Style v n -> f (Style v n)

-- | The <tt>FontSize</tt> attribute specifies the size of a font's
--   em-square. Inner <tt>FontSize</tt> attributes override outer ones.
newtype FontSize n
FontSize :: Recommend (Last n) -> FontSize n
_FontSize :: forall n p f. (Profunctor p, Functor f) => p (Recommend n) (f (Recommend n)) -> p (FontSize n) (f (FontSize n))

-- | Set the font size, that is, the size of the font's em-square as
--   measured within the current local vector space. The default size is
--   <tt>local 1</tt> (which is applied by <a>recommendFontSize</a>).
fontSize :: (N a ~ n, Typeable n, HasStyle a) => Measure n -> a -> a

-- | <a>Recommend</a> a font size. Any use of <a>fontSize</a> above this
--   will overwrite any recommended size. This should only be used with
--   <a>mkText'</a>, other text functions already has a recommended font
--   size so this will be ignored.
recommendFontSize :: (N a ~ n, Typeable n, HasStyle a) => Measure n -> a -> a

-- | A convenient synonym for 'fontSize (Normalized w)'.
fontSizeN :: (N a ~ n, Typeable n, Num n, HasStyle a) => n -> a -> a

-- | A convenient synonym for 'fontSize (Output w)'.
fontSizeO :: (N a ~ n, Typeable n, HasStyle a) => n -> a -> a

-- | A convenient sysnonym for 'fontSize (Local w)'.
fontSizeL :: (N a ~ n, Typeable n, Num n, HasStyle a) => n -> a -> a

-- | A convenient synonym for 'fontSize (Global w)'.
fontSizeG :: (N a ~ n, Typeable n, Num n, HasStyle a) => n -> a -> a

-- | Extract the size from a <tt>FontSize</tt> attribute.
getFontSize :: FontSize n -> n

-- | Apply a <a>FontSize</a> attribute.
fontSizeM :: (N a ~ n, Typeable n, HasStyle a) => FontSizeM n -> a -> a
_fontSizeR :: forall n (v :: Type -> Type). (Typeable n, OrderedField n) => Lens' (Style v n) (Measured n (Recommend n))

-- | Lens to commit a font size. This is *not* a valid lens (see
--   <tt>commited</tt>.
_fontSize :: forall n (v :: Type -> Type). (Typeable n, OrderedField n) => Lens' (Style v n) (Measure n)
_fontSizeU :: forall n (v :: Type -> Type). Typeable n => Lens' (Style v n) (Maybe n)

-- | The <tt>FontSlantA</tt> attribute specifies the slant (normal, italic,
--   or oblique) that should be used for all text within a diagram. Inner
--   <tt>FontSlantA</tt> attributes override outer ones.
data FontSlant
FontSlantNormal :: FontSlant
FontSlantItalic :: FontSlant
FontSlantOblique :: FontSlant

-- | Extract the font slant from a <tt>FontSlantA</tt> attribute.
getFontSlant :: FontSlant -> FontSlant

-- | Specify the slant (normal, italic, or oblique) that should be used for
--   all text within a diagram. See also <a>italic</a> and <a>oblique</a>
--   for useful special cases.
fontSlant :: HasStyle a => FontSlant -> a -> a

-- | Set all text in italics.
italic :: HasStyle a => a -> a

-- | Set all text using an oblique slant.
oblique :: HasStyle a => a -> a

-- | Lens onto the font slant in a style.
_fontSlant :: forall (v :: Type -> Type) n f. Functor f => (FontSlant -> f FontSlant) -> Style v n -> f (Style v n)

-- | The <tt>FontWeightA</tt> attribute specifies the weight (normal or
--   bold) that should be used for all text within a diagram. Inner
--   <tt>FontWeightA</tt> attributes override outer ones.
data FontWeight
FontWeightNormal :: FontWeight
FontWeightBold :: FontWeight
FontWeightBolder :: FontWeight
FontWeightLighter :: FontWeight
FontWeightThin :: FontWeight
FontWeightUltraLight :: FontWeight
FontWeightLight :: FontWeight
FontWeightMedium :: FontWeight
FontWeightSemiBold :: FontWeight
FontWeightUltraBold :: FontWeight
FontWeightHeavy :: FontWeight

-- | Extract the font weight.
getFontWeight :: FontWeight -> FontWeight

-- | Specify the weight (normal, bolder, lighter or bold) that should be
--   used for all text within a diagram. See also <a>bold</a> for a useful
--   special case.
fontWeight :: HasStyle a => FontWeight -> a -> a

-- | Set all text using a bold font weight.
bold :: HasStyle a => a -> a

-- | Set all text to be bolder than the inherited font weight.
bolder :: HasStyle a => a -> a

-- | Set all text to be lighter than the inherited font weight.
lighter :: HasStyle a => a -> a

-- | Lens onto the font weight in a style.
_fontWeight :: forall (v :: Type -> Type) n f. Functor f => (FontWeight -> f FontWeight) -> Style v n -> f (Style v n)

-- | Set all text using a thin font weight.
thinWeight :: HasStyle a => a -> a

-- | Set all text using a extra light font weight.
ultraLight :: HasStyle a => a -> a

-- | Set all text using a light font weight.
light :: HasStyle a => a -> a

-- | Set all text using a medium font weight.
mediumWeight :: HasStyle a => a -> a

-- | Set all text using a heavy/black font weight.
heavy :: HasStyle a => a -> a

-- | Set all text using a semi-bold font weight.
semiBold :: HasStyle a => a -> a

-- | Set all text using an ultra-bold font weight.
ultraBold :: HasStyle a => a -> a
instance Diagrams.Core.Style.AttributeClass Diagrams.TwoD.Text.Font
instance GHC.Internal.Data.Typeable.Internal.Typeable n => Diagrams.Core.Style.AttributeClass (Diagrams.TwoD.Text.FontSize n)
instance Diagrams.Core.Style.AttributeClass Diagrams.TwoD.Text.FontSlant
instance Diagrams.Core.Style.AttributeClass Diagrams.TwoD.Text.FontWeight
instance Data.Default.Internal.Default Diagrams.TwoD.Text.FontSlant
instance Data.Default.Internal.Default Diagrams.TwoD.Text.FontWeight
instance GHC.Internal.Num.Num n => Data.Default.Internal.Default (Diagrams.TwoD.Text.FontSizeM n)
instance GHC.Classes.Eq Diagrams.TwoD.Text.Font
instance GHC.Classes.Eq Diagrams.TwoD.Text.FontSlant
instance GHC.Classes.Eq Diagrams.TwoD.Text.FontWeight
instance GHC.Internal.Base.Functor Diagrams.TwoD.Text.FontSize
instance GHC.Internal.Float.Floating n => Diagrams.Core.HasOrigin.HasOrigin (Diagrams.TwoD.Text.Text n)
instance GHC.Classes.Ord Diagrams.TwoD.Text.FontSlant
instance GHC.Classes.Ord Diagrams.TwoD.Text.FontWeight
instance GHC.Internal.Float.Floating n => Diagrams.Core.Types.Renderable (Diagrams.TwoD.Text.Text n) Diagrams.Core.Types.NullBackend
instance GHC.Internal.Base.Semigroup Diagrams.TwoD.Text.Font
instance GHC.Internal.Base.Semigroup (Diagrams.TwoD.Text.FontSize n)
instance GHC.Internal.Base.Semigroup Diagrams.TwoD.Text.FontSlant
instance GHC.Internal.Base.Semigroup Diagrams.TwoD.Text.FontWeight
instance GHC.Internal.Show.Show Diagrams.TwoD.Text.FontSlant
instance GHC.Internal.Show.Show Diagrams.TwoD.Text.FontWeight
instance GHC.Internal.Float.Floating n => Diagrams.Core.Transform.Transformable (Diagrams.TwoD.Text.Text n)


-- | Standard arrowheads and tails. Each arrowhead or tail is designed to
--   be drawn filled, with a line width of 0, and is normalized to fit
--   inside a circle of diameter 1.
module Diagrams.TwoD.Arrowheads

tri :: RealFloat n => ArrowHT n

dart :: RealFloat n => ArrowHT n

halfDart :: RealFloat n => ArrowHT n

spike :: RealFloat n => ArrowHT n

thorn :: RealFloat n => ArrowHT n

-- | A line the same width as the shaft.
lineHead :: RealFloat n => ArrowHT n
noHead :: ArrowHT n

-- | Isoceles triangle style. The above example specifies an angle of `2/5
--   Turn`.
--   
arrowheadTriangle :: RealFloat n => Angle n -> ArrowHT n

-- | Isoceles triangle with linear concave base. Inkscape type 1 - dart
--   like.
arrowheadDart :: RealFloat n => Angle n -> ArrowHT n

-- | Top half of an <a>arrowheadDart</a>.
arrowheadHalfDart :: RealFloat n => Angle n -> ArrowHT n

-- | Isoceles triangle with curved concave base. Inkscape type 2.
arrowheadSpike :: RealFloat n => Angle n -> ArrowHT n

-- | Curved sides, linear concave base. Illustrator CS5 #3
arrowheadThorn :: RealFloat n => Angle n -> ArrowHT n

tri' :: RealFloat n => ArrowHT n

dart' :: RealFloat n => ArrowHT n

halfDart' :: RealFloat n => ArrowHT n

spike' :: RealFloat n => ArrowHT n

thorn' :: RealFloat n => ArrowHT n

-- | A line the same width as the shaft.
lineTail :: RealFloat n => ArrowHT n
noTail :: ArrowHT n

quill :: (Floating n, Ord n) => ArrowHT n

block :: RealFloat n => ArrowHT n

-- | The angle is where the top left corner intersects the circle.
arrowtailQuill :: OrderedField n => Angle n -> ArrowHT n
arrowtailBlock :: RealFloat n => Angle n -> ArrowHT n
type ArrowHT n = n -> n -> (Path V2 n, Path V2 n)


-- | Drawing arrows in two dimensions. For a tutorial on drawing arrows
--   using this module, see the diagrams website:
--   <a>https://diagrams.github.io/doc/arrow.html</a>.
module Diagrams.TwoD.Arrow

-- | <tt>arrowV v</tt> creates an arrow with the direction and norm of the
--   vector <tt>v</tt> (with its tail at the origin), using default
--   parameters.
arrowV :: (TypeableFloat n, Renderable (Path V2 n) b) => V2 n -> QDiagram b V2 n Any

-- | <tt>arrowV' v</tt> creates an arrow with the direction and norm of the
--   vector <tt>v</tt> (with its tail at the origin).
arrowV' :: (TypeableFloat n, Renderable (Path V2 n) b) => ArrowOpts n -> V2 n -> QDiagram b V2 n Any

-- | Create an arrow starting at s with length and direction determined by
--   the vector v.
arrowAt :: (TypeableFloat n, Renderable (Path V2 n) b) => Point V2 n -> V2 n -> QDiagram b V2 n Any
arrowAt' :: (TypeableFloat n, Renderable (Path V2 n) b) => ArrowOpts n -> Point V2 n -> V2 n -> QDiagram b V2 n Any

-- | <tt>arrowBetween s e</tt> creates an arrow pointing from <tt>s</tt> to
--   <tt>e</tt> with default parameters.
arrowBetween :: (TypeableFloat n, Renderable (Path V2 n) b) => Point V2 n -> Point V2 n -> QDiagram b V2 n Any

-- | <tt>arrowBetween' opts s e</tt> creates an arrow pointing from
--   <tt>s</tt> to <tt>e</tt> using the given options. In particular, it
--   scales and rotates <tt>arrowShaft</tt> to go between <tt>s</tt> and
--   <tt>e</tt>, taking head, tail, and gaps into account.
arrowBetween' :: (TypeableFloat n, Renderable (Path V2 n) b) => ArrowOpts n -> Point V2 n -> Point V2 n -> QDiagram b V2 n Any

-- | Connect two diagrams with a straight arrow.
connect :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => n1 -> n2 -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Connect two diagrams with an arbitrary arrow.
connect' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => ArrowOpts n -> n1 -> n2 -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Connect two diagrams at point on the perimeter of the diagrams,
--   choosen by angle.
connectPerim :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => n1 -> n2 -> Angle n -> Angle n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
connectPerim' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => ArrowOpts n -> n1 -> n2 -> Angle n -> Angle n -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Draw an arrow from diagram named "n1" to diagram named "n2". The arrow
--   lies on the line between the centres of the diagrams, but is drawn so
--   that it stops at the boundaries of the diagrams, using traces to find
--   the intersection points.
connectOutside :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => n1 -> n2 -> QDiagram b V2 n Any -> QDiagram b V2 n Any
connectOutside' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => ArrowOpts n -> n1 -> n2 -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | <tt>arrow len</tt> creates an arrow of length <tt>len</tt> with
--   default parameters, starting at the origin and ending at the point
--   <tt>(len,0)</tt>.
arrow :: (TypeableFloat n, Renderable (Path V2 n) b) => n -> QDiagram b V2 n Any

-- | <tt>arrow' opts len</tt> creates an arrow of length <tt>len</tt> using
--   the given options, starting at the origin and ending at the point
--   <tt>(len,0)</tt>. In particular, it scales the given <a>arrowShaft</a>
--   so that the entire arrow has length <tt>len</tt>.
arrow' :: (TypeableFloat n, Renderable (Path V2 n) b) => ArrowOpts n -> n -> QDiagram b V2 n Any

-- | Turn a located trail into a default arrow by putting an arrowhead at
--   the end of the trail.
arrowFromLocatedTrail :: (Renderable (Path V2 n) b, RealFloat n, Typeable n) => Located (Trail V2 n) -> QDiagram b V2 n Any

-- | Turn a located trail into an arrow using the given options.
arrowFromLocatedTrail' :: (Renderable (Path V2 n) b, RealFloat n, Typeable n) => ArrowOpts n -> Located (Trail V2 n) -> QDiagram b V2 n Any
data ArrowOpts n
ArrowOpts :: ArrowHT n -> ArrowHT n -> Trail V2 n -> Measure n -> Measure n -> Style V2 n -> Measure n -> Style V2 n -> Measure n -> Style V2 n -> ArrowOpts n
[_arrowHead] :: ArrowOpts n -> ArrowHT n
[_arrowTail] :: ArrowOpts n -> ArrowHT n
[_arrowShaft] :: ArrowOpts n -> Trail V2 n
[_headGap] :: ArrowOpts n -> Measure n
[_tailGap] :: ArrowOpts n -> Measure n
[_headStyle] :: ArrowOpts n -> Style V2 n
[_headLength] :: ArrowOpts n -> Measure n
[_tailStyle] :: ArrowOpts n -> Style V2 n
[_tailLength] :: ArrowOpts n -> Measure n
[_shaftStyle] :: ArrowOpts n -> Style V2 n

-- | A shape to place at the head of the arrow.
arrowHead :: forall n f. Functor f => (ArrowHT n -> f (ArrowHT n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | A shape to place at the tail of the arrow.
arrowTail :: forall n f. Functor f => (ArrowHT n -> f (ArrowHT n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | The trail to use for the arrow shaft.
arrowShaft :: forall n f. Functor f => (Trail V2 n -> f (Trail V2 n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | Distance to leave between the head and the target point.
headGap :: forall n f. Functor f => (Measure n -> f (Measure n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | Distance to leave between the starting point and the tail.
tailGap :: forall n f. Functor f => (Measure n -> f (Measure n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | Set both the <tt>headGap</tt> and <tt>tailGap</tt> simultaneously.
gaps :: forall n f. Applicative f => (Measure n -> f (Measure n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | Same as gaps, provided for backward compatiiblity.
gap :: forall n f. Applicative f => (Measure n -> f (Measure n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | A lens for setting or modifying the texture of an arrowhead. For
--   example, one may write <tt>... (with &amp; headTexture .~ grad)</tt>
--   to get an arrow with a head filled with a gradient, assuming grad has
--   been defined. Or <tt>... (with &amp; headTexture .~ solid blue</tt> to
--   set the head color to blue. For more general control over the style of
--   arrowheads, see <a>headStyle</a>.
headTexture :: TypeableFloat n => Lens' (ArrowOpts n) (Texture n)

-- | Style to apply to the head. <tt>headStyle</tt> is modified by using
--   the lens combinator <tt>%~</tt> to change the current style. For
--   example, to change an opaque black arrowhead to translucent orange:
--   <tt>(with &amp; headStyle %~ fc orange . opacity 0.75)</tt>.
headStyle :: forall n f. Functor f => (Style V2 n -> f (Style V2 n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | The length from the start of the joint to the tip of the head.
headLength :: forall n f. Functor f => (Measure n -> f (Measure n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | A lens for setting or modifying the texture of an arrow tail. This is
--   *not* a valid lens (see <a>committed</a>).
tailTexture :: TypeableFloat n => Lens' (ArrowOpts n) (Texture n)

-- | Style to apply to the tail. See <a>headStyle</a>.
tailStyle :: forall n f. Functor f => (Style V2 n -> f (Style V2 n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | The length of the tail plus its joint.
tailLength :: forall n f. Functor f => (Measure n -> f (Measure n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | Set both the <tt>headLength</tt> and <tt>tailLength</tt>
--   simultaneously.
lengths :: forall n f. Applicative f => (Measure n -> f (Measure n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | A lens for setting or modifying the texture of an arrow shaft.
shaftTexture :: TypeableFloat n => Lens' (ArrowOpts n) (Texture n)

-- | Style to apply to the shaft. See <a>headStyle</a>.
shaftStyle :: forall n f. Functor f => (Style V2 n -> f (Style V2 n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | Straight line arrow shaft.
straightShaft :: OrderedField n => Trail V2 n
instance Diagrams.Core.Types.TypeableFloat n => Data.Default.Internal.Default (Diagrams.TwoD.Arrow.ArrowOpts n)


-- | Linear maps. Unlike <a>Transformation</a>s these are not restricted to
--   the same space. In practice these are used for projections in
--   <a>Diagrams.ThreeD.Projection</a>. Unless you want to work with
--   projections you're probably better off using <a>Transform</a>.
--   
--   Currently only path-like things can be projected. In the future we
--   hope to support projecting diagrams.
module Diagrams.LinearMap

-- | Type for holding linear maps. Note that these are not affine
--   transforms so attemping apply a translation with <a>LinearMap</a> will
--   likely produce incorrect results.
newtype LinearMap (v :: Type -> Type) (u :: Type -> Type) n
LinearMap :: (v n -> u n) -> LinearMap (v :: Type -> Type) (u :: Type -> Type) n
[lapply] :: LinearMap (v :: Type -> Type) (u :: Type -> Type) n -> v n -> u n

-- | Class of things that have vectors that can be mapped over.
class LinearMappable a b

-- | Apply a linear map to an object. If the map is not linear, behaviour
--   will likely be wrong.
vmap :: LinearMappable a b => (Vn a -> Vn b) -> a -> b

-- | Apply a linear map.
linmap :: forall (v :: Type -> Type) n a b. (InSpace v n a, LinearMappable a b, N b ~ n) => LinearMap v (V b) n -> a -> b

-- | Affine linear maps. Unlike <a>Transformation</a> these do not have to
--   be invertible so we can map between spaces.
data AffineMap (v :: Type -> Type) (u :: Type -> Type) n
AffineMap :: LinearMap v u n -> u n -> AffineMap (v :: Type -> Type) (u :: Type -> Type) n
class (LinearMappable a b, N a ~ N b) => AffineMappable a b

-- | Affine map over an object. Has a default implimentation of only
--   applying the linear map
amap :: AffineMappable a b => AffineMap (V a) (V b) (N b) -> a -> b

-- | Make an affine map from a linear function and a translation.
mkAffineMap :: (v n -> u n) -> u n -> AffineMap v u n
toAffineMap :: forall (v :: Type -> Type) n. Transformation v n -> AffineMap v v n
instance (r GHC.Types.~ Diagrams.Segment.FixedSegment u n) => Diagrams.LinearMap.AffineMappable (Diagrams.Segment.FixedSegment v n) r
instance (Diagrams.LinearMap.LinearMappable a b, Diagrams.Core.V.N a GHC.Types.~ Diagrams.Core.V.N b, r GHC.Types.~ Diagrams.Located.Located b) => Diagrams.LinearMap.AffineMappable (Diagrams.Located.Located a) r
instance (r GHC.Types.~ Diagrams.Segment.Offset c u n) => Diagrams.LinearMap.AffineMappable (Diagrams.Segment.Offset c v n) r
instance (Linear.Metric.Metric v, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n, r GHC.Types.~ Diagrams.Path.Path u n) => Diagrams.LinearMap.AffineMappable (Diagrams.Path.Path v n) r
instance (Linear.Vector.Additive v, GHC.Internal.Num.Num n, r GHC.Types.~ Linear.Affine.Point u n) => Diagrams.LinearMap.AffineMappable (Linear.Affine.Point v n) r
instance (Linear.Metric.Metric v, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n, r GHC.Types.~ Diagrams.Trail.SegTree u n) => Diagrams.LinearMap.AffineMappable (Diagrams.Trail.SegTree v n) r
instance (r GHC.Types.~ Diagrams.Segment.Segment c u n) => Diagrams.LinearMap.AffineMappable (Diagrams.Segment.Segment c v n) r
instance (Linear.Metric.Metric v, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n, r GHC.Types.~ Diagrams.Trail.Trail' l u n) => Diagrams.LinearMap.AffineMappable (Diagrams.Trail.Trail' l v n) r
instance (Linear.Metric.Metric v, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n, r GHC.Types.~ Diagrams.Trail.Trail u n) => Diagrams.LinearMap.AffineMappable (Diagrams.Trail.Trail v n) r
instance (r GHC.Types.~ Diagrams.Segment.FixedSegment u m) => Diagrams.LinearMap.LinearMappable (Diagrams.Segment.FixedSegment v n) r
instance (Diagrams.LinearMap.LinearMappable a b, r GHC.Types.~ Diagrams.Located.Located b) => Diagrams.LinearMap.LinearMappable (Diagrams.Located.Located a) r
instance (r GHC.Types.~ Diagrams.Segment.Offset c u m) => Diagrams.LinearMap.LinearMappable (Diagrams.Segment.Offset c v n) r
instance (Linear.Metric.Metric v, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n, Diagrams.Core.Envelope.OrderedField m, r GHC.Types.~ Diagrams.Path.Path u m) => Diagrams.LinearMap.LinearMappable (Diagrams.Path.Path v n) r
instance Diagrams.LinearMap.LinearMappable (Linear.Affine.Point v n) (Linear.Affine.Point u m)
instance (Linear.Metric.Metric v, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n, Diagrams.Core.Envelope.OrderedField m, r GHC.Types.~ Diagrams.Trail.SegTree u m) => Diagrams.LinearMap.LinearMappable (Diagrams.Trail.SegTree v n) r
instance (r GHC.Types.~ Diagrams.Segment.Segment c u m) => Diagrams.LinearMap.LinearMappable (Diagrams.Segment.Segment c v n) r
instance (Linear.Metric.Metric v, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n, Diagrams.Core.Envelope.OrderedField m, r GHC.Types.~ Diagrams.Trail.Trail' l u m) => Diagrams.LinearMap.LinearMappable (Diagrams.Trail.Trail' l v n) r
instance (Linear.Metric.Metric v, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n, Diagrams.Core.Envelope.OrderedField m, r GHC.Types.~ Diagrams.Trail.Trail u m) => Diagrams.LinearMap.LinearMappable (Diagrams.Trail.Trail v n) r

module Diagrams.Deform

-- | <tt>Deformations</tt> are a superset of the affine transformations
--   represented by the <a>Transformation</a> type. In general they are not
--   invertible. <tt>Deformation</tt>s include projective transformations.
--   <tt>Deformation</tt> can represent other functions from points to
--   points which are "well-behaved", in that they do not introduce small
--   wiggles.
newtype Deformation (v :: Type -> Type) (u :: Type -> Type) n
Deformation :: (Point v n -> Point u n) -> Deformation (v :: Type -> Type) (u :: Type -> Type) n
class Deformable a b

-- | <tt>deform' epsilon d a</tt> transforms <tt>a</tt> by the deformation
--   <tt>d</tt>. If the type of <tt>a</tt> is not closed under projection,
--   approximate to accuracy <tt>epsilon</tt>.
deform' :: Deformable a b => N a -> Deformation (V a) (V b) (N a) -> a -> b

-- | <tt>deform d a</tt> transforms <tt>a</tt> by the deformation
--   <tt>d</tt>. If the type of <tt>a</tt> is not closed under projection,
--   <tt>deform</tt> should call <tt>deform'</tt> with some reasonable
--   default value of <tt>epsilon</tt>.
deform :: Deformable a b => Deformation (V a) (V b) (N a) -> a -> b

-- | <tt>asDeformation</tt> converts a <a>Transformation</a> to a
--   <a>Deformation</a> by discarding the inverse transform. This allows
--   reusing <tt>Transformation</tt>s in the construction of
--   <tt>Deformation</tt>s.
asDeformation :: forall (v :: Type -> Type) n. (Additive v, Num n) => Transformation v n -> Deformation v v n
instance (Linear.Metric.Metric v, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n, r GHC.Types.~ Diagrams.Located.Located (Diagrams.Trail.Trail u n)) => Diagrams.Deform.Deformable (Diagrams.Located.Located (Diagrams.Trail.Trail v n)) r
instance (Linear.Metric.Metric v, Linear.Metric.Metric u, Diagrams.Core.Envelope.OrderedField n, r GHC.Types.~ Diagrams.Path.Path u n) => Diagrams.Deform.Deformable (Diagrams.Path.Path v n) r
instance (r GHC.Types.~ Linear.Affine.Point u n) => Diagrams.Deform.Deformable (Linear.Affine.Point v n) r
instance GHC.Internal.Base.Monoid (Diagrams.Deform.Deformation v v n)
instance GHC.Internal.Base.Semigroup (Diagrams.Deform.Deformation v v n)

module Diagrams.TwoD.Deform

-- | The parallel projection onto the plane x=0
parallelX0 :: forall (v :: Type -> Type) n. (R1 v, Num n) => Deformation v v n

-- | The perspective division onto the plane x=1 along lines going through
--   the origin.
perspectiveX1 :: forall (v :: Type -> Type) n. (R1 v, Functor v, Fractional n) => Deformation v v n

-- | The parallel projection onto the plane y=0
parallelY0 :: forall (v :: Type -> Type) n. (R2 v, Num n) => Deformation v v n

-- | The perspective division onto the plane y=1 along lines going through
--   the origin.
perspectiveY1 :: forall (v :: Type -> Type) n. (R2 v, Functor v, Floating n) => Deformation v v n

-- | The viewing transform for a viewer facing along the positive X axis. X
--   coördinates stay fixed, while Y coördinates are compressed with
--   increasing distance. <tt>asDeformation (translation unitX) &lt;&gt;
--   parallelX0 &lt;&gt; frustrumX = perspectiveX1</tt>
facingX :: forall (v :: Type -> Type) n. (R1 v, Functor v, Fractional n) => Deformation v v n
facingY :: forall (v :: Type -> Type) n. (R2 v, Functor v, Fractional n) => Deformation v v n


-- | 3D projections are a way of viewing a three-dimensional objects on a
--   two-dimensional plane.
--   
--   This module can be used with the functions in
--   <a>Linear.Projection</a>.
--   
--   Disclaimer: This module should be considered experimental and is
--   likely to change.
module Diagrams.ThreeD.Projection

-- | Look at the xy-plane with y as the up direction.
facingXY :: (Epsilon n, Floating n) => AffineMap V3 V2 n

-- | Look at the xz-plane with z as the up direction.
facingXZ :: (Epsilon n, Floating n) => AffineMap V3 V2 n

-- | Look at the yz-plane with z as the up direction.
facingYZ :: (Epsilon n, Floating n) => AffineMap V3 V2 n

-- | Apply an isometric projection given the up direction
isometricApply :: (InSpace V3 n a, InSpace V2 n b, AffineMappable a b, Floating n, Epsilon n) => Direction V3 n -> a -> b

-- | Make an isometric affine map with the given up direction.
isometric :: (Floating n, Epsilon n) => Direction V3 n -> AffineMap V3 V2 n
lookingAt :: (Epsilon n, Floating n) => P3 n -> P3 n -> Direction V3 n -> AffineMap V3 V2 n

-- | Apply the affine part of a homogeneous matrix.
m44AffineApply :: (InSpace V3 n a, InSpace V2 n b, AffineMappable a b) => M44 n -> a -> b

-- | Create an <a>AffineMap</a> from a 4x4 homogeneous matrix, ignoring any
--   perspective transforms.
m44AffineMap :: Num n => M44 n -> AffineMap V3 V2 n

-- | Apply a transformation matrix and translation.
m33AffineApply :: (InSpace V3 n a, InSpace V2 n b, AffineMappable a b) => M33 n -> V2 n -> a -> b

-- | Create an <a>AffineMap</a> from a 3x3 transformation matrix and a
--   translation vector.
m33AffineMap :: Num n => M33 n -> V2 n -> AffineMap V3 V2 n

-- | Make a deformation from a 4x4 homogeneous matrix.
m44Deformation :: Fractional n => M44 n -> Deformation V3 V2 n

module Diagrams.ThreeD.Deform

-- | The parallel projection onto the plane x=0
parallelX0 :: forall (v :: Type -> Type) n. (R1 v, Num n) => Deformation v v n

-- | The perspective division onto the plane x=1 along lines going through
--   the origin.
perspectiveX1 :: forall (v :: Type -> Type) n. (R1 v, Functor v, Fractional n) => Deformation v v n

-- | The viewing transform for a viewer facing along the positive X axis. X
--   coördinates stay fixed, while Y coördinates are compressed with
--   increasing distance. <tt>asDeformation (translation unitX) &lt;&gt;
--   parallelX0 &lt;&gt; frustrumX = perspectiveX1</tt>
facingX :: forall (v :: Type -> Type) n. (R1 v, Functor v, Fractional n) => Deformation v v n

-- | The parallel projection onto the plane y=0
parallelY0 :: forall (v :: Type -> Type) n. (R2 v, Num n) => Deformation v v n

-- | The perspective division onto the plane y=1 along lines going through
--   the origin.
perspectiveY1 :: forall (v :: Type -> Type) n. (R2 v, Functor v, Floating n) => Deformation v v n
facingY :: forall (v :: Type -> Type) n. (R2 v, Functor v, Fractional n) => Deformation v v n

-- | The parallel projection onto the plane z=0
parallelZ0 :: forall (v :: Type -> Type) n. (R3 v, Num n) => Deformation v v n

-- | The perspective division onto the plane z=1 along lines going through
--   the origin.
perspectiveZ1 :: forall (v :: Type -> Type) n. (R3 v, Functor v, Fractional n) => Deformation v v n
facingZ :: forall (v :: Type -> Type) n. (R3 v, Functor v, Fractional n) => Deformation v v n


-- | This module defines the three-dimensional vector space R^3,
--   three-dimensional transformations, and various predefined
--   three-dimensional shapes. This module re-exports useful functionality
--   from a group of more specific modules:
--   
--   <ul>
--   <li><a>Diagrams.ThreeD.Types</a> defines basic types for
--   two-dimensional diagrams, including types representing the 3D
--   Euclidean vector space and various systems of representing
--   directions.</li>
--   <li><a>Diagrams.ThreeD.Transform</a> defines R^3-specific
--   transformations such as rotation by an angle, and scaling,
--   translation, and reflection in the X, Y, and Z directions.
--   <a>Diagrams.ThreeD.Deform</a> defines several R^3-specific non-affine
--   transformations, such as projections.</li>
--   <li><a>Diagrams.ThreeD.Shapes</a> defines three-dimensional solids,
--   e.g. spheres and cubes.</li>
--   <li><a>Diagrams.ThreeD.Vector</a> defines some special 3D vectors and
--   functions for converting between vectors and directions.</li>
--   <li><a>Diagrams.ThreeD.Light</a> and <a>Diagrams.ThreeD.Camera</a>
--   define types needed for rendering 3D geometry to (2D) images.</li>
--   <li><a>Diagrams.ThreeD.Align</a> defines many alignment combinators
--   specialized to three dimensions.</li>
--   <li><a>Diagrams.ThreeD.Attributes</a> defines 3D-specific attributes
--   such as surface color, diffuse reflectance, and specular
--   highlights.</li>
--   </ul>
module Diagrams.ThreeD


-- | Boehm's algorithm for converting a cubic B-spline into a sequence of
--   cubic Bezier curves.
--   
--   See
--   
--   <ul>
--   <li>Thomas W. Sederberg, <i>An Introduction to B-Spline Curves</i>,
--   <a>http://web.archive.org/web/20120227050519/http://tom.cs.byu.edu/~455/bs.pdf</a></li>
--   <li>Lyle Ramshaw, <i>Blossoming: A Connect-the-Dots Approach to
--   Splines</i>,
--   <a>http://www.hpl.hp.com/techreports/Compaq-DEC/SRC-RR-19.pdf</a></li>
--   </ul>
module Diagrams.CubicSpline.Boehm
type BSpline (v :: Type -> Type) n = [Point v n]

-- | Convert a uniform cubic B-spline to a sequence of cubic beziers.
--   (<i>Uniform</i> refers to the fact that the knots are assumed to be
--   evenly spaced, with no duplicates.) The knots at the end are
--   replicated so the cubic spline begins and ends at the first and last
--   control points, tangent to the line from the end control point to the
--   next.
bsplineToBeziers :: forall (v :: Type -> Type) n. (Additive v, Fractional n, Num n, Ord n) => BSpline v n -> [FixedSegment v n]

-- | Generate a uniform cubic B-spline from the given control points. The
--   spline starts and ends at the first and last control points, and is
--   tangent to the line to the second(-to-last) control point. It does not
--   necessarily pass through any of the other control points.
--   
--   
--   <pre>
--   pts = map p2 [(0,0), (2,3), (5,-2), (-4,1), (0,3)]
--   spot = circle 0.2 # fc blue # lw none
--   bsplineEx = mconcat
--     [ position (zip pts (repeat spot))
--     , bspline pts
--     ]
--     # frame 0.5
--   </pre>
bspline :: forall t (v :: Type -> Type) n. (TrailLike t, V t ~ v, N t ~ n) => BSpline v n -> t


-- | A <i>cubic spline</i> is a smooth, connected sequence of cubic curves.
--   This module provides two methods for constructing splines.
--   
--   The <a>cubicSpline</a> method can be used to create closed or open
--   cubic splines from a list of points. The resulting splines <i>pass
--   through</i> all the control points, but depend on the control points
--   in a "global" way (that is, changing one control point may alter the
--   entire curve). For access to the internals of the spline generation
--   algorithm, see <a>Diagrams.CubicSpline.Internal</a>.
--   
--   <a>bspline</a> creates a cubic B-spline, which starts and ends at the
--   first and last control points, but does not necessarily pass through
--   any of the other control points. It depends on the control points in a
--   "local" way, that is, changing one control point will only affect a
--   local portion of the curve near that control point.
module Diagrams.CubicSpline

-- | Construct a spline path-like thing of cubic segments from a list of
--   vertices, with the first vertex as the starting point. The first
--   argument specifies whether the path should be closed.
--   
--   
--   <pre>
--   pts = map p2 [(0,0), (2,3), (5,-2), (-4,1), (0,3)]
--   spot = circle 0.2 # fc blue # lw none
--   mkPath closed = position (zip pts (repeat spot))
--                &lt;&gt; cubicSpline closed pts
--   cubicSplineEx = (mkPath False ||| strutX 2 ||| mkPath True)
--                 # centerXY # pad 1.1
--   </pre>
--   
--   For more information, see
--   <a>http://mathworld.wolfram.com/CubicSpline.html</a>.
cubicSpline :: forall t (v :: Type -> Type) n. (V t ~ v, N t ~ n, TrailLike t, Fractional (v n)) => Bool -> [Point v n] -> t
type BSpline (v :: Type -> Type) n = [Point v n]

-- | Generate a uniform cubic B-spline from the given control points. The
--   spline starts and ends at the first and last control points, and is
--   tangent to the line to the second(-to-last) control point. It does not
--   necessarily pass through any of the other control points.
--   
--   
--   <pre>
--   pts = map p2 [(0,0), (2,3), (5,-2), (-4,1), (0,3)]
--   spot = circle 0.2 # fc blue # lw none
--   bsplineEx = mconcat
--     [ position (zip pts (repeat spot))
--     , bspline pts
--     ]
--     # frame 0.5
--   </pre>
bspline :: forall t (v :: Type -> Type) n. (TrailLike t, V t ~ v, N t ~ n) => BSpline v n -> t


-- | Tools for visualizing diagrams' internal model: local origins,
--   envelopes, traces, <i>etc.</i>
module Diagrams.TwoD.Model

-- | Mark the origin of a diagram by placing a red dot 1/50th its size.
showOrigin :: (TypeableFloat n, Renderable (Path V2 n) b, Monoid' m) => QDiagram b V2 n m -> QDiagram b V2 n m

-- | Mark the origin of a diagram, with control over colour and scale of
--   marker dot.
showOrigin' :: (TypeableFloat n, Renderable (Path V2 n) b, Monoid' m) => OriginOpts n -> QDiagram b V2 n m -> QDiagram b V2 n m
data OriginOpts n
OriginOpts :: Colour Double -> n -> n -> OriginOpts n
[_oColor] :: OriginOpts n -> Colour Double
[_oScale] :: OriginOpts n -> n
[_oMinSize] :: OriginOpts n -> n
oColor :: forall n f. Functor f => (Colour Double -> f (Colour Double)) -> OriginOpts n -> f (OriginOpts n)
oScale :: forall n f. Functor f => (n -> f n) -> OriginOpts n -> f (OriginOpts n)
oMinSize :: forall n f. Functor f => (n -> f n) -> OriginOpts n -> f (OriginOpts n)

-- | Mark the envelope with an approximating cubic spline using 32 points,
--   medium line width and red line color.
showEnvelope :: (Enum n, TypeableFloat n, Renderable (Path V2 n) b) => QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Mark the envelope with an approximating cubic spline with control over
--   the color, line width and number of points.
showEnvelope' :: (Enum n, TypeableFloat n, Renderable (Path V2 n) b) => EnvelopeOpts n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
data EnvelopeOpts n
EnvelopeOpts :: Colour Double -> Measure n -> Int -> EnvelopeOpts n
[_eColor] :: EnvelopeOpts n -> Colour Double
[_eLineWidth] :: EnvelopeOpts n -> Measure n
[_ePoints] :: EnvelopeOpts n -> Int
eColor :: forall n f. Functor f => (Colour Double -> f (Colour Double)) -> EnvelopeOpts n -> f (EnvelopeOpts n)
eLineWidth :: forall n1 n2 f. Functor f => (Measure n1 -> f (Measure n2)) -> EnvelopeOpts n1 -> f (EnvelopeOpts n2)
ePoints :: forall n f. Functor f => (Int -> f Int) -> EnvelopeOpts n -> f (EnvelopeOpts n)

-- | Mark the trace of a diagram by placing 64 red dots 1/100th its size
--   along the trace.
showTrace :: (Enum n, TypeableFloat n, Renderable (Path V2 n) b) => QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Mark the trace of a diagram, with control over colour and scale of
--   marker dot and the number of points on the trace.
showTrace' :: (Enum n, TypeableFloat n, Renderable (Path V2 n) b) => TraceOpts n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
data TraceOpts n
TraceOpts :: Colour Double -> n -> n -> Int -> TraceOpts n
[_tColor] :: TraceOpts n -> Colour Double
[_tScale] :: TraceOpts n -> n
[_tMinSize] :: TraceOpts n -> n
[_tPoints] :: TraceOpts n -> Int
tColor :: forall n f. Functor f => (Colour Double -> f (Colour Double)) -> TraceOpts n -> f (TraceOpts n)
tScale :: forall n f. Functor f => (n -> f n) -> TraceOpts n -> f (TraceOpts n)
tMinSize :: forall n f. Functor f => (n -> f n) -> TraceOpts n -> f (TraceOpts n)
tPoints :: forall n f. Functor f => (Int -> f Int) -> TraceOpts n -> f (TraceOpts n)
showLabels :: (TypeableFloat n, Renderable (Text n) b, Semigroup m) => QDiagram b V2 n m -> QDiagram b V2 n Any
instance Diagrams.Core.Envelope.OrderedField n => Data.Default.Internal.Default (Diagrams.TwoD.Model.EnvelopeOpts n)
instance GHC.Internal.Real.Fractional n => Data.Default.Internal.Default (Diagrams.TwoD.Model.OriginOpts n)
instance GHC.Internal.Float.Floating n => Data.Default.Internal.Default (Diagrams.TwoD.Model.TraceOpts n)


-- | Bounding boxes are not very compositional (<i>e.g.</i> it is not
--   possible to do anything sensible with them under rotation), so they
--   are not used in the diagrams core. However, they do have their uses;
--   this module provides definitions and functions for working with them.
module Diagrams.BoundingBox

-- | A bounding box is an axis-aligned region determined by two points
--   indicating its "lower" and "upper" corners. It can also represent an
--   empty bounding box - the points are wrapped in <tt>Maybe</tt>.
data BoundingBox (v :: Type -> Type) n

-- | An empty bounding box. This is the same thing as <tt>mempty</tt>, but
--   it doesn't require the same type constraints that the <tt>Monoid</tt>
--   instance does.
emptyBox :: forall (v :: Type -> Type) n. BoundingBox v n

-- | Create a bounding box from a point that is component-wise
--   <tt>(&lt;=)</tt> than the other. If this is not the case, then
--   <tt>mempty</tt> is returned.
fromCorners :: forall (v :: Type -> Type) n. (Additive v, Foldable v, Ord n) => Point v n -> Point v n -> BoundingBox v n

-- | Create a degenerate bounding "box" containing only a single point.
fromPoint :: forall (v :: Type -> Type) n. Point v n -> BoundingBox v n

-- | Create the smallest bounding box containing all the given points.
fromPoints :: forall (v :: Type -> Type) n. (Additive v, Ord n) => [Point v n] -> BoundingBox v n

-- | Create a bounding box for any enveloped object (such as a diagram or
--   path).
boundingBox :: forall (v :: Type -> Type) n a. (InSpace v n a, HasBasis v, Enveloped a) => a -> BoundingBox v n

-- | Queries whether the BoundingBox is empty.
isEmptyBox :: forall (v :: Type -> Type) n. BoundingBox v n -> Bool

-- | Gets the lower and upper corners that define the bounding box.
getCorners :: forall (v :: Type -> Type) n. BoundingBox v n -> Maybe (Point v n, Point v n)

-- | Computes all of the corners of the bounding box.
getAllCorners :: forall (v :: Type -> Type) n. (Additive v, Traversable v) => BoundingBox v n -> [Point v n]

-- | Get the size of the bounding box - the vector from the
--   (component-wise) lesser point to the greater point.
boxExtents :: (Additive v, Num n) => BoundingBox v n -> v n

-- | Get the center point in a bounding box.
boxCenter :: forall (v :: Type -> Type) n. (Additive v, Fractional n) => BoundingBox v n -> Maybe (Point v n)

-- | Get the center of a the bounding box of an enveloped object, return
--   <a>Nothing</a> for object with empty envelope.
mCenterPoint :: forall (v :: Type -> Type) n a. (InSpace v n a, HasBasis v, Enveloped a) => a -> Maybe (Point v n)

-- | Get the center of a the bounding box of an enveloped object, return
--   the origin for object with empty envelope.
centerPoint :: forall (v :: Type -> Type) n a. (InSpace v n a, HasBasis v, Enveloped a) => a -> Point v n

-- | Create a transformation mapping points from one bounding box to the
--   other. Returns <a>Nothing</a> if either of the boxes are empty.
boxTransform :: forall (v :: Type -> Type) n. (Additive v, Fractional n) => BoundingBox v n -> BoundingBox v n -> Maybe (Transformation v n)

-- | Transforms an enveloped thing to fit within a <tt>BoundingBox</tt>. If
--   the bounding box is empty, then the result is also <tt>mempty</tt>.
boxFit :: forall (v :: Type -> Type) n a. (InSpace v n a, HasBasis v, Enveloped a, Transformable a, Monoid a) => BoundingBox v n -> a -> a

-- | Check whether a point is contained in a bounding box (including its
--   edges).
contains :: forall (v :: Type -> Type) n. (Additive v, Foldable v, Ord n) => BoundingBox v n -> Point v n -> Bool

-- | Check whether a point is <i>strictly</i> contained in a bounding box.
contains' :: forall (v :: Type -> Type) n. (Additive v, Foldable v, Ord n) => BoundingBox v n -> Point v n -> Bool

-- | Test whether the first bounding box is contained inside the second.
inside :: forall (v :: Type -> Type) n. (Additive v, Foldable v, Ord n) => BoundingBox v n -> BoundingBox v n -> Bool

-- | Test whether the first bounding box is <i>strictly</i> contained
--   inside the second.
inside' :: forall (v :: Type -> Type) n. (Additive v, Foldable v, Ord n) => BoundingBox v n -> BoundingBox v n -> Bool

-- | Test whether the first bounding box lies outside the second (although
--   they may intersect in their boundaries).
outside :: forall (v :: Type -> Type) n. (Additive v, Foldable v, Ord n) => BoundingBox v n -> BoundingBox v n -> Bool

-- | Test whether the first bounding box lies <i>strictly</i> outside the
--   second (they do not intersect at all).
outside' :: forall (v :: Type -> Type) n. (Additive v, Foldable v, Ord n) => BoundingBox v n -> BoundingBox v n -> Bool

-- | <tt>boxGrid f box</tt> returns a grid of regularly spaced points
--   inside the box, such that there are <tt>(1/f)</tt> points along each
--   dimension. For example, for a 3D box with corners at (0,0,0) and
--   (2,2,2), <tt>boxGrid 0.1</tt> would yield a grid of approximately 1000
--   points (it might actually be <tt>11^3</tt> instead of <tt>10^3</tt>)
--   spaced <tt>0.2</tt> units apart.
boxGrid :: forall (v :: Type -> Type) n. (Traversable v, Additive v, Num n, Enum n) => n -> BoundingBox v n -> [Point v n]

-- | Form the smallest bounding box containing the given two bound union.
--   This function is just an alias for <tt>mappend</tt>.
union :: forall (v :: Type -> Type) n. (Additive v, Ord n) => BoundingBox v n -> BoundingBox v n -> BoundingBox v n

-- | Form the largest bounding box contained within this given two bounding
--   boxes, or <tt>Nothing</tt> if the two bounding boxes do not overlap at
--   all.
intersection :: forall (v :: Type -> Type) n. (Additive v, Foldable v, Ord n) => BoundingBox v n -> BoundingBox v n -> BoundingBox v n
instance (Linear.Metric.Metric v, GHC.Internal.Data.Traversable.Traversable v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Align.Alignable (Diagrams.BoundingBox.BoundingBox v n)
instance Control.Lens.Empty.AsEmpty (Diagrams.BoundingBox.BoundingBox v n)
instance (Linear.Vector.Additive v', GHC.Internal.Data.Foldable.Foldable v', GHC.Classes.Ord n') => Control.Lens.Each.Each (Diagrams.BoundingBox.BoundingBox v n) (Diagrams.BoundingBox.BoundingBox v' n') (Linear.Affine.Point v n) (Linear.Affine.Point v' n')
instance (Linear.Metric.Metric v, GHC.Internal.Data.Traversable.Traversable v, Diagrams.Core.Envelope.OrderedField n) => Diagrams.Core.Envelope.Enveloped (Diagrams.BoundingBox.BoundingBox v n)
instance GHC.Classes.Eq (v n) => GHC.Classes.Eq (Diagrams.BoundingBox.BoundingBox v n)
instance GHC.Classes.Eq (v n) => GHC.Classes.Eq (Diagrams.BoundingBox.NonEmptyBoundingBox v n)
instance GHC.Internal.Base.Functor v => GHC.Internal.Base.Functor (Diagrams.BoundingBox.BoundingBox v)
instance GHC.Internal.Base.Functor v => GHC.Internal.Base.Functor (Diagrams.BoundingBox.NonEmptyBoundingBox v)
instance (Linear.Vector.Additive v, GHC.Internal.Num.Num n) => Diagrams.Core.HasOrigin.HasOrigin (Diagrams.BoundingBox.BoundingBox v n)
instance (Linear.Vector.Additive v, GHC.Internal.Data.Foldable.Foldable v, GHC.Classes.Ord n) => Diagrams.Query.HasQuery (Diagrams.BoundingBox.BoundingBox v n) GHC.Internal.Data.Semigroup.Internal.Any
instance (Linear.Vector.Additive v, GHC.Classes.Ord n) => GHC.Internal.Base.Monoid (Diagrams.BoundingBox.BoundingBox v n)
instance GHC.Internal.Read.Read (v n) => GHC.Internal.Read.Read (Diagrams.BoundingBox.BoundingBox v n)
instance (Linear.Vector.Additive v, GHC.Classes.Ord n) => GHC.Internal.Base.Semigroup (Diagrams.BoundingBox.BoundingBox v n)
instance (Linear.Vector.Additive v, GHC.Classes.Ord n) => GHC.Internal.Base.Semigroup (Diagrams.BoundingBox.NonEmptyBoundingBox v n)
instance GHC.Internal.Show.Show (v n) => GHC.Internal.Show.Show (Diagrams.BoundingBox.BoundingBox v n)
instance GHC.Internal.Float.RealFloat n => Diagrams.Core.Trace.Traced (Diagrams.BoundingBox.BoundingBox Linear.V2.V2 n)
instance Diagrams.Core.Types.TypeableFloat n => Diagrams.Core.Trace.Traced (Diagrams.BoundingBox.BoundingBox Linear.V3.V3 n)


-- | Diagram combinators specialized to two dimensions. For more general
--   combinators, see <a>Diagrams.Combinators</a>.
module Diagrams.TwoD.Combinators

-- | Place two diagrams (or other objects) vertically adjacent to one
--   another, with the first diagram above the second. Since Haskell
--   ignores whitespace in expressions, one can thus write
--   
--   <pre>
--    c
--   ===
--    d
--   
--   </pre>
--   
--   to place <tt>c</tt> above <tt>d</tt>. The local origin of the
--   resulting combined diagram is the same as the local origin of the
--   first. <tt>(===)</tt> is associative and has <a>mempty</a> as an
--   identity. See the documentation of <a>beside</a> for more information.
(===) :: (InSpace V2 n a, Juxtaposable a, Semigroup a) => a -> a -> a
infixl 6 ===

-- | Place two diagrams (or other juxtaposable objects) horizontally
--   adjacent to one another, with the first diagram to the left of the
--   second. The local origin of the resulting combined diagram is the same
--   as the local origin of the first. <tt>(|||)</tt> is associative and
--   has <a>mempty</a> as an identity. See the documentation of
--   <a>beside</a> for more information.
(|||) :: (InSpace V2 n a, Juxtaposable a, Semigroup a) => a -> a -> a
infixl 6 |||

-- | Lay out a list of juxtaposable objects in a row from left to right, so
--   that their local origins lie along a single horizontal line, with
--   successive envelopes tangent to one another.
--   
--   <ul>
--   <li>For more control over the spacing, see <a>hcat'</a>.</li>
--   <li>To align the diagrams vertically (or otherwise), use alignment
--   combinators (such as <a>alignT</a> or <a>alignB</a>) from
--   <a>Diagrams.TwoD.Align</a> before applying <a>hcat</a>.</li>
--   <li>For non-axis-aligned layout, see <a>cat</a>.</li>
--   </ul>
hcat :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => [a] -> a

-- | A variant of <a>hcat</a> taking an extra <a>CatOpts</a> record to
--   control the spacing. See the <a>cat'</a> documentation for a
--   description of the possibilities. For the common case of setting just
--   a separation amount, see <a>hsep</a>.
hcat' :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => CatOpts n -> [a] -> a

-- | A convenient synonym for horizontal concatenation with separation:
--   <tt>hsep s === hcat' (with &amp; sep .~ s)</tt>.
hsep :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => n -> [a] -> a

-- | Lay out a list of juxtaposable objects in a column from top to bottom,
--   so that their local origins lie along a single vertical line, with
--   successive envelopes tangent to one another.
--   
--   <ul>
--   <li>For more control over the spacing, see <a>vcat'</a>.</li>
--   <li>To align the diagrams horizontally (or otherwise), use alignment
--   combinators (such as <a>alignL</a> or <a>alignR</a>) from
--   <a>Diagrams.TwoD.Align</a> before applying <a>vcat</a>.</li>
--   <li>For non-axis-aligned layout, see <a>cat</a>.</li>
--   </ul>
vcat :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => [a] -> a

-- | A variant of <a>vcat</a> taking an extra <a>CatOpts</a> record to
--   control the spacing. See the <a>cat'</a> documentation for a
--   description of the possibilities. For the common case of setting just
--   a separation amount, see <a>vsep</a>.
vcat' :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => CatOpts n -> [a] -> a

-- | A convenient synonym for vertical concatenation with separation:
--   <tt>vsep s === vcat' (with &amp; sep .~ s)</tt>.
vsep :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => n -> [a] -> a

-- | <tt>strutR2 v</tt> is a two-dimensional diagram which produces no
--   output, but with respect to alignment, envelope, <i>and trace</i> acts
--   like a 1-dimensional segment oriented along the vector <tt>v</tt>,
--   with local origin at its center. If you don't care about the trace
--   then there's no difference between <tt>strutR2</tt> and the more
--   general <a>strut</a>.
strutR2 :: (RealFloat n, Monoid' m) => V2 n -> QDiagram b V2 n m

-- | <tt>strutX w</tt> is an empty diagram with width <tt>w</tt>, height 0,
--   and a centered local origin. Note that <tt>strutX (-w)</tt> behaves
--   the same as <tt>strutX w</tt>.
strutX :: forall (v :: Type -> Type) n b m. (Metric v, R1 v, OrderedField n) => n -> QDiagram b v n m

-- | <tt>strutY h</tt> is an empty diagram with height <tt>h</tt>, width 0,
--   and a centered local origin. Note that <tt>strutY (-h)</tt> behaves
--   the same as <tt>strutY h</tt>.
strutY :: forall (v :: Type -> Type) n b m. (Metric v, R2 v, OrderedField n) => n -> QDiagram b v n m

-- | <tt>padX s</tt> "pads" a diagram in the x-direction, expanding its
--   envelope horizontally by a factor of <tt>s</tt> (factors between 0 and
--   1 can be used to shrink the envelope). Note that the envelope will
--   expand with respect to the local origin, so if the origin is not
--   centered horizontally the padding may appear "uneven". If this is not
--   desired, the origin can be centered (using <a>centerX</a>) before
--   applying <tt>padX</tt>.
padX :: forall (v :: Type -> Type) n m b. (Metric v, R2 v, OrderedField n, Monoid' m) => n -> QDiagram b v n m -> QDiagram b v n m

-- | <tt>padY s</tt> "pads" a diagram in the y-direction, expanding its
--   envelope vertically by a factor of <tt>s</tt> (factors between 0 and 1
--   can be used to shrink the envelope). Note that the envelope will
--   expand with respect to the local origin, so if the origin is not
--   centered vertically the padding may appear "uneven". If this is not
--   desired, the origin can be centered (using <a>centerY</a>) before
--   applying <tt>padY</tt>.
padY :: forall (v :: Type -> Type) m n b. (Metric v, R2 v, Monoid' m, OrderedField n) => n -> QDiagram b v n m -> QDiagram b v n m

-- | <tt>extrudeLeft s</tt> "extrudes" a diagram in the negative
--   x-direction, offsetting its envelope by the provided distance. When
--   <tt> s &lt; 0 </tt>, the envelope is inset instead.
--   
--   See the documentation for <a>extrudeEnvelope</a> for more information.
extrudeLeft :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | <tt>extrudeRight s</tt> "extrudes" a diagram in the positive
--   x-direction, offsetting its envelope by the provided distance. When
--   <tt> s &lt; 0 </tt>, the envelope is inset instead.
--   
--   See the documentation for <a>extrudeEnvelope</a> for more information.
extrudeRight :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | <tt>extrudeBottom s</tt> "extrudes" a diagram in the negative
--   y-direction, offsetting its envelope by the provided distance. When
--   <tt> s &lt; 0 </tt>, the envelope is inset instead.
--   
--   See the documentation for <a>extrudeEnvelope</a> for more information.
extrudeBottom :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | <tt>extrudeTop s</tt> "extrudes" a diagram in the positive
--   y-direction, offsetting its envelope by the provided distance. When
--   <tt> s &lt; 0 </tt>, the envelope is inset instead.
--   
--   See the documentation for <a>extrudeEnvelope</a> for more information.
extrudeTop :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | <tt>rectEnvelope p v</tt> sets the envelope of a diagram to a
--   rectangle whose lower-left corner is at <tt>p</tt> and whose
--   upper-right corner is at <tt>p .+^ v</tt>. Useful for selecting the
--   rectangular portion of a diagram which should actually be "viewed" in
--   the final render, if you don't want to see the entire diagram.
rectEnvelope :: forall b n m. (OrderedField n, Monoid' m) => Point V2 n -> V2 n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | A synonym for <a>rectEnvelope</a>.
crop :: forall b n m. (OrderedField n, Monoid' m) => Point V2 n -> V2 n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | Construct a bounding rectangle for an enveloped object, that is, the
--   smallest axis-aligned rectangle which encloses the object.
boundingRect :: (InSpace V2 n a, SameSpace a t, Enveloped t, Transformable t, TrailLike t, Monoid t, Enveloped a) => a -> t

-- | "Set the background color" of a diagram. That is, place a diagram atop
--   a bounding rectangle of the given color. The background does not
--   change the result of queries.
bg :: (TypeableFloat n, Renderable (Path V2 n) b, Monoid' q) => Colour Double -> QDiagram b V2 n q -> QDiagram b V2 n q

-- | Similar to <a>bg</a> but makes the colored background rectangle larger
--   than the diagram. The first parameter is used to set how far the
--   background extends beyond the diagram. The background does not change
--   the result of queries.
bgFrame :: (TypeableFloat n, Renderable (Path V2 n) b, Monoid' q) => n -> Colour Double -> QDiagram b V2 n q -> QDiagram b V2 n q


-- | Utilities for working with sizes of objects.
module Diagrams.Size

-- | A <a>SizeSpec</a> is a way of specifying a size without needed lengths
--   for all the dimensions.
data SizeSpec (v :: Type -> Type) n

-- | Make a <a>SizeSpec</a> from a vector of maybe values. Any negative
--   values will be ignored. For 2D <a>SizeSpec</a>s see <tt>mkWidth</tt>
--   and <tt>mkHeight</tt> from <a>Diagrams.TwoD.Size</a>.
mkSizeSpec :: (Functor v, Num n) => v (Maybe n) -> SizeSpec v n

-- | Make a <a>SizeSpec</a> from a vector. Any negative values will be
--   ignored.
dims :: v n -> SizeSpec v n

-- | A size spec with no hints to the size.
absolute :: forall (v :: Type -> Type) n. (Additive v, Num n) => SizeSpec v n

-- | Retrieve a size spec as a vector of maybe values. Only positive sizes
--   are returned.
getSpec :: (Functor v, Num n, Ord n) => SizeSpec v n -> v (Maybe n)

-- | <tt>specToSize n spec</tt> extracts a size from a <a>SizeSpec</a>
--   <tt>sz</tt>. Any values not specified in the spec are replaced by the
--   smallest of the values that are specified. If there are no specified
--   values (i.e. <a>absolute</a>) then <tt>n</tt> is used.
specToSize :: (Foldable v, Functor v, Num n, Ord n) => n -> SizeSpec v n -> v n

-- | <tt>requiredScale spec sz</tt> returns the largest scaling factor to
--   make something of size <tt>sz</tt> fit the requested size
--   <tt>spec</tt> without changing the aspect ratio. <tt>sz</tt> should be
--   non-zero (otherwise a scale of 1 is returned). For non-uniform scaling
--   see <a>boxFit</a>.
requiredScale :: (Additive v, Foldable v, Fractional n, Ord n) => SizeSpec v n -> v n -> n

-- | Return the <a>Transformation</a> calcuated from <a>requiredScale</a>.
requiredScaling :: (Additive v, Foldable v, Fractional n, Ord n) => SizeSpec v n -> v n -> Transformation v n

-- | Uniformly scale any enveloped object so that it fits within the given
--   size. For non-uniform scaling see <a>boxFit</a>.
sized :: forall (v :: Type -> Type) n a. (InSpace v n a, HasLinearMap v, Transformable a, Enveloped a) => SizeSpec v n -> a -> a

-- | Uniformly scale an enveloped object so that it "has the same size as"
--   (fits within the width and height of) some other object.
sizedAs :: forall (v :: Type -> Type) n a b. (InSpace v n a, SameSpace a b, HasLinearMap v, Transformable a, Enveloped a, Enveloped b) => b -> a -> a

-- | Get the adjustment to fit a <a>BoundingBox</a> in the given
--   <a>SizeSpec</a>. The vector is the new size and the transformation to
--   position the lower corner at the origin and scale to the size spec.
sizeAdjustment :: (Additive v, Foldable v, OrderedField n) => SizeSpec v n -> BoundingBox v n -> (v n, Transformation v n)
instance GHC.Classes.Eq (v n) => GHC.Classes.Eq (Diagrams.Size.SizeSpec v n)
instance GHC.Internal.Base.Functor v => GHC.Internal.Base.Functor (Diagrams.Size.SizeSpec v)
instance GHC.Internal.Generics.Generic (Diagrams.Size.SizeSpec v n)
instance Data.Hashable.Class.Hashable (v n) => Data.Hashable.Class.Hashable (Diagrams.Size.SizeSpec v n)
instance GHC.Internal.Show.Show (v n) => GHC.Internal.Show.Show (Diagrams.Size.SizeSpec v n)


-- | Utilities for working with sizes of two-dimensional objects.
module Diagrams.TwoD.Size

-- | Compute the width of an enveloped object.
--   
--   Note this is just <tt>diameter unitX</tt>.
width :: (InSpace V2 n a, Enveloped a) => a -> n

-- | Compute the height of an enveloped object.
height :: (InSpace V2 n a, Enveloped a) => a -> n

-- | Compute the absolute x-coordinate range of an enveloped object in the
--   form <tt>(lo,hi)</tt>. Return <tt>Nothing</tt> for objects with an
--   empty envelope.
--   
--   Note this is just <tt>extent unitX</tt>.
extentX :: forall (v :: Type -> Type) n a. (InSpace v n a, R1 v, Enveloped a) => a -> Maybe (n, n)

-- | Compute the absolute y-coordinate range of an enveloped object in the
--   form <tt>(lo,hi)</tt>. Return <tt>Nothing</tt> for objects with an
--   empty envelope.
extentY :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Enveloped a) => a -> Maybe (n, n)

-- | Make a <a>SizeSpec</a> from possibly-specified width and height.
mkSizeSpec2D :: Num n => Maybe n -> Maybe n -> SizeSpec V2 n

-- | Make a <a>SizeSpec</a> with only width defined.
mkWidth :: Num n => n -> SizeSpec V2 n

-- | Make a <a>SizeSpec</a> with only height defined.
mkHeight :: Num n => n -> SizeSpec V2 n

-- | Make a <a>SizeSpec</a> from a width and height.
dims2D :: n -> n -> SizeSpec V2 n


-- | This module defines the two-dimensional vector space R^2,
--   two-dimensional transformations, and various predefined
--   two-dimensional shapes. This module re-exports useful functionality
--   from a group of more specific modules:
--   
--   <ul>
--   <li><a>Diagrams.TwoD.Types</a> defines basic types for two-dimensional
--   diagrams, including types representing the 2D Euclidean vector space
--   and various systems of angle measurement.</li>
--   <li><a>Diagrams.TwoD.Align</a> defines alignment combinators
--   specialized to two dimensions (see <a>Diagrams.Align</a> for more
--   general alignment).</li>
--   <li><a>Diagrams.TwoD.Combinators</a> defines ways of combining
--   diagrams specialized to two dimensions (see also
--   <a>Diagrams.Combinators</a> for more general combining).</li>
--   <li><a>Diagrams.TwoD.Attributes</a> defines attributes specific to two
--   dimensions, *e.g.* fill color, line color, and gradients.</li>
--   <li><a>Diagrams.TwoD.Transform</a> defines R^2-specific
--   transformations such as rotation by an angle, and scaling,
--   translation, and reflection in the X and Y directions.</li>
--   <li><a>Diagrams.TwoD.Deform</a> defines some non-affine
--   transformations specific to two dimensions, *e.g.* parallel and
--   perspective projections.</li>
--   <li><a>Diagrams.TwoD.Ellipse</a> defines circles and ellipses.</li>
--   <li><a>Diagrams.TwoD.Arc</a> defines circular arcs.</li>
--   <li><a>Diagrams.TwoD.Path</a> exports various operations on
--   two-dimensional paths when viewed as regions of the plane.</li>
--   <li><a>Diagrams.TwoD.Polygons</a> defines general algorithms for
--   drawing various types of polygons.</li>
--   <li><a>Diagrams.TwoD.Shapes</a> defines other two-dimensional shapes,
--   e.g. various polygons.</li>
--   <li><a>Diagrams.TwoD.Arrow</a> contains tools for drawing arrows
--   between things, and <a>Diagrams.TwoD.Arrowheads</a> defines a
--   collection of arrowheads.</li>
--   <li><a>Diagrams.TwoD.Text</a> defines primitive text diagrams.</li>
--   <li><a>Diagrams.TwoD.Image</a> allows importing external images into
--   diagrams.</li>
--   <li><a>Diagrams.TwoD.Vector</a> defines some special 2D vectors and
--   functions for converting between vectors and angles.</li>
--   <li><a>Diagrams.TwoD.Size</a> defines functions for working with the
--   size of 2D objects.</li>
--   <li><a>Diagrams.TwoD.Model</a> defines some aids for visualizing
--   diagrams' internal model (local origins, envelopes, etc.)</li>
--   </ul>
module Diagrams.TwoD

-- | A 2-dimensional vector
--   
--   <pre>
--   &gt;&gt;&gt; pure 1 :: V2 Int
--   V2 1 1
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; V2 1 2 + V2 3 4
--   V2 4 6
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; V2 1 2 * V2 3 4
--   V2 3 8
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; sum (V2 1 2)
--   3
--   </pre>
data V2 a
V2 :: !a -> !a -> V2 a

-- | A space that has at least 1 basis vector <a>_x</a>.
class R1 (t :: Type -> Type)

-- | <pre>
--   &gt;&gt;&gt; V1 2 ^._x
--   2
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; V1 2 &amp; _x .~ 3
--   V1 3
--   </pre>
_x :: R1 t => Lens' (t a) a

-- | A space that distinguishes 2 orthogonal basis vectors <a>_x</a> and
--   <a>_y</a>, but may have more.
class R1 t => R2 (t :: Type -> Type)

-- | <pre>
--   &gt;&gt;&gt; V2 1 2 ^._y
--   2
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; V2 1 2 &amp; _y .~ 3
--   V2 1 3
--   </pre>
_y :: R2 t => Lens' (t a) a
_xy :: R2 t => Lens' (t a) (V2 a)
type P2 = Point V2
type T2 = Transformation V2

-- | Construct a 2D vector from a pair of components. See also
--   <tt>&amp;</tt>.
r2 :: (n, n) -> V2 n

-- | Convert a 2D vector back into a pair of components. See also
--   <tt>coords</tt>.
unr2 :: V2 n -> (n, n)

-- | Curried form of <a>r2</a>.
mkR2 :: n -> n -> V2 n

-- | Construct a 2D point from a pair of coordinates. See also
--   <tt>^&amp;</tt>.
p2 :: (n, n) -> P2 n

-- | Convert a 2D point back into a pair of coordinates. See also
--   <tt>coords</tt>.
unp2 :: P2 n -> (n, n)

-- | Curried form of <a>p2</a>.
mkP2 :: n -> n -> P2 n

-- | The unit vector in the positive X direction.
unitX :: (R1 v, Additive v, Num n) => v n

-- | The unit vector in the positive Y direction.
unitY :: (R2 v, Additive v, Num n) => v n

-- | The unit vector in the negative X direction.
unit_X :: (R1 v, Additive v, Num n) => v n

-- | The unit vector in the negative Y direction.
unit_Y :: (R2 v, Additive v, Num n) => v n

-- | the counter-clockwise perpendicular vector
--   
--   <pre>
--   &gt;&gt;&gt; perp $ V2 10 20
--   V2 (-20) 10
--   </pre>
perp :: Num a => V2 a -> V2 a

-- | <tt>leftTurn v1 v2</tt> tests whether the direction of <tt>v2</tt> is
--   a left turn from <tt>v1</tt> (that is, if the direction of <tt>v2</tt>
--   can be obtained from that of <tt>v1</tt> by adding an angle 0 &lt;=
--   theta &lt;= tau/2).
leftTurn :: (Num n, Ord n) => V2 n -> V2 n -> Bool

-- | A <a>Direction</a> pointing in the X direction.
xDir :: forall (v :: Type -> Type) n. (R1 v, Additive v, Num n) => Direction v n

-- | A <a>Direction</a> pointing in the Y direction.
yDir :: forall (v :: Type -> Type) n. (R2 v, Additive v, Num n) => Direction v n

-- | The circle constant, the ratio of a circle's circumference to its
--   <i>radius</i>. Note that <tt>pi = tau/2</tt>.
--   
--   For more information and a well-reasoned argument why we should all be
--   using tau instead of pi, see <i>The Tau Manifesto</i>,
--   <a>http://tauday.com/</a>.
--   
--   To hear what it sounds like (and to easily memorize the first 30
--   digits or so), try <a>http://youtu.be/3174T-3-59Q</a>.
tau :: Floating a => a

-- | A unit vector at a specified angle counter-clockwise from the positive
--   x-axis
angleV :: Floating n => Angle n -> V2 n

-- | A direction at a specified angle counter-clockwise from the
--   <a>xDir</a>.
angleDir :: Floating n => Angle n -> Direction V2 n

-- | Signed angle between two vectors. Currently defined as
--   
--   <pre>
--   signedAngleBetween u v = (u ^. _theta) ^-^ (v ^. _theta)
--   </pre>
signedAngleBetween :: RealFloat n => V2 n -> V2 n -> Angle n

-- | Same as <a>signedAngleBetween</a> but for <tt>Directions</tt>s.
signedAngleBetweenDirs :: RealFloat n => Direction V2 n -> Direction V2 n -> Angle n

-- | A space which has magnitude <a>_r</a> that can be calculated
--   numerically.
class HasR (t :: Type -> Type)
_r :: (HasR t, RealFloat n) => Lens' (t n) n
r2PolarIso :: RealFloat n => Iso' (V2 n) (n, Angle n)

-- | Convert a <a>ToPath</a> object into a diagram. The resulting diagram
--   has the names 0, 1, ... assigned to each of the path's vertices.
--   
--   See also <a>stroke'</a>, which takes an extra options record allowing
--   its behaviour to be customized.
--   
--   <pre>
--   <a>stroke</a> :: <a>Path</a> <a>V2</a> <a>Double</a>                  -&gt; <a>Diagram</a> b
--   <a>stroke</a> :: <a>Located</a> (<a>Trail</a> <a>V2</a> <a>Double</a>)       -&gt; <a>Diagram</a> b
--   <a>stroke</a> :: <a>Located</a> (<a>Trail'</a> <a>Loop</a> <a>V2</a> <a>Double</a>) -&gt; <a>Diagram</a> b
--   <a>stroke</a> :: <a>Located</a> (<a>Trail'</a> <a>Line</a> <a>V2</a> <a>Double</a>) -&gt; <a>Diagram</a> b
--   </pre>
stroke :: (InSpace V2 n t, ToPath t, TypeableFloat n, Renderable (Path V2 n) b) => t -> QDiagram b V2 n Any

-- | A variant of <a>stroke</a> that takes an extra record of options to
--   customize its behaviour. In particular:
--   
--   <ul>
--   <li>Names can be assigned to the path's vertices</li>
--   </ul>
--   
--   <a>StrokeOpts</a> is an instance of <a>Default</a>, so <tt>stroke'
--   (<tt>with</tt> &amp; ... )</tt> syntax may be used.
stroke' :: (InSpace V2 n t, ToPath t, TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> t -> QDiagram b V2 n Any

-- | <a>stroke</a> specialised to <a>Path</a>.
strokePath :: (TypeableFloat n, Renderable (Path V2 n) b) => Path V2 n -> QDiagram b V2 n Any

-- | <a>stroke</a> specialised to <a>Path</a>.
strokeP :: (TypeableFloat n, Renderable (Path V2 n) b) => Path V2 n -> QDiagram b V2 n Any

-- | <a>stroke'</a> specialised to <a>Path</a>.
strokePath' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Path V2 n -> QDiagram b V2 n Any

-- | <a>stroke'</a> specialised to <a>Path</a>.
strokeP' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Path V2 n -> QDiagram b V2 n Any

-- | <a>stroke</a> specialised to <a>Trail</a>.
strokeTrail :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail V2 n -> QDiagram b V2 n Any

-- | <a>stroke</a> specialised to <a>Trail</a>.
strokeT :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail V2 n -> QDiagram b V2 n Any

-- | A composition of <a>stroke'</a> and <a>pathFromTrail</a> for
--   conveniently converting a trail directly into a diagram.
strokeTrail' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Trail V2 n -> QDiagram b V2 n Any

-- | Deprecated synonym for <a>strokeTrail'</a>.
strokeT' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Trail V2 n -> QDiagram b V2 n Any

-- | A composition of <a>strokeT</a> and <a>wrapLine</a> for conveniently
--   converting a line directly into a diagram.
strokeLine :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail' Line V2 n -> QDiagram b V2 n Any

-- | A composition of <a>strokeT</a> and <a>wrapLoop</a> for conveniently
--   converting a loop directly into a diagram.
strokeLoop :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail' Loop V2 n -> QDiagram b V2 n Any

-- | A convenience function for converting a <tt>Located Trail</tt>
--   directly into a diagram; <tt>strokeLocTrail = stroke . trailLike</tt>.
strokeLocTrail :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail V2 n) -> QDiagram b V2 n Any

-- | Deprecated synonym for <a>strokeLocTrail</a>.
strokeLocT :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail V2 n) -> QDiagram b V2 n Any

-- | A convenience function for converting a <tt>Located</tt> line directly
--   into a diagram; <tt>strokeLocLine = stroke . trailLike . mapLoc
--   wrapLine</tt>.
strokeLocLine :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail' Line V2 n) -> QDiagram b V2 n Any

-- | A convenience function for converting a <tt>Located</tt> loop directly
--   into a diagram; <tt>strokeLocLoop = stroke . trailLike . mapLoc
--   wrapLoop</tt>.
strokeLocLoop :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail' Loop V2 n) -> QDiagram b V2 n Any

-- | Enumeration of algorithms or "rules" for determining which points lie
--   in the interior of a (possibly self-intersecting) path.
data FillRule

-- | Interior points are those with a nonzero <i>winding</i> <i>number</i>.
--   See <a>http://en.wikipedia.org/wiki/Nonzero-rule</a>.
Winding :: FillRule

-- | Interior points are those where a ray extended infinitely in a
--   particular direction crosses the path an odd number of times. See
--   <a>http://en.wikipedia.org/wiki/Even-odd_rule</a>.
EvenOdd :: FillRule

-- | Specify the fill rule that should be used for determining which points
--   are inside a path.
fillRule :: HasStyle a => FillRule -> a -> a

-- | Lens onto the fill rule of a style.
_fillRule :: forall n f. Functor f => (FillRule -> f FillRule) -> Style V2 n -> f (Style V2 n)

-- | A record of options that control how a path is stroked.
--   <tt>StrokeOpts</tt> is an instance of <a>Default</a>, so a
--   <tt>StrokeOpts</tt> records can be created using <tt><tt>with</tt> {
--   ... }</tt> notation.
data StrokeOpts a
StrokeOpts :: [[a]] -> FillRule -> StrokeOpts a
[_vertexNames] :: StrokeOpts a -> [[a]]
[_queryFillRule] :: StrokeOpts a -> FillRule

-- | Atomic names that should be assigned to the vertices of the path so
--   that they can be referenced later. If there are not enough names, the
--   extra vertices are not assigned names; if there are too many, the
--   extra names are ignored. Note that this is a <i>list of lists</i> of
--   names, since paths can consist of multiple trails. The first list of
--   names are assigned to the vertices of the first trail, the second list
--   to the second trail, and so on.
--   
--   The default value is the empty list.
vertexNames :: forall a a' f. Functor f => ([[a]] -> f [[a']]) -> StrokeOpts a -> f (StrokeOpts a')

-- | The fill rule used for determining which points are inside the path.
--   The default is <a>Winding</a>. NOTE: for now, this only affects the
--   resulting diagram's <a>Query</a>, <i>not</i> how it will be drawn! To
--   set the fill rule determining how it is to be drawn, use the
--   <a>fillRule</a> function.
queryFillRule :: forall a f. Functor f => (FillRule -> f FillRule) -> StrokeOpts a -> f (StrokeOpts a)

-- | Find the intersect points of two objects that can be converted to a
--   path.
intersectPoints :: (InSpace V2 n t, SameSpace t s, ToPath t, ToPath s, OrderedField n) => t -> s -> [P2 n]

-- | Find the intersect points of two objects that can be converted to a
--   path within the given tolerance.
intersectPoints' :: (InSpace V2 n t, SameSpace t s, ToPath t, ToPath s, OrderedField n) => n -> t -> s -> [P2 n]

-- | Compute the intersect points between two paths.
intersectPointsP :: OrderedField n => Path V2 n -> Path V2 n -> [P2 n]

-- | Compute the intersect points between two paths within given tolerance.
intersectPointsP' :: OrderedField n => n -> Path V2 n -> Path V2 n -> [P2 n]

-- | Compute the intersect points between two located trails.
intersectPointsT :: OrderedField n => Located (Trail V2 n) -> Located (Trail V2 n) -> [P2 n]

-- | Compute the intersect points between two located trails within the
--   given tolerance.
intersectPointsT' :: OrderedField n => n -> Located (Trail V2 n) -> Located (Trail V2 n) -> [P2 n]

-- | Clip a diagram by the given path:
--   
--   <ul>
--   <li>Only the parts of the diagram which lie in the interior of the
--   path will be drawn.</li>
--   <li>The envelope of the diagram is unaffected.</li>
--   </ul>
clipBy :: (HasStyle a, V a ~ V2, N a ~ n, TypeableFloat n) => Path V2 n -> a -> a

-- | Clip a diagram to the given path setting its envelope to the pointwise
--   minimum of the envelopes of the diagram and path. The trace consists
--   of those parts of the original diagram's trace which fall within the
--   clipping path, or parts of the path's trace within the original
--   diagram.
clipTo :: TypeableFloat n => Path V2 n -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Clip a diagram to the clip path taking the envelope and trace of the
--   clip path.
clipped :: TypeableFloat n => Path V2 n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
_Clip :: forall n n' p f. (Profunctor p, Functor f) => p [Path V2 n] (f [Path V2 n']) -> p (Clip n) (f (Clip n'))

-- | Lens onto the Clip in a style. An empty list means no clipping.
_clip :: (Typeable n, OrderedField n) => Lens' (Style V2 n) [Path V2 n]

-- | Create a centered horizontal (L-R) line of the given length.
--   
--   
--   <pre>
--   hruleEx = vcat' (with &amp; sep .~ 0.2) (map hrule [1..5])
--           # centerXY # pad 1.1
--   </pre>
hrule :: (InSpace V2 n t, TrailLike t) => n -> t

-- | Create a centered vertical (T-B) line of the given length.
--   
--   
--   <pre>
--   vruleEx = hcat' (with &amp; sep .~ 0.2) (map vrule [1, 1.2 .. 2])
--           # centerXY # pad 1.1
--   </pre>
vrule :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A circle of radius 1, with center at the origin.
unitCircle :: (TrailLike t, V t ~ V2, N t ~ n) => t

-- | A circle of the given radius, centered at the origin. As a path, it
--   begins at (r,0).
circle :: (TrailLike t, V t ~ V2, N t ~ n, Transformable t) => n -> t

-- | <tt>ellipse e</tt> constructs an ellipse with eccentricity <tt>e</tt>
--   by scaling the unit circle in the X direction. The eccentricity must
--   be within the interval [0,1).
ellipse :: (TrailLike t, V t ~ V2, N t ~ n, Transformable t) => n -> t

-- | <tt>ellipseXY x y</tt> creates an axis-aligned ellipse, centered at
--   the origin, with radius <tt>x</tt> along the x-axis and radius
--   <tt>y</tt> along the y-axis.
ellipseXY :: (TrailLike t, V t ~ V2, N t ~ n, Transformable t) => n -> n -> t

-- | Given a start direction <tt>d</tt> and a sweep angle <tt>s</tt>,
--   <tt><a>arc</a> d s</tt> is the path of a radius one arc starting at
--   <tt>d</tt> and sweeping out the angle <tt>s</tt> counterclockwise (for
--   positive s). The resulting <tt>Trail</tt> is allowed to wrap around
--   and overlap itself.
arc :: (InSpace V2 n t, OrderedField n, TrailLike t) => Direction V2 n -> Angle n -> t

-- | Given a radus <tt>r</tt>, a start direction <tt>d</tt> and an angle
--   <tt>s</tt>, <tt><a>arc'</a> r d s</tt> is the path of a radius
--   <tt>(abs r)</tt> arc starting at <tt>d</tt> and sweeping out the angle
--   <tt>s</tt> counterclockwise (for positive s). The origin of the arc is
--   its center.
--   
--   
--   <pre>
--   arc'Ex = mconcat [ arc' r xDir (1/4 @@ turn) | r &lt;- [0.5,-1,1.5] ]
--          # centerXY # pad 1.1
--   </pre>
arc' :: (InSpace V2 n t, OrderedField n, TrailLike t) => n -> Direction V2 n -> Angle n -> t

-- | Like <tt>arcAngleCCW</tt> but clockwise.
arcCW :: (InSpace V2 n t, RealFloat n, TrailLike t) => Direction V2 n -> Direction V2 n -> t

-- | Given a start direction <tt>s</tt> and end direction <tt>e</tt>,
--   <tt>arcCCW s e</tt> is the path of a radius one arc counterclockwise
--   between the two directions. The origin of the arc is its center.
arcCCW :: (InSpace V2 n t, RealFloat n, TrailLike t) => Direction V2 n -> Direction V2 n -> t

-- | Create a circular wedge of the given radius, beginning at the given
--   direction and extending through the given angle.
--   
--   
--   <pre>
--   wedgeEx = hcat' (with &amp; sep .~ 0.5)
--     [ wedge 1 xDir (1/4 @@ turn)
--     , wedge 1 (rotate (7/30 @@ turn) xDir) (4/30 @@ turn)
--     , wedge 1 (rotate (1/8 @@ turn) xDir) (3/4 @@ turn)
--     ]
--     # fc blue
--     # centerXY # pad 1.1
--   </pre>
wedge :: (InSpace V2 n t, OrderedField n, TrailLike t) => n -> Direction V2 n -> Angle n -> t

-- | <tt>arcBetween p q height</tt> creates an arc beginning at <tt>p</tt>
--   and ending at <tt>q</tt>, with its midpoint at a distance of <tt>abs
--   height</tt> away from the straight line from <tt>p</tt> to <tt>q</tt>.
--   A positive value of <tt>height</tt> results in an arc to the left of
--   the line from <tt>p</tt> to <tt>q</tt>; a negative value yields one to
--   the right.
--   
--   
--   <pre>
--   arcBetweenEx = mconcat
--     [ arcBetween origin (p2 (2,1)) ht | ht &lt;- [-0.2, -0.1 .. 0.2] ]
--     # centerXY # pad 1.1
--   </pre>
arcBetween :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => Point V2 n -> Point V2 n -> n -> t

-- | Create an annular wedge of the given radii, beginning at the first
--   direction and extending through the given sweep angle. The radius of
--   the outer circle is given first.
--   
--   
--   <pre>
--   annularWedgeEx = hsep 0.50
--     [ annularWedge 1 0.5 xDir (1/4 @@ turn)
--     , annularWedge 1 0.3 (rotate (7/30 @@ turn) xDir) (4/30 @@ turn)
--     , annularWedge 1 0.7 (rotate (1/8 @@ turn) xDir) (3/4 @@ turn)
--     ]
--     # fc blue
--     # centerXY # pad 1.1
--   </pre>
annularWedge :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => n -> n -> Direction V2 n -> Angle n -> t

-- | Generate the polygon described by the given options.
polygon :: (InSpace V2 n t, TrailLike t) => PolygonOpts n -> t

-- | Generate a polygon. See <a>PolygonOpts</a> for more information.
polyTrail :: OrderedField n => PolygonOpts n -> Located (Trail V2 n)

-- | Options for specifying a polygon.
data PolygonOpts n
PolygonOpts :: PolyType n -> PolyOrientation n -> Point V2 n -> PolygonOpts n
[_polyType] :: PolygonOpts n -> PolyType n
[_polyOrient] :: PolygonOpts n -> PolyOrientation n
[_polyCenter] :: PolygonOpts n -> Point V2 n

-- | Specification for the polygon's vertices.
polyType :: forall n f. Functor f => (PolyType n -> f (PolyType n)) -> PolygonOpts n -> f (PolygonOpts n)

-- | Should a rotation be applied to the polygon in order to orient it in a
--   particular way?
polyOrient :: forall n f. Functor f => (PolyOrientation n -> f (PolyOrientation n)) -> PolygonOpts n -> f (PolygonOpts n)

-- | Should a translation be applied to the polygon in order to place the
--   center at a particular location?
polyCenter :: forall n f. Functor f => (Point V2 n -> f (Point V2 n)) -> PolygonOpts n -> f (PolygonOpts n)

-- | Method used to determine the vertices of a polygon.
data PolyType n

-- | A "polar" polygon.
--   
--   <ul>
--   <li>The first argument is a list of <i>central</i> <i>angles</i> from
--   each vertex to the next.</li>
--   <li>The second argument is a list of <i>radii</i> from the origin to
--   each successive vertex.</li>
--   </ul>
--   
--   To construct an <i>n</i>-gon, use a list of <i>n-1</i> angles and
--   <i>n</i> radii. Extra angles or radii are ignored.
--   
--   Cyclic polygons (with all vertices lying on a circle) can be
--   constructed using a second argument of <tt>(repeat r)</tt>.
PolyPolar :: [Angle n] -> [n] -> PolyType n

-- | A polygon determined by the distance between successive vertices and
--   the external angles formed by each three successive vertices. In other
--   words, a polygon specified by "turtle graphics": go straight ahead x1
--   units; turn by external angle a1; go straight ahead x2 units; turn by
--   external angle a2; etc. The polygon will be centered at the
--   <i>centroid</i> of its vertices.
--   
--   <ul>
--   <li>The first argument is a list of <i>vertex</i> <i>angles</i>,
--   giving the external angle at each vertex from the previous vertex to
--   the next. The first angle in the list is the external angle at the
--   <i>second</i> vertex; the first edge always starts out heading in the
--   positive y direction from the first vertex.</li>
--   <li>The second argument is a list of distances between successive
--   vertices.</li>
--   </ul>
--   
--   To construct an <i>n</i>-gon, use a list of <i>n-2</i> angles and
--   <i>n-1</i> edge lengths. Extra angles or lengths are ignored.
PolySides :: [Angle n] -> [n] -> PolyType n

-- | A regular polygon with the given number of sides (first argument) and
--   the given radius (second argument).
PolyRegular :: Int -> n -> PolyType n

-- | Determine how a polygon should be oriented.
data PolyOrientation n

-- | No special orientation; the first vertex will be at (1,0).
NoOrient :: PolyOrientation n

-- | Orient <i>horizontally</i>, so the bottommost edge is parallel to the
--   x-axis. This is the default.
OrientH :: PolyOrientation n

-- | Orient <i>vertically</i>, so the leftmost edge is parallel to the
--   y-axis.
OrientV :: PolyOrientation n

-- | Orient so some edge is <i>facing</i> <i>in</i> <i>the</i>
--   <i>direction</i> <i>of</i>, that is, perpendicular to, the given
--   vector.
OrientTo :: V2 n -> PolyOrientation n

-- | Options for creating "star" polygons, where the edges connect possibly
--   non-adjacent vertices.
data StarOpts

-- | Specify the order in which the vertices should be connected by a
--   function that maps each vertex index to the index of the vertex that
--   should come next. Indexing of vertices begins at 0.
StarFun :: (Int -> Int) -> StarOpts

-- | Specify a star polygon by a "skip". A skip of 1 indicates a normal
--   polygon, where edges go between successive vertices. A skip of 2 means
--   that edges will connect every second vertex, skipping one in between.
--   Generally, a skip of <i>n</i> means that edges will connect every
--   <i>n</i>th vertex.
StarSkip :: Int -> StarOpts

-- | Create a generalized <i>star</i> <i>polygon</i>. The <a>StarOpts</a>
--   are used to determine in which order the given vertices should be
--   connected. The intention is that the second argument of type
--   <tt>[Point v]</tt> could be generated by a call to <a>polygon</a>,
--   <tt>regPoly</tt>, or the like, since a list of vertices is
--   <a>TrailLike</a>. But of course the list can be generated any way you
--   like. A <tt><a>Path</a> <tt>v</tt></tt> is returned (instead of any
--   <a>TrailLike</a>) because the resulting path may have more than one
--   component, for example if the vertices are to be connected in several
--   disjoint cycles.
star :: OrderedField n => StarOpts -> [Point V2 n] -> Path V2 n

-- | Create a regular polygon. The first argument is the number of sides,
--   and the second is the <i>length</i> of the sides. (Compare to the
--   <a>polygon</a> function with a <a>PolyRegular</a> option, which
--   produces polygons of a given <i>radius</i>).
--   
--   The polygon will be oriented with one edge parallel to the x-axis.
regPoly :: (InSpace V2 n t, TrailLike t) => Int -> n -> t

-- | An equilateral triangle, with sides of the given length and base
--   parallel to the x-axis.
--   
triangle :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A synonym for <a>triangle</a>, provided for backwards compatibility.
eqTriangle :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A square with its center at the origin and sides of the given length,
--   oriented parallel to the axes.
--   
square :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A regular pentagon, with sides of the given length and base parallel
--   to the x-axis.
--   
pentagon :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A regular hexagon, with sides of the given length and base parallel to
--   the x-axis.
--   
hexagon :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A regular heptagon, with sides of the given length and base parallel
--   to the x-axis.
--   
heptagon :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A synonym for <a>heptagon</a>. It is, however, completely inferior,
--   being a base admixture of the Latin <i>septum</i> (seven) and the
--   Greek γωνία (angle).
septagon :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A regular octagon, with sides of the given length and base parallel to
--   the x-axis.
--   
octagon :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A regular nonagon, with sides of the given length and base parallel to
--   the x-axis.
--   
nonagon :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A regular decagon, with sides of the given length and base parallel to
--   the x-axis.
--   
decagon :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A regular hendecagon, with sides of the given length and base parallel
--   to the x-axis.
--   
hendecagon :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A regular dodecagon, with sides of the given length and base parallel
--   to the x-axis.
--   
dodecagon :: (InSpace V2 n t, TrailLike t) => n -> t

-- | A square with its center at the origin and sides of length 1, oriented
--   parallel to the axes.
--   
unitSquare :: (InSpace V2 n t, TrailLike t) => t

-- | <tt>rect w h</tt> is an axis-aligned rectangle of width <tt>w</tt> and
--   height <tt>h</tt>, centered at the origin.
--   
rect :: (InSpace V2 n t, TrailLike t) => n -> n -> t

-- | <tt>roundedRect w h r</tt> generates a closed trail, or closed path
--   centered at the origin, of an axis-aligned rectangle with width
--   <tt>w</tt>, height <tt>h</tt>, and circular rounded corners of radius
--   <tt>r</tt>. If <tt>r</tt> is negative the corner will be cut out in a
--   reverse arc. If the size of <tt>r</tt> is larger than half the smaller
--   dimension of <tt>w</tt> and <tt>h</tt>, then it will be reduced to fit
--   in that range, to prevent the corners from overlapping. The trail or
--   path begins with the right edge and proceeds counterclockwise. If you
--   need to specify a different radius for each corner individually, use
--   <a>roundedRect'</a> instead.
--   
--   
--   <pre>
--   roundedRectEx = pad 1.1 . centerXY $ hcat' (with &amp; sep .~ 0.2)
--     [ roundedRect  0.5 0.4 0.1
--     , roundedRect  0.5 0.4 (-0.1)
--     , roundedRect' 0.7 0.4 (with &amp; radiusTL .~ 0.2
--                                  &amp; radiusTR .~ -0.2
--                                  &amp; radiusBR .~ 0.1)
--     ]
--   </pre>
roundedRect :: (InSpace V2 n t, TrailLike t, RealFloat n) => n -> n -> n -> t

-- | <tt>roundedRect'</tt> works like <tt>roundedRect</tt> but allows you
--   to set the radius of each corner indivually, using
--   <tt>RoundedRectOpts</tt>. The default corner radius is 0. Each radius
--   can also be negative, which results in the curves being reversed to be
--   inward instead of outward.
roundedRect' :: (InSpace V2 n t, TrailLike t, RealFloat n) => n -> n -> RoundedRectOpts n -> t
data RoundedRectOpts d
RoundedRectOpts :: d -> d -> d -> d -> RoundedRectOpts d
[_radiusTL] :: RoundedRectOpts d -> d
[_radiusTR] :: RoundedRectOpts d -> d
[_radiusBL] :: RoundedRectOpts d -> d
[_radiusBR] :: RoundedRectOpts d -> d
radiusTL :: forall d f. Functor f => (d -> f d) -> RoundedRectOpts d -> f (RoundedRectOpts d)
radiusTR :: forall d f. Functor f => (d -> f d) -> RoundedRectOpts d -> f (RoundedRectOpts d)
radiusBL :: forall d f. Functor f => (d -> f d) -> RoundedRectOpts d -> f (RoundedRectOpts d)
radiusBR :: forall d f. Functor f => (d -> f d) -> RoundedRectOpts d -> f (RoundedRectOpts d)

-- | <tt>arrowV v</tt> creates an arrow with the direction and norm of the
--   vector <tt>v</tt> (with its tail at the origin), using default
--   parameters.
arrowV :: (TypeableFloat n, Renderable (Path V2 n) b) => V2 n -> QDiagram b V2 n Any

-- | <tt>arrowV' v</tt> creates an arrow with the direction and norm of the
--   vector <tt>v</tt> (with its tail at the origin).
arrowV' :: (TypeableFloat n, Renderable (Path V2 n) b) => ArrowOpts n -> V2 n -> QDiagram b V2 n Any

-- | Create an arrow starting at s with length and direction determined by
--   the vector v.
arrowAt :: (TypeableFloat n, Renderable (Path V2 n) b) => Point V2 n -> V2 n -> QDiagram b V2 n Any
arrowAt' :: (TypeableFloat n, Renderable (Path V2 n) b) => ArrowOpts n -> Point V2 n -> V2 n -> QDiagram b V2 n Any

-- | <tt>arrowBetween s e</tt> creates an arrow pointing from <tt>s</tt> to
--   <tt>e</tt> with default parameters.
arrowBetween :: (TypeableFloat n, Renderable (Path V2 n) b) => Point V2 n -> Point V2 n -> QDiagram b V2 n Any

-- | <tt>arrowBetween' opts s e</tt> creates an arrow pointing from
--   <tt>s</tt> to <tt>e</tt> using the given options. In particular, it
--   scales and rotates <tt>arrowShaft</tt> to go between <tt>s</tt> and
--   <tt>e</tt>, taking head, tail, and gaps into account.
arrowBetween' :: (TypeableFloat n, Renderable (Path V2 n) b) => ArrowOpts n -> Point V2 n -> Point V2 n -> QDiagram b V2 n Any

-- | Connect two diagrams with a straight arrow.
connect :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => n1 -> n2 -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Connect two diagrams with an arbitrary arrow.
connect' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => ArrowOpts n -> n1 -> n2 -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Connect two diagrams at point on the perimeter of the diagrams,
--   choosen by angle.
connectPerim :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => n1 -> n2 -> Angle n -> Angle n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
connectPerim' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => ArrowOpts n -> n1 -> n2 -> Angle n -> Angle n -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Draw an arrow from diagram named "n1" to diagram named "n2". The arrow
--   lies on the line between the centres of the diagrams, but is drawn so
--   that it stops at the boundaries of the diagrams, using traces to find
--   the intersection points.
connectOutside :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => n1 -> n2 -> QDiagram b V2 n Any -> QDiagram b V2 n Any
connectOutside' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => ArrowOpts n -> n1 -> n2 -> QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | <tt>arrow len</tt> creates an arrow of length <tt>len</tt> with
--   default parameters, starting at the origin and ending at the point
--   <tt>(len,0)</tt>.
arrow :: (TypeableFloat n, Renderable (Path V2 n) b) => n -> QDiagram b V2 n Any

-- | <tt>arrow' opts len</tt> creates an arrow of length <tt>len</tt> using
--   the given options, starting at the origin and ending at the point
--   <tt>(len,0)</tt>. In particular, it scales the given <a>arrowShaft</a>
--   so that the entire arrow has length <tt>len</tt>.
arrow' :: (TypeableFloat n, Renderable (Path V2 n) b) => ArrowOpts n -> n -> QDiagram b V2 n Any

-- | Straight line arrow shaft.
straightShaft :: OrderedField n => Trail V2 n
data ArrowOpts n
ArrowOpts :: ArrowHT n -> ArrowHT n -> Trail V2 n -> Measure n -> Measure n -> Style V2 n -> Measure n -> Style V2 n -> Measure n -> Style V2 n -> ArrowOpts n
[_arrowHead] :: ArrowOpts n -> ArrowHT n
[_arrowTail] :: ArrowOpts n -> ArrowHT n
[_arrowShaft] :: ArrowOpts n -> Trail V2 n
[_headGap] :: ArrowOpts n -> Measure n
[_tailGap] :: ArrowOpts n -> Measure n
[_headStyle] :: ArrowOpts n -> Style V2 n
[_headLength] :: ArrowOpts n -> Measure n
[_tailStyle] :: ArrowOpts n -> Style V2 n
[_tailLength] :: ArrowOpts n -> Measure n
[_shaftStyle] :: ArrowOpts n -> Style V2 n

-- | A shape to place at the head of the arrow.
arrowHead :: forall n f. Functor f => (ArrowHT n -> f (ArrowHT n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | A shape to place at the tail of the arrow.
arrowTail :: forall n f. Functor f => (ArrowHT n -> f (ArrowHT n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | The trail to use for the arrow shaft.
arrowShaft :: forall n f. Functor f => (Trail V2 n -> f (Trail V2 n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | Distance to leave between the head and the target point.
headGap :: forall n f. Functor f => (Measure n -> f (Measure n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | Distance to leave between the starting point and the tail.
tailGap :: forall n f. Functor f => (Measure n -> f (Measure n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | Set both the <tt>headGap</tt> and <tt>tailGap</tt> simultaneously.
gaps :: forall n f. Applicative f => (Measure n -> f (Measure n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | Same as gaps, provided for backward compatiiblity.
gap :: forall n f. Applicative f => (Measure n -> f (Measure n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | A lens for setting or modifying the texture of an arrowhead. For
--   example, one may write <tt>... (with &amp; headTexture .~ grad)</tt>
--   to get an arrow with a head filled with a gradient, assuming grad has
--   been defined. Or <tt>... (with &amp; headTexture .~ solid blue</tt> to
--   set the head color to blue. For more general control over the style of
--   arrowheads, see <a>headStyle</a>.
headTexture :: TypeableFloat n => Lens' (ArrowOpts n) (Texture n)

-- | Style to apply to the head. <tt>headStyle</tt> is modified by using
--   the lens combinator <tt>%~</tt> to change the current style. For
--   example, to change an opaque black arrowhead to translucent orange:
--   <tt>(with &amp; headStyle %~ fc orange . opacity 0.75)</tt>.
headStyle :: forall n f. Functor f => (Style V2 n -> f (Style V2 n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | A lens for setting or modifying the texture of an arrow tail. This is
--   *not* a valid lens (see <a>committed</a>).
tailTexture :: TypeableFloat n => Lens' (ArrowOpts n) (Texture n)

-- | Style to apply to the tail. See <a>headStyle</a>.
tailStyle :: forall n f. Functor f => (Style V2 n -> f (Style V2 n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | A lens for setting or modifying the texture of an arrow shaft.
shaftTexture :: TypeableFloat n => Lens' (ArrowOpts n) (Texture n)

-- | Style to apply to the shaft. See <a>headStyle</a>.
shaftStyle :: forall n f. Functor f => (Style V2 n -> f (Style V2 n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | The length from the start of the joint to the tip of the head.
headLength :: forall n f. Functor f => (Measure n -> f (Measure n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | The length of the tail plus its joint.
tailLength :: forall n f. Functor f => (Measure n -> f (Measure n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | Set both the <tt>headLength</tt> and <tt>tailLength</tt>
--   simultaneously.
lengths :: forall n f. Applicative f => (Measure n -> f (Measure n)) -> ArrowOpts n -> f (ArrowOpts n)

-- | Create a primitive text diagram from the given string, with center
--   alignment, equivalent to <tt><a>alignedText</a> 0.5 0.5</tt>.
--   
--   Note that it <i>takes up no space</i>, as text size information is not
--   available.
text :: (TypeableFloat n, Renderable (Text n) b) => String -> QDiagram b V2 n Any

-- | Create a primitive text diagram from the given string, origin at the
--   top left corner of the text's bounding box, equivalent to
--   <tt><a>alignedText</a> 0 1</tt>.
--   
--   Note that it <i>takes up no space</i>.
topLeftText :: (TypeableFloat n, Renderable (Text n) b) => String -> QDiagram b V2 n Any

-- | Create a primitive text diagram from the given string, with the origin
--   set to a point interpolated within the bounding box. The first
--   parameter varies from 0 (left) to 1 (right), and the second parameter
--   from 0 (bottom) to 1 (top). Some backends do not implement this and
--   instead snap to closest corner or the center.
--   
--   The height of this box is determined by the font's potential ascent
--   and descent, rather than the height of the particular string.
--   
--   Note that it <i>takes up no space</i>.
alignedText :: (TypeableFloat n, Renderable (Text n) b) => n -> n -> String -> QDiagram b V2 n Any

-- | Create a primitive text diagram from the given string, with the origin
--   set to be on the baseline, at the beginning (although not bounding).
--   This is the reference point of showText in the Cairo graphics library.
--   
--   Note that it <i>takes up no space</i>.
baselineText :: (TypeableFloat n, Renderable (Text n) b) => String -> QDiagram b V2 n Any

-- | Specify a font family to be used for all text within a diagram.
font :: HasStyle a => String -> a -> a

-- | Set all text in italics.
italic :: HasStyle a => a -> a

-- | Set all text using an oblique slant.
oblique :: HasStyle a => a -> a

-- | Set the font size, that is, the size of the font's em-square as
--   measured within the current local vector space. The default size is
--   <tt>local 1</tt> (which is applied by <a>recommendFontSize</a>).
fontSize :: (N a ~ n, Typeable n, HasStyle a) => Measure n -> a -> a

-- | Set all text using a bold font weight.
bold :: HasStyle a => a -> a

-- | Set all text to be bolder than the inherited font weight.
bolder :: HasStyle a => a -> a

-- | Set all text to be lighter than the inherited font weight.
lighter :: HasStyle a => a -> a

-- | Set all text using a thin font weight.
thinWeight :: HasStyle a => a -> a

-- | Set all text using a extra light font weight.
ultraLight :: HasStyle a => a -> a

-- | Set all text using a light font weight.
light :: HasStyle a => a -> a

-- | Set all text using a medium font weight.
mediumWeight :: HasStyle a => a -> a

-- | Set all text using a heavy/black font weight.
heavy :: HasStyle a => a -> a

-- | Set all text using a semi-bold font weight.
semiBold :: HasStyle a => a -> a

-- | Set all text using an ultra-bold font weight.
ultraBold :: HasStyle a => a -> a

-- | Lens onto the font name of a style.
_font :: forall (v :: Type -> Type) n f. Functor f => (Maybe String -> f (Maybe String)) -> Style v n -> f (Style v n)
_fontSizeR :: forall n (v :: Type -> Type). (Typeable n, OrderedField n) => Lens' (Style v n) (Measured n (Recommend n))

-- | Lens to commit a font size. This is *not* a valid lens (see
--   <tt>commited</tt>.
_fontSize :: forall n (v :: Type -> Type). (Typeable n, OrderedField n) => Lens' (Style v n) (Measure n)

-- | A convenient synonym for 'fontSize (Output w)'.
fontSizeO :: (N a ~ n, Typeable n, HasStyle a) => n -> a -> a

-- | A convenient sysnonym for 'fontSize (Local w)'.
fontSizeL :: (N a ~ n, Typeable n, Num n, HasStyle a) => n -> a -> a

-- | A convenient synonym for 'fontSize (Normalized w)'.
fontSizeN :: (N a ~ n, Typeable n, Num n, HasStyle a) => n -> a -> a

-- | A convenient synonym for 'fontSize (Global w)'.
fontSizeG :: (N a ~ n, Typeable n, Num n, HasStyle a) => n -> a -> a

-- | An image primitive, the two ints are width followed by height. Will
--   typically be created by <tt>loadImageEmb</tt> or <tt>loadImageExt</tt>
--   which, will handle setting the width and height to the actual width
--   and height of the image.
data DImage a b
[DImage] :: forall b a. ImageData b -> Int -> Int -> Transformation V2 a -> DImage a b

-- | <a>ImageData</a> is either a JuicyPixels <tt>DynamicImage</tt> tagged
--   as <a>Embedded</a> or a reference tagged as <a>External</a>.
--   Additionally <a>Native</a> is provided for external libraries to hook
--   into.
data ImageData a
[ImageRaster] :: DynamicImage -> ImageData Embedded
[ImageRef] :: FilePath -> ImageData External
[ImageNative] :: forall t. t -> ImageData (Native t)
data Embedded
data External
data Native t

-- | Make a <a>DImage</a> into a <a>Diagram</a>.
image :: (TypeableFloat n, Typeable a, Renderable (DImage n a) b) => DImage n a -> QDiagram b V2 n Any

-- | Use JuicyPixels to read a file in any format and wrap it in a
--   <a>DImage</a>. The width and height of the image are set to their
--   actual values.
loadImageEmb :: Num n => FilePath -> IO (Either String (DImage n Embedded))

-- | Check that a file exists, and use JuicyPixels to figure out the right
--   size, but save a reference to the image instead of the raster data
loadImageExt :: Num n => FilePath -> IO (Either String (DImage n External))

-- | Make an "unchecked" image reference; have to specify a width and
--   height. Unless the aspect ratio of the external image is the w :: h,
--   then the image will be distorted.
uncheckedImageRef :: Num n => FilePath -> Int -> Int -> DImage n External

-- | Create an image "from scratch" by specifying the pixel data
raster :: Num n => (Int -> Int -> AlphaColour Double) -> Int -> Int -> DImage n Embedded

-- | Crate a diagram from raw raster data.
rasterDia :: (TypeableFloat n, Renderable (DImage n Embedded) b) => (Int -> Int -> AlphaColour Double) -> Int -> Int -> QDiagram b V2 n Any

-- | Create a transformation which performs a rotation about the local
--   origin by the given angle. See also <a>rotate</a>.
rotation :: Floating n => Angle n -> Transformation V2 n

-- | Rotate about the local origin by the given angle. Positive angles
--   correspond to counterclockwise rotation, negative to clockwise. The
--   angle can be expressed using any of the <tt>Iso</tt>s on <a>Angle</a>.
--   For example, <tt>rotate (1/4 @@ <a>turn</a>)</tt>, <tt>rotate (tau/4
--   @@ rad)</tt>, and <tt>rotate (90 @@ deg)</tt> all represent the same
--   transformation, namely, a counterclockwise rotation by a right angle.
--   To rotate about some point other than the local origin, see
--   <tt>rotateAbout</tt>.
--   
--   Note that writing <tt>rotate (1/4)</tt>, with no <a>Angle</a>
--   constructor, will yield an error since GHC cannot figure out which
--   sort of angle you want to use. In this common situation you can use
--   <tt>rotateBy</tt>, which interprets its argument as a number of turns.
rotate :: (InSpace V2 n t, Transformable t, Floating n) => Angle n -> t -> t

-- | A synonym for <a>rotate</a>, interpreting its argument in units of
--   turns; it can be more convenient to write <tt>rotateBy (1/4)</tt> than
--   <tt><a>rotate</a> (1/4 @@ <a>turn</a>)</tt>.
rotateBy :: (InSpace V2 n t, Transformable t, Floating n) => n -> t -> t

-- | Use an <a>Angle</a> to make an <a>Iso</a> between an object rotated
--   and unrotated. This us useful for performing actions <a>under</a> a
--   rotation:
--   
--   <pre>
--   under (rotated t) f = rotate (negated t) . f . rotate t
--   rotated t ## a      = rotate t a
--   a ^. rotated t      = rotate (-t) a
--   over (rotated t) f  = rotate t . f . rotate (negated t)
--   </pre>
rotated :: (InSpace V2 n a, Floating n, SameSpace a b, Transformable a, Transformable b) => Angle n -> Iso a b a b

-- | <tt>rotationAbout p</tt> is a rotation about the point <tt>p</tt>
--   (instead of around the local origin).
rotationAround :: Floating n => P2 n -> Angle n -> T2 n

-- | <tt>rotateAbout p</tt> is like <a>rotate</a>, except it rotates around
--   the point <tt>p</tt> instead of around the local origin.
rotateAround :: (InSpace V2 n t, Transformable t, Floating n) => P2 n -> Angle n -> t -> t

-- | The rotation that aligns the x-axis with the given direction.
rotationTo :: OrderedField n => Direction V2 n -> T2 n

-- | Rotate around the local origin such that the x axis aligns with the
--   given direction.
rotateTo :: (InSpace V2 n t, OrderedField n, Transformable t) => Direction V2 n -> t -> t

-- | Construct a transformation which scales by the given factor in the x
--   (horizontal) direction.
scalingX :: forall (v :: Type -> Type) n. (Additive v, R1 v, Fractional n) => n -> Transformation v n

-- | Scale a diagram by the given factor in the x (horizontal) direction.
--   To scale uniformly, use <a>scale</a>.
scaleX :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Fractional n, Transformable t) => n -> t -> t

-- | Construct a transformation which scales by the given factor in the y
--   (vertical) direction.
scalingY :: forall (v :: Type -> Type) n. (Additive v, R2 v, Fractional n) => n -> Transformation v n

-- | Scale a diagram by the given factor in the y (vertical) direction. To
--   scale uniformly, use <a>scale</a>.
scaleY :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Fractional n, Transformable t) => n -> t -> t

-- | Create a uniform scaling transformation.
scaling :: forall (v :: Type -> Type) n. (Additive v, Fractional n) => n -> Transformation v n

-- | Scale uniformly in every dimension by the given scalar.
scale :: forall (v :: Type -> Type) n a. (InSpace v n a, Eq n, Fractional n, Transformable a) => n -> a -> a

-- | <tt>scaleToX w</tt> scales a diagram in the x (horizontal) direction
--   by whatever factor required to make its width <tt>w</tt>.
--   <tt>scaleToX</tt> should not be applied to diagrams with a width of 0,
--   such as <tt>vrule</tt>.
scaleToX :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Enveloped t, Transformable t) => n -> t -> t

-- | <tt>scaleToY h</tt> scales a diagram in the y (vertical) direction by
--   whatever factor required to make its height <tt>h</tt>.
--   <tt>scaleToY</tt> should not be applied to diagrams with a height of
--   0, such as <tt>hrule</tt>.
scaleToY :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Enveloped t, Transformable t) => n -> t -> t

-- | <tt>scaleUToX w</tt> scales a diagram <i>uniformly</i> by whatever
--   factor required to make its width <tt>w</tt>. <tt>scaleUToX</tt>
--   should not be applied to diagrams with a width of 0, such as
--   <tt>vrule</tt>.
scaleUToX :: forall (v :: Type -> Type) n t. (InSpace v n t, R1 v, Enveloped t, Transformable t) => n -> t -> t

-- | <tt>scaleUToY h</tt> scales a diagram <i>uniformly</i> by whatever
--   factor required to make its height <tt>h</tt>. <tt>scaleUToY</tt>
--   should not be applied to diagrams with a height of 0, such as
--   <tt>hrule</tt>.
scaleUToY :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Enveloped t, Transformable t) => n -> t -> t

-- | Construct a transformation which translates by the given distance in
--   the x (horizontal) direction.
translationX :: forall (v :: Type -> Type) n. (Additive v, R1 v, Num n) => n -> Transformation v n

-- | Translate a diagram by the given distance in the x (horizontal)
--   direction.
translateX :: forall (v :: Type -> Type) n t. (InSpace v n t, R1 v, Transformable t) => n -> t -> t

-- | Construct a transformation which translates by the given distance in
--   the y (vertical) direction.
translationY :: forall (v :: Type -> Type) n. (Additive v, R2 v, Num n) => n -> Transformation v n

-- | Translate a diagram by the given distance in the y (vertical)
--   direction.
translateY :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Transformable t) => n -> t -> t

-- | Create a translation.
translation :: v n -> Transformation v n

-- | Translate by a vector.
translate :: Transformable t => Vn t -> t -> t

-- | The angle-preserving linear map that aligns the x-axis unit vector
--   with the given vector. See also <a>scaleRotateTo</a>.
scalingRotationTo :: Floating n => V2 n -> T2 n

-- | Rotate and uniformly scale around the local origin such that the
--   x-axis aligns with the given vector. This satisfies the equation
--   
--   <pre>
--   scaleRotateTo v = rotateTo (dir v) . scale (norm v)
--   </pre>
--   
--   up to floating point rounding errors, but is more accurate and
--   performant since it avoids cancellable uses of trigonometric
--   functions.
scaleRotateTo :: (InSpace V2 n t, Transformable t, Floating n) => V2 n -> t -> t

-- | Construct a transformation which flips a diagram from left to right,
--   i.e. sends the point (x,y) to (-x,y).
reflectionX :: forall (v :: Type -> Type) n. (Additive v, R1 v, Num n) => Transformation v n

-- | Flip a diagram from left to right, i.e. send the point (x,y) to
--   (-x,y).
reflectX :: forall (v :: Type -> Type) n t. (InSpace v n t, R1 v, Transformable t) => t -> t

-- | Construct a transformation which flips a diagram from top to bottom,
--   i.e. sends the point (x,y) to (x,-y).
reflectionY :: forall (v :: Type -> Type) n. (Additive v, R2 v, Num n) => Transformation v n

-- | Flip a diagram from top to bottom, i.e. send the point (x,y) to
--   (x,-y).
reflectY :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Transformable t) => t -> t

-- | Construct a transformation which flips the diagram about x=y, i.e.
--   sends the point (x,y) to (y,x).
reflectionXY :: forall (v :: Type -> Type) n. (Additive v, R2 v, Num n) => Transformation v n

-- | Flips the diagram about x=y, i.e. send the point (x,y) to (y,x).
reflectXY :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Transformable t) => t -> t

-- | <tt>reflectionAbout p d</tt> is a reflection in the line determined by
--   the point <tt>p</tt> and direction <tt>d</tt>.
reflectionAbout :: OrderedField n => P2 n -> Direction V2 n -> T2 n

-- | <tt>reflectAbout p d</tt> reflects a diagram in the line determined by
--   the point <tt>p</tt> and direction <tt>d</tt>.
reflectAbout :: (InSpace V2 n t, OrderedField n, Transformable t) => P2 n -> Direction V2 n -> t -> t

-- | <tt>shearingX d</tt> is the linear transformation which is the
--   identity on y coordinates and sends <tt>(0,1)</tt> to <tt>(d,1)</tt>.
shearingX :: Num n => n -> T2 n

-- | <tt>shearX d</tt> performs a shear in the x-direction which sends
--   <tt>(0,1)</tt> to <tt>(d,1)</tt>.
shearX :: (InSpace V2 n t, Transformable t) => n -> t -> t

-- | <tt>shearingY d</tt> is the linear transformation which is the
--   identity on x coordinates and sends <tt>(1,0)</tt> to <tt>(1,d)</tt>.
shearingY :: Num n => n -> T2 n

-- | <tt>shearY d</tt> performs a shear in the y-direction which sends
--   <tt>(1,0)</tt> to <tt>(1,d)</tt>.
shearY :: (InSpace V2 n t, Transformable t) => n -> t -> t

-- | The parallel projection onto the plane x=0
parallelX0 :: forall (v :: Type -> Type) n. (R1 v, Num n) => Deformation v v n

-- | The perspective division onto the plane x=1 along lines going through
--   the origin.
perspectiveX1 :: forall (v :: Type -> Type) n. (R1 v, Functor v, Fractional n) => Deformation v v n

-- | The parallel projection onto the plane y=0
parallelY0 :: forall (v :: Type -> Type) n. (R2 v, Num n) => Deformation v v n

-- | The perspective division onto the plane y=1 along lines going through
--   the origin.
perspectiveY1 :: forall (v :: Type -> Type) n. (R2 v, Functor v, Floating n) => Deformation v v n

-- | The viewing transform for a viewer facing along the positive X axis. X
--   coördinates stay fixed, while Y coördinates are compressed with
--   increasing distance. <tt>asDeformation (translation unitX) &lt;&gt;
--   parallelX0 &lt;&gt; frustrumX = perspectiveX1</tt>
facingX :: forall (v :: Type -> Type) n. (R1 v, Functor v, Fractional n) => Deformation v v n
facingY :: forall (v :: Type -> Type) n. (R2 v, Functor v, Fractional n) => Deformation v v n

-- | Place two diagrams (or other objects) vertically adjacent to one
--   another, with the first diagram above the second. Since Haskell
--   ignores whitespace in expressions, one can thus write
--   
--   <pre>
--    c
--   ===
--    d
--   
--   </pre>
--   
--   to place <tt>c</tt> above <tt>d</tt>. The local origin of the
--   resulting combined diagram is the same as the local origin of the
--   first. <tt>(===)</tt> is associative and has <a>mempty</a> as an
--   identity. See the documentation of <a>beside</a> for more information.
(===) :: (InSpace V2 n a, Juxtaposable a, Semigroup a) => a -> a -> a
infixl 6 ===

-- | Place two diagrams (or other juxtaposable objects) horizontally
--   adjacent to one another, with the first diagram to the left of the
--   second. The local origin of the resulting combined diagram is the same
--   as the local origin of the first. <tt>(|||)</tt> is associative and
--   has <a>mempty</a> as an identity. See the documentation of
--   <a>beside</a> for more information.
(|||) :: (InSpace V2 n a, Juxtaposable a, Semigroup a) => a -> a -> a
infixl 6 |||

-- | Lay out a list of juxtaposable objects in a row from left to right, so
--   that their local origins lie along a single horizontal line, with
--   successive envelopes tangent to one another.
--   
--   <ul>
--   <li>For more control over the spacing, see <a>hcat'</a>.</li>
--   <li>To align the diagrams vertically (or otherwise), use alignment
--   combinators (such as <a>alignT</a> or <a>alignB</a>) from
--   <a>Diagrams.TwoD.Align</a> before applying <a>hcat</a>.</li>
--   <li>For non-axis-aligned layout, see <a>cat</a>.</li>
--   </ul>
hcat :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => [a] -> a

-- | A variant of <a>hcat</a> taking an extra <a>CatOpts</a> record to
--   control the spacing. See the <a>cat'</a> documentation for a
--   description of the possibilities. For the common case of setting just
--   a separation amount, see <a>hsep</a>.
hcat' :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => CatOpts n -> [a] -> a

-- | A convenient synonym for horizontal concatenation with separation:
--   <tt>hsep s === hcat' (with &amp; sep .~ s)</tt>.
hsep :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => n -> [a] -> a

-- | Lay out a list of juxtaposable objects in a column from top to bottom,
--   so that their local origins lie along a single vertical line, with
--   successive envelopes tangent to one another.
--   
--   <ul>
--   <li>For more control over the spacing, see <a>vcat'</a>.</li>
--   <li>To align the diagrams horizontally (or otherwise), use alignment
--   combinators (such as <a>alignL</a> or <a>alignR</a>) from
--   <a>Diagrams.TwoD.Align</a> before applying <a>vcat</a>.</li>
--   <li>For non-axis-aligned layout, see <a>cat</a>.</li>
--   </ul>
vcat :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => [a] -> a

-- | A variant of <a>vcat</a> taking an extra <a>CatOpts</a> record to
--   control the spacing. See the <a>cat'</a> documentation for a
--   description of the possibilities. For the common case of setting just
--   a separation amount, see <a>vsep</a>.
vcat' :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => CatOpts n -> [a] -> a

-- | A convenient synonym for vertical concatenation with separation:
--   <tt>vsep s === vcat' (with &amp; sep .~ s)</tt>.
vsep :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => n -> [a] -> a

-- | <tt>strutX w</tt> is an empty diagram with width <tt>w</tt>, height 0,
--   and a centered local origin. Note that <tt>strutX (-w)</tt> behaves
--   the same as <tt>strutX w</tt>.
strutX :: forall (v :: Type -> Type) n b m. (Metric v, R1 v, OrderedField n) => n -> QDiagram b v n m

-- | <tt>strutY h</tt> is an empty diagram with height <tt>h</tt>, width 0,
--   and a centered local origin. Note that <tt>strutY (-h)</tt> behaves
--   the same as <tt>strutY h</tt>.
strutY :: forall (v :: Type -> Type) n b m. (Metric v, R2 v, OrderedField n) => n -> QDiagram b v n m

-- | <tt>padX s</tt> "pads" a diagram in the x-direction, expanding its
--   envelope horizontally by a factor of <tt>s</tt> (factors between 0 and
--   1 can be used to shrink the envelope). Note that the envelope will
--   expand with respect to the local origin, so if the origin is not
--   centered horizontally the padding may appear "uneven". If this is not
--   desired, the origin can be centered (using <a>centerX</a>) before
--   applying <tt>padX</tt>.
padX :: forall (v :: Type -> Type) n m b. (Metric v, R2 v, OrderedField n, Monoid' m) => n -> QDiagram b v n m -> QDiagram b v n m

-- | <tt>padY s</tt> "pads" a diagram in the y-direction, expanding its
--   envelope vertically by a factor of <tt>s</tt> (factors between 0 and 1
--   can be used to shrink the envelope). Note that the envelope will
--   expand with respect to the local origin, so if the origin is not
--   centered vertically the padding may appear "uneven". If this is not
--   desired, the origin can be centered (using <a>centerY</a>) before
--   applying <tt>padY</tt>.
padY :: forall (v :: Type -> Type) m n b. (Metric v, R2 v, Monoid' m, OrderedField n) => n -> QDiagram b v n m -> QDiagram b v n m

-- | <tt>extrudeLeft s</tt> "extrudes" a diagram in the negative
--   x-direction, offsetting its envelope by the provided distance. When
--   <tt> s &lt; 0 </tt>, the envelope is inset instead.
--   
--   See the documentation for <a>extrudeEnvelope</a> for more information.
extrudeLeft :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | <tt>extrudeRight s</tt> "extrudes" a diagram in the positive
--   x-direction, offsetting its envelope by the provided distance. When
--   <tt> s &lt; 0 </tt>, the envelope is inset instead.
--   
--   See the documentation for <a>extrudeEnvelope</a> for more information.
extrudeRight :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | <tt>extrudeBottom s</tt> "extrudes" a diagram in the negative
--   y-direction, offsetting its envelope by the provided distance. When
--   <tt> s &lt; 0 </tt>, the envelope is inset instead.
--   
--   See the documentation for <a>extrudeEnvelope</a> for more information.
extrudeBottom :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | <tt>extrudeTop s</tt> "extrudes" a diagram in the positive
--   y-direction, offsetting its envelope by the provided distance. When
--   <tt> s &lt; 0 </tt>, the envelope is inset instead.
--   
--   See the documentation for <a>extrudeEnvelope</a> for more information.
extrudeTop :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | <tt>rectEnvelope p v</tt> sets the envelope of a diagram to a
--   rectangle whose lower-left corner is at <tt>p</tt> and whose
--   upper-right corner is at <tt>p .+^ v</tt>. Useful for selecting the
--   rectangular portion of a diagram which should actually be "viewed" in
--   the final render, if you don't want to see the entire diagram.
rectEnvelope :: forall b n m. (OrderedField n, Monoid' m) => Point V2 n -> V2 n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | A synonym for <a>rectEnvelope</a>.
crop :: forall b n m. (OrderedField n, Monoid' m) => Point V2 n -> V2 n -> QDiagram b V2 n m -> QDiagram b V2 n m

-- | Construct a bounding rectangle for an enveloped object, that is, the
--   smallest axis-aligned rectangle which encloses the object.
boundingRect :: (InSpace V2 n a, SameSpace a t, Enveloped t, Transformable t, TrailLike t, Monoid t, Enveloped a) => a -> t

-- | "Set the background color" of a diagram. That is, place a diagram atop
--   a bounding rectangle of the given color. The background does not
--   change the result of queries.
bg :: (TypeableFloat n, Renderable (Path V2 n) b, Monoid' q) => Colour Double -> QDiagram b V2 n q -> QDiagram b V2 n q

-- | Similar to <a>bg</a> but makes the colored background rectangle larger
--   than the diagram. The first parameter is used to set how far the
--   background extends beyond the diagram. The background does not change
--   the result of queries.
bgFrame :: (TypeableFloat n, Renderable (Path V2 n) b, Monoid' q) => n -> Colour Double -> QDiagram b V2 n q -> QDiagram b V2 n q

-- | Align along the left edge, i.e. translate the diagram in a horizontal
--   direction so that the local origin is on the left edge of the
--   envelope.
alignL :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Align along the right edge.
alignR :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Align along the top edge.
alignT :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Align along the bottom edge.
alignB :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a
alignTL :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a
alignTR :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a
alignBL :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a
alignBR :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | <tt>alignX</tt> and <tt>snugX</tt> move the local origin horizontally
--   as follows:
--   
--   <ul>
--   <li><tt>alignX (-1)</tt> moves the local origin to the left edge of
--   the boundary;</li>
--   <li><tt>align 1</tt> moves the local origin to the right edge;</li>
--   <li>any other argument interpolates linearly between these. For
--   example, <tt>alignX 0</tt> centers, <tt>alignX 2</tt> moves the origin
--   one "radius" to the right of the right edge, and so on.</li>
--   <li><tt>snugX</tt> works the same way.</li>
--   </ul>
alignX :: forall (v :: Type -> Type) n a. (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a) => n -> a -> a

-- | Like <a>alignX</a>, but moving the local origin vertically, with an
--   argument of <tt>1</tt> corresponding to the top edge and <tt>(-1)</tt>
--   corresponding to the bottom edge.
alignY :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => n -> a -> a

-- | Center the local origin along the X-axis.
centerX :: forall (v :: Type -> Type) n a. (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Center the local origin along the Y-axis.
centerY :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => a -> a

-- | Center along both the X- and Y-axes.
centerXY :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => a -> a
snugL :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugR :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugT :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugB :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a

-- | See the documentation for <a>alignX</a>.
snugX :: forall (v :: Type -> Type) n a. (InSpace v n a, R1 v, Fractional n, Alignable a, Traced a, HasOrigin a) => n -> a -> a

-- | See the documentation for <a>alignY</a>.
snugY :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => n -> a -> a
snugCenterX :: forall (v :: Type -> Type) n a. (InSpace v n a, R1 v, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugCenterY :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a
snugCenterXY :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a

-- | Compute the width of an enveloped object.
--   
--   Note this is just <tt>diameter unitX</tt>.
width :: (InSpace V2 n a, Enveloped a) => a -> n

-- | Compute the height of an enveloped object.
height :: (InSpace V2 n a, Enveloped a) => a -> n

-- | Compute the absolute x-coordinate range of an enveloped object in the
--   form <tt>(lo,hi)</tt>. Return <tt>Nothing</tt> for objects with an
--   empty envelope.
--   
--   Note this is just <tt>extent unitX</tt>.
extentX :: forall (v :: Type -> Type) n a. (InSpace v n a, R1 v, Enveloped a) => a -> Maybe (n, n)

-- | Compute the absolute y-coordinate range of an enveloped object in the
--   form <tt>(lo,hi)</tt>. Return <tt>Nothing</tt> for objects with an
--   empty envelope.
extentY :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Enveloped a) => a -> Maybe (n, n)

-- | Make a <a>SizeSpec</a> from possibly-specified width and height.
mkSizeSpec2D :: Num n => Maybe n -> Maybe n -> SizeSpec V2 n

-- | Make a <a>SizeSpec</a> with only width defined.
mkWidth :: Num n => n -> SizeSpec V2 n

-- | Make a <a>SizeSpec</a> with only height defined.
mkHeight :: Num n => n -> SizeSpec V2 n

-- | Make a <a>SizeSpec</a> from a width and height.
dims2D :: n -> n -> SizeSpec V2 n

-- | A Texture is either a color <a>SC</a>, linear gradient <a>LG</a>, or
--   radial gradient <a>RG</a>. An object can have only one texture which
--   is determined by the <a>Last</a> semigroup structure.
data Texture n
SC :: SomeColor -> Texture n
LG :: LGradient n -> Texture n
RG :: RGradient n -> Texture n

-- | Convert a solid colour into a texture.
solid :: Color a => a -> Texture n

-- | The <a>SpreadMethod</a> determines what happens before
--   <tt>lGradStart</tt> and after <tt>lGradEnd</tt>. <a>GradPad</a> fills
--   the space before the start of the gradient with the color of the first
--   stop and the color after end of the gradient with the color of the
--   last stop. <a>GradRepeat</a> restarts the gradient and
--   <a>GradReflect</a> restarts the gradient with the stops in reverse
--   order.
data SpreadMethod
GradPad :: SpreadMethod
GradReflect :: SpreadMethod
GradRepeat :: SpreadMethod

-- | A gradient stop contains a color and fraction (usually between 0 and
--   1)
data GradientStop d
GradientStop :: SomeColor -> d -> GradientStop d
[_stopColor] :: GradientStop d -> SomeColor
[_stopFraction] :: GradientStop d -> d
_FillTexture :: forall n p f. (Profunctor p, Functor f) => p (Recommend (Texture n)) (f (Recommend (Texture n))) -> p (FillTexture n) (f (FillTexture n))
fillTexture :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => Texture n -> a -> a

-- | Commit a fill texture in a style. This is <i>not</i> a valid setter
--   because it doesn't abide the functor law (see <a>committed</a>).
_fillTexture :: (Typeable n, Floating n) => Lens' (Style V2 n) (Texture n)
getFillTexture :: FillTexture n -> Texture n
_LineTexture :: forall n n' p f. (Profunctor p, Functor f) => p (Texture n) (f (Texture n')) -> p (LineTexture n) (f (LineTexture n'))
lineTexture :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => Texture n -> a -> a
_lineTexture :: (Floating n, Typeable n) => Lens' (Style V2 n) (Texture n)
lineTextureA :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => LineTexture n -> a -> a
getLineTexture :: LineTexture n -> Texture n

-- | The fraction for stop.
stopFraction :: forall n f. Functor f => (n -> f n) -> GradientStop n -> f (GradientStop n)

-- | A color for the stop.
stopColor :: forall n f. Functor f => (SomeColor -> f SomeColor) -> GradientStop n -> f (GradientStop n)

-- | A convenient function for making gradient stops from a list of
--   triples. (An opaque color, a stop fraction, an opacity).
mkStops :: [(Colour Double, d, Double)] -> [GradientStop d]

-- | Linear Gradient
data LGradient n
LGradient :: [GradientStop n] -> Point V2 n -> Point V2 n -> Transformation V2 n -> SpreadMethod -> LGradient n
[_lGradStops] :: LGradient n -> [GradientStop n]
[_lGradStart] :: LGradient n -> Point V2 n
[_lGradEnd] :: LGradient n -> Point V2 n
[_lGradTrans] :: LGradient n -> Transformation V2 n
[_lGradSpreadMethod] :: LGradient n -> SpreadMethod
_LG :: forall n p f. (Choice p, Applicative f) => p (LGradient n) (f (LGradient n)) -> p (Texture n) (f (Texture n))

-- | A list of stops (colors and fractions).
lGradStops :: forall n f. Functor f => ([GradientStop n] -> f [GradientStop n]) -> LGradient n -> f (LGradient n)

-- | A transformation to be applied to the gradient. Usually this field
--   will start as the identity transform and capture the transforms that
--   are applied to the gradient.
lGradTrans :: forall n f. Functor f => (Transformation V2 n -> f (Transformation V2 n)) -> LGradient n -> f (LGradient n)

-- | The starting point for the first gradient stop. The coordinates are in
--   <a>local</a> units and the default is (-0.5, 0).
lGradStart :: forall n f. Functor f => (Point V2 n -> f (Point V2 n)) -> LGradient n -> f (LGradient n)

-- | The ending point for the last gradient stop.The coordinates are in
--   <a>local</a> units and the default is (0.5, 0).
lGradEnd :: forall n f. Functor f => (Point V2 n -> f (Point V2 n)) -> LGradient n -> f (LGradient n)

-- | For setting the spread method.
lGradSpreadMethod :: forall n f. Functor f => (SpreadMethod -> f SpreadMethod) -> LGradient n -> f (LGradient n)

-- | A default is provided so that linear gradients can easily be created
--   using lenses. For example, <tt>lg = defaultLG &amp; lGradStart .~
--   (0.25 ^&amp; 0.33)</tt>. Note that no default value is provided for
--   <tt>lGradStops</tt>, this must be set before the gradient value is
--   used, otherwise the object will appear transparent.
defaultLG :: Fractional n => Texture n

-- | Make a linear gradient texture from a stop list, start point, end
--   point, and <a>SpreadMethod</a>. The <a>lGradTrans</a> field is set to
--   the identity transfrom, to change it use the <a>lGradTrans</a> lens.
mkLinearGradient :: Num n => [GradientStop n] -> Point V2 n -> Point V2 n -> SpreadMethod -> Texture n

-- | Radial Gradient
data RGradient n
RGradient :: [GradientStop n] -> Point V2 n -> n -> Point V2 n -> n -> Transformation V2 n -> SpreadMethod -> RGradient n
[_rGradStops] :: RGradient n -> [GradientStop n]
[_rGradCenter0] :: RGradient n -> Point V2 n
[_rGradRadius0] :: RGradient n -> n
[_rGradCenter1] :: RGradient n -> Point V2 n
[_rGradRadius1] :: RGradient n -> n
[_rGradTrans] :: RGradient n -> Transformation V2 n
[_rGradSpreadMethod] :: RGradient n -> SpreadMethod

-- | A list of stops (colors and fractions).
rGradStops :: forall n f. Functor f => ([GradientStop n] -> f [GradientStop n]) -> RGradient n -> f (RGradient n)

-- | The center point of the inner circle.
rGradCenter0 :: forall n f. Functor f => (Point V2 n -> f (Point V2 n)) -> RGradient n -> f (RGradient n)

-- | The radius of the inner cirlce in <a>local</a> coordinates.
rGradRadius0 :: forall n f. Functor f => (n -> f n) -> RGradient n -> f (RGradient n)

-- | The center of the outer circle.
rGradCenter1 :: forall n f. Functor f => (Point V2 n -> f (Point V2 n)) -> RGradient n -> f (RGradient n)

-- | The radius of the outer circle in <a>local</a> coordinates.
rGradRadius1 :: forall n f. Functor f => (n -> f n) -> RGradient n -> f (RGradient n)

-- | A transformation to be applied to the gradient. Usually this field
--   will start as the identity transform and capture the transforms that
--   are applied to the gradient.
rGradTrans :: forall n f. Functor f => (Transformation V2 n -> f (Transformation V2 n)) -> RGradient n -> f (RGradient n)

-- | For setting the spread method.
rGradSpreadMethod :: forall n f. Functor f => (SpreadMethod -> f SpreadMethod) -> RGradient n -> f (RGradient n)

-- | A default is provided so that radial gradients can easily be created
--   using lenses. For example, <tt>rg = defaultRG &amp; rGradRadius1 .~
--   0.25</tt>. Note that no default value is provided for
--   <tt>rGradStops</tt>, this must be set before the gradient value is
--   used, otherwise the object will appear transparent.
defaultRG :: Fractional n => Texture n
_RG :: forall n p f. (Choice p, Applicative f) => p (RGradient n) (f (RGradient n)) -> p (Texture n) (f (Texture n))

-- | Make a radial gradient texture from a stop list, radius, start point,
--   end point, and <a>SpreadMethod</a>. The <a>rGradTrans</a> field is set
--   to the identity transfrom, to change it use the <a>rGradTrans</a>
--   lens.
mkRadialGradient :: Num n => [GradientStop n] -> Point V2 n -> n -> Point V2 n -> n -> SpreadMethod -> Texture n

-- | Set the fill color. This function is polymorphic in the color type (so
--   it can be used with either <a>Colour</a> or <a>AlphaColour</a>), but
--   this can sometimes create problems for type inference, so the
--   <a>fc</a> and <a>fcA</a> variants are provided with more concrete
--   types.
fillColor :: (InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) => c -> a -> a
_SC :: forall n p f. (Choice p, Applicative f) => p SomeColor (f SomeColor) -> p (Texture n) (f (Texture n))

-- | Prism onto an <a>AlphaColour</a> <a>Double</a> of a <a>SC</a> texture.
_AC :: forall n p f. (Choice p, Applicative f) => p (AlphaColour Double) (f (AlphaColour Double)) -> p (Texture n) (f (Texture n))

-- | A synonym for <a>fillColor</a>, specialized to <tt><a>Colour</a>
--   Double</tt> (i.e. opaque colors). See comment after <a>fillColor</a>
--   about backends.
fc :: (InSpace V2 n a, Floating n, Typeable n, HasStyle a) => Colour Double -> a -> a

-- | A synonym for <a>fillColor</a>, specialized to <tt><a>AlphaColour</a>
--   Double</tt> (i.e. colors with transparency). See comment after
--   <a>fillColor</a> about backends.
fcA :: (InSpace V2 n a, Floating n, Typeable n, HasStyle a) => AlphaColour Double -> a -> a

-- | Set a "recommended" fill color, to be used only if no explicit calls
--   to <a>fillColor</a> (or <a>fc</a>, or <a>fcA</a>) are used. See
--   comment after <a>fillColor</a> about backends.
recommendFillColor :: (InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) => c -> a -> a

-- | Set the line (stroke) color. This function is polymorphic in the color
--   type (so it can be used with either <a>Colour</a> or
--   <a>AlphaColour</a>), but this can sometimes create problems for type
--   inference, so the <a>lc</a> and <a>lcA</a> variants are provided with
--   more concrete types.
lineColor :: (InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) => c -> a -> a

-- | A synonym for <a>lineColor</a>, specialized to <tt><a>Colour</a>
--   Double</tt> (i.e. opaque colors). See comment in <a>lineColor</a>
--   about backends.
lc :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => Colour Double -> a -> a

-- | A synonym for <a>lineColor</a>, specialized to <tt><a>AlphaColour</a>
--   Double</tt> (i.e. colors with transparency). See comment in
--   <a>lineColor</a> about backends.
lcA :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => AlphaColour Double -> a -> a

-- | Mark the origin of a diagram by placing a red dot 1/50th its size.
showOrigin :: (TypeableFloat n, Renderable (Path V2 n) b, Monoid' m) => QDiagram b V2 n m -> QDiagram b V2 n m

-- | Mark the origin of a diagram, with control over colour and scale of
--   marker dot.
showOrigin' :: (TypeableFloat n, Renderable (Path V2 n) b, Monoid' m) => OriginOpts n -> QDiagram b V2 n m -> QDiagram b V2 n m
data OriginOpts n
OriginOpts :: Colour Double -> n -> n -> OriginOpts n
[_oColor] :: OriginOpts n -> Colour Double
[_oScale] :: OriginOpts n -> n
[_oMinSize] :: OriginOpts n -> n
oColor :: forall n f. Functor f => (Colour Double -> f (Colour Double)) -> OriginOpts n -> f (OriginOpts n)
oScale :: forall n f. Functor f => (n -> f n) -> OriginOpts n -> f (OriginOpts n)
oMinSize :: forall n f. Functor f => (n -> f n) -> OriginOpts n -> f (OriginOpts n)

-- | Mark the envelope with an approximating cubic spline using 32 points,
--   medium line width and red line color.
showEnvelope :: (Enum n, TypeableFloat n, Renderable (Path V2 n) b) => QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Mark the envelope with an approximating cubic spline with control over
--   the color, line width and number of points.
showEnvelope' :: (Enum n, TypeableFloat n, Renderable (Path V2 n) b) => EnvelopeOpts n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
data EnvelopeOpts n
EnvelopeOpts :: Colour Double -> Measure n -> Int -> EnvelopeOpts n
[_eColor] :: EnvelopeOpts n -> Colour Double
[_eLineWidth] :: EnvelopeOpts n -> Measure n
[_ePoints] :: EnvelopeOpts n -> Int
eColor :: forall n f. Functor f => (Colour Double -> f (Colour Double)) -> EnvelopeOpts n -> f (EnvelopeOpts n)
eLineWidth :: forall n1 n2 f. Functor f => (Measure n1 -> f (Measure n2)) -> EnvelopeOpts n1 -> f (EnvelopeOpts n2)
ePoints :: forall n f. Functor f => (Int -> f Int) -> EnvelopeOpts n -> f (EnvelopeOpts n)

-- | Mark the trace of a diagram by placing 64 red dots 1/100th its size
--   along the trace.
showTrace :: (Enum n, TypeableFloat n, Renderable (Path V2 n) b) => QDiagram b V2 n Any -> QDiagram b V2 n Any

-- | Mark the trace of a diagram, with control over colour and scale of
--   marker dot and the number of points on the trace.
showTrace' :: (Enum n, TypeableFloat n, Renderable (Path V2 n) b) => TraceOpts n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
data TraceOpts n
TraceOpts :: Colour Double -> n -> n -> Int -> TraceOpts n
[_tColor] :: TraceOpts n -> Colour Double
[_tScale] :: TraceOpts n -> n
[_tMinSize] :: TraceOpts n -> n
[_tPoints] :: TraceOpts n -> Int
tColor :: forall n f. Functor f => (Colour Double -> f (Colour Double)) -> TraceOpts n -> f (TraceOpts n)
tScale :: forall n f. Functor f => (n -> f n) -> TraceOpts n -> f (TraceOpts n)
tMinSize :: forall n f. Functor f => (n -> f n) -> TraceOpts n -> f (TraceOpts n)
tPoints :: forall n f. Functor f => (Int -> f Int) -> TraceOpts n -> f (TraceOpts n)
showLabels :: (TypeableFloat n, Renderable (Text n) b, Semigroup m) => QDiagram b V2 n m -> QDiagram b V2 n Any


-- | A default diagram-adjustment implementation for two-dimensional
--   diagrams, useful for backend implementors.
module Diagrams.TwoD.Adjust

-- | Set default attributes of a 2D diagram (in case they have not been
--   set):
--   
--   <ul>
--   <li><a>LineWidth</a>: 0.01</li>
--   <li><tt>LineTexture</tt>: solid black</li>
--   <li><a>LineCap</a>: LineCapButt</li>
--   <li><a>LineJoin</a>: miter</li>
--   <li><tt>MiterLimit</tt>: 10</li>
--   </ul>
setDefault2DAttributes :: (TypeableFloat n, Semigroup m) => QDiagram b V2 n m -> QDiagram b V2 n m

-- | Adjust the size and position of a 2D diagram to fit within the
--   requested size. The first argument is a lens into the output size
--   contained in the rendering options. Returns an updated options record,
--   any transformation applied to the diagram (the inverse of which can be
--   used, say, to translate output/device coordinates back into local
--   diagram coordinates), and the modified diagram itself.
adjustSize2D :: (TypeableFloat n, Monoid' m) => Lens' (Options b V2 n) (SizeSpec V2 n) -> b -> Options b V2 n -> QDiagram b V2 n m -> (Options b V2 n, Transformation V2 n, QDiagram b V2 n m)

-- | <tt>adjustDia2D</tt> provides a useful default implementation of the
--   <a>adjustDia</a> method from the <a>Backend</a> type class.
--   
--   As its first argument it requires a lens into the output size
--   contained in the rendering options.
--   
--   It then performs the following adjustments:
--   
--   <ul>
--   <li>Set default attributes (see <a>setDefault2DAttributes</a>)</li>
--   <li>Scale and translate the diagram to fit within the requested size
--   (see <tt>adjustDiaSize2D</tt>)</li>
--   </ul>
--   
--   It returns an updated options record, any transformation applied to
--   the diagram (the inverse of which can be used, say, to translate
--   output/device coordinates back into local diagram coordinates), and
--   the modified diagram itself.
adjustDia2D :: (TypeableFloat n, Monoid' m) => Lens' (Options b V2 n) (SizeSpec V2 n) -> b -> Options b V2 n -> QDiagram b V2 n m -> (Options b V2 n, Transformation V2 n, QDiagram b V2 n m)


-- | Utilities for working with sizes of three-dimensional objects.
module Diagrams.ThreeD.Size

-- | Compute the absolute x-coordinate range of an enveloped object in the
--   form <tt>(lo,hi)</tt>. Return <tt>Nothing</tt> for objects with an
--   empty envelope.
--   
--   Note this is just <tt>extent unitX</tt>.
extentX :: forall (v :: Type -> Type) n a. (InSpace v n a, R1 v, Enveloped a) => a -> Maybe (n, n)

-- | Compute the absolute y-coordinate range of an enveloped object in the
--   form <tt>(lo,hi)</tt>. Return <tt>Nothing</tt> for objects with an
--   empty envelope.
extentY :: forall (v :: Type -> Type) n a. (InSpace v n a, R2 v, Enveloped a) => a -> Maybe (n, n)

-- | Compute the absolute z-coordinate range of an enveloped object in the
--   form <tt>(lo,hi)</tt>. Return <tt>Nothing</tt> for objects with an
--   empty envelope.
extentZ :: forall (v :: Type -> Type) n a. (InSpace v n a, R3 v, Enveloped a) => a -> Maybe (n, n)

-- | Make a <a>SizeSpec</a> from possibly-specified width and height.
mkSizeSpec3D :: Num n => Maybe n -> Maybe n -> Maybe n -> SizeSpec V3 n

-- | Make a <a>SizeSpec</a> from a width and height.
dims3D :: n -> n -> n -> SizeSpec V3 n


-- | An animation is a time-varying diagram, together with start and end
--   times. Most of the tools for working with animations can actually be
--   found in the <tt>active</tt> package, which defines the <a>Active</a>
--   type.
--   
--   XXX more documentation and examples should go here
module Diagrams.Animation

-- | A value of type <tt>QAnimation b v m</tt> is an animation (a
--   time-varying diagram with start and end times) that can be rendered by
--   backend <tt>b</tt>, with vector space <tt>v</tt> and monoidal
--   annotations of type <tt>m</tt>.
type QAnimation b (v :: Type -> Type) n m = Active QDiagram b v n m

-- | A value of type <tt>Animation b v</tt> is an animation (a time-varying
--   diagram with start and end times) in vector space <tt>v</tt> that can
--   be rendered by backspace <tt>b</tt>.
--   
--   Note that <tt>Animation</tt> is actually a synonym for
--   <tt>QAnimation</tt> where the type of the monoidal annotations has
--   been fixed to <a>Any</a> (the default).
type Animation b (v :: Type -> Type) n = QAnimation b v n Any

-- | Automatically assign fixed a envelope to the entirety of an animation
--   by sampling the envelope at a number of points in time and taking the
--   union of all the sampled envelopes to form the "hull". This hull is
--   then used uniformly throughout the animation.
--   
--   This is useful when you have an animation that grows and shrinks in
--   size or shape over time, but you want it to take up a fixed amount of
--   space, <i>e.g.</i> so that the final rendered movie does not zoom in
--   and out, or so that it occupies a fixed location with respect to
--   another animation, when combining animations with something like
--   <tt>|||</tt>.
--   
--   By default, 30 samples per time unit are used; to adjust this number
--   see <a>animEnvelope'</a>.
--   
--   See also <a>animRect</a> for help constructing a background to go
--   behind an animation.
animEnvelope :: forall n (v :: Type -> Type) m b. (OrderedField n, Metric v, Monoid' m) => QAnimation b v n m -> QAnimation b v n m

-- | Like <a>animEnvelope</a>, but with an adjustible sample rate. The
--   first parameter is the number of samples per time unit to use. Lower
--   rates will be faster but less accurate; higher rates are more accurate
--   but slower.
animEnvelope' :: forall n (v :: Type -> Type) m b. (OrderedField n, Metric v, Monoid' m) => Rational -> QAnimation b v n m -> QAnimation b v n m

-- | <tt>animRect</tt> works similarly to <a>animEnvelope</a> for 2D
--   diagrams, but instead of adjusting the envelope, simply returns the
--   smallest bounding rectangle which encloses the entire animation.
--   Useful for <i>e.g.</i> creating a background to go behind an
--   animation.
--   
--   Uses 30 samples per time unit by default; to adjust this number see
--   <a>animRect'</a>.
animRect :: (InSpace V2 n t, Monoid' m, TrailLike t, Enveloped t, Transformable t, Monoid t) => QAnimation b V2 n m -> t

-- | Like <a>animRect</a>, but with an adjustible sample rate. The first
--   parameter is the number of samples per time unit to use. Lower rates
--   will be faster but less accurate; higher rates are more accurate but
--   slower.
animRect' :: (InSpace V2 n t, Monoid' m, TrailLike t, Enveloped t, Transformable t, Monoid t) => Rational -> QAnimation b V2 n m -> t


-- | Convenient creation of command-line-driven executables for rendering
--   diagrams. This module provides a general framework and default
--   behaviors for parsing command-line arguments, records for diagram
--   creation options in various forms, and classes and instances for a
--   unified entry point to command-line-driven diagram creation
--   executables.
--   
--   For a tutorial on command-line diagram creation see
--   <a>https://diagrams.github.io/doc/cmdline.html</a>.
module Diagrams.Backend.CmdLine

-- | Standard options most diagrams are likely to have.
data DiagramOpts
DiagramOpts :: Maybe Int -> Maybe Int -> FilePath -> DiagramOpts

-- | Final output width of diagram.
[_width] :: DiagramOpts -> Maybe Int

-- | Final output height of diagram.
[_height] :: DiagramOpts -> Maybe Int

-- | Output file path, format is typically chosen by extension.
[_output] :: DiagramOpts -> FilePath

-- | Command line parser for <a>DiagramOpts</a>. Width is option
--   <tt>--width</tt> or <tt>-w</tt>. Height is option <tt>--height</tt> or
--   <tt>-h</tt> (note we change help to be <tt>-?</tt> due to this).
--   Output is option <tt>--output</tt> or <tt>-o</tt>.
diagramOpts :: Parser DiagramOpts
width :: Lens' DiagramOpts (Maybe Int)
height :: Lens' DiagramOpts (Maybe Int)
output :: Lens' DiagramOpts FilePath

-- | Extra options for a program that can offer a choice between multiple
--   diagrams.
data DiagramMultiOpts
DiagramMultiOpts :: Maybe String -> Bool -> DiagramMultiOpts

-- | Selected diagram to render.
[_selection] :: DiagramMultiOpts -> Maybe String

-- | Flag to indicate that a list of available diagrams should be printed
--   to standard out.
[_list] :: DiagramMultiOpts -> Bool

-- | Command line parser for <a>DiagramMultiOpts</a>. Selection is option
--   <tt>--selection</tt> or <tt>-S</tt>. List is <tt>--list</tt> or
--   <tt>-L</tt>.
diagramMultiOpts :: Parser DiagramMultiOpts
selection :: Lens' DiagramMultiOpts (Maybe String)
list :: Lens' DiagramMultiOpts Bool

-- | Extra options for animations.
data DiagramAnimOpts
DiagramAnimOpts :: Double -> DiagramAnimOpts

-- | Number of frames per unit time to generate for the animation.
[_fpu] :: DiagramAnimOpts -> Double

-- | Command line parser for <a>DiagramAnimOpts</a> Frames per unit is
--   <tt>--fpu</tt> or <tt>-f</tt>.
diagramAnimOpts :: Parser DiagramAnimOpts
fpu :: Iso' DiagramAnimOpts Double

-- | Parseable instances give a command line parser for a type. If a custom
--   parser for a common type is wanted a newtype wrapper could be used to
--   make a new <a>Parseable</a> instance. Notice that we do <i>not</i>
--   want as many instances as <a>Read</a> because we want to limit
--   ourselves to things that make sense to parse from the command line.
class Parseable a
parser :: Parseable a => Parser a

-- | Parses a hexadecimal color. The string can start with <tt>"0x"</tt> or
--   <tt>"#"</tt> or just be a string of hexadecimal values. If four or
--   three digits are given each digit is repeated to form a full 24 or 32
--   bit color. For example, <tt>"0xfc4"</tt> is the same as
--   <tt>"0xffcc44"</tt>. When eight or six digits are given each pair of
--   digits is a color or alpha channel with the order being red, green,
--   blue, alpha.
readHexColor :: (Applicative m, MonadFail m) => String -> m (AlphaColour Double)

-- | This class represents the various ways we want to support diagram
--   creation from the command line. It has the right instances to select
--   between creating single static diagrams, multiple static diagrams,
--   static animations, and functions that produce diagrams as long as the
--   arguments are <a>Parseable</a>.
--   
--   Backends are expected to create <tt>Mainable</tt> instances for the
--   types that are suitable for generating output in the backend's format.
--   For instance, Postscript can handle single diagrams, pages of
--   diagrams, animations as separate files, and association lists. This
--   implies instances for <tt>Diagram Postscript R2</tt>, <tt>[Diagram
--   Postscript R2]</tt>, <tt>Animation Postscript R2</tt>, and
--   <tt>[(String,Diagram Postscript R2)]</tt>. We can consider these as
--   the base cases for the function instance.
--   
--   The associated type <a>MainOpts</a> describes the options which need
--   to be parsed from the command-line and passed to <tt>mainRender</tt>.
class Mainable d where {
    
    -- | Associated type that describes the options which need to be parsed
    --   from the command-line and passed to <tt>mainRender</tt>.
    type MainOpts d;
}

-- | This method invokes the command-line parser resulting in an options
--   value or ending the program with an error or help message. Typically
--   the default instance will work. If a different help message or parsing
--   behavior is desired a new implementation is appropriate.
mainArgs :: (Mainable d, Parseable (MainOpts d)) => proxy d -> IO (MainOpts d)

-- | Backend specific work of rendering with the given options and mainable
--   value is done here. All backend instances should implement this
--   method.
mainRender :: Mainable d => MainOpts d -> d -> IO ()

-- | Main entry point for command-line diagram creation. This is the method
--   that users will call from their program <tt>main</tt>. For instance an
--   expected user program would take the following form.
--   
--   <pre>
--   import Diagrams.Prelude
--   import Diagrams.Backend.TheBestBackend.CmdLine
--   
--   d :: Diagram B R2
--   d = ...
--   
--   main = mainWith d
--   </pre>
--   
--   Most backends should be able to use the default implementation. A
--   different implementation should be used to handle more complex
--   interactions with the user.
mainWith :: Mainable d => d -> IO ()

-- | This class allows us to abstract over functions that take some
--   arguments and produce a final value. When some <tt>d</tt> is an
--   instance of <a>ToResult</a> we get a type <tt><a>Args</a> d</tt> that
--   is a type of <i>all</i> the arguments at once, and a type
--   <tt><a>ResultOf</a> d</tt> that is the type of the final result from
--   some base case instance.
class ToResult d where {
    type Args d;
    type ResultOf d;
}
toResult :: ToResult d => d -> Args d -> ResultOf d

-- | <tt>defaultAnimMainRender</tt> is an implementation of
--   <a>mainRender</a> which renders an animation as numbered frames, named
--   by extending the given output file name by consecutive integers. For
--   example if the given output file name is <tt>foo/blah.ext</tt>, the
--   frames will be saved in <tt>foo/blah001.ext</tt>,
--   <tt>foo/blah002.ext</tt>, and so on (the number of padding digits used
--   depends on the total number of frames). It is up to the user to take
--   these images and stitch them together into an actual animation format
--   (using, <i>e.g.</i> <tt>ffmpeg</tt>).
--   
--   Of course, this is a rather crude method of rendering animations; more
--   sophisticated methods will likely be added in the future.
--   
--   The <tt>fpu</tt> option from <a>DiagramAnimOpts</a> can be used to
--   control how many frames will be output for each second (unit time) of
--   animation.
--   
--   This function requires a lens into the structure that the particular
--   backend uses for its diagram base case. If <tt>MainOpts (QDiagram b v
--   n Any) ~ DiagramOpts</tt> then this lens will simply be <a>output</a>.
--   This lens is required because the implementation works by modifying
--   the output field and running the base <tt>mainRender</tt>. Typically a
--   backend can write its <tt>Animation B V</tt> instance as
--   
--   <pre>
--   instance Mainable (Animation B V) where
--       type MainOpts (Animation B V) = (DiagramOpts, DiagramAnimOpts)
--       mainRender = defaultAnimMainRender output
--   
--   </pre>
--   
--   We do not provide this instance in general so that backends can choose
--   to opt-in to this form or provide a different instance that makes more
--   sense.
defaultAnimMainRender :: forall opts b (v :: Type -> Type) n. (opts -> QDiagram b v n Any -> IO ()) -> Lens' opts FilePath -> (opts, DiagramAnimOpts) -> Animation b v n -> IO ()

-- | <tt>defaultMultiMainRender</tt> is an implementation of
--   <a>mainRender</a> where instead of a single diagram it takes a list of
--   diagrams paired with names as input. The generated executable then
--   takes a <tt>--selection</tt> option specifying the name of the diagram
--   that should be rendered. The list of available diagrams may also be
--   printed by passing the option <tt>--list</tt>.
--   
--   Typically a backend can write its <tt>[(String,QDiagram b v n
--   Any)]</tt> instance as
--   
--   <pre>
--   instance Mainable [(String,QDiagram b v n Any)] where
--       type MainOpts [(String,QDiagram b v n Any)] = (DiagramOpts, DiagramMultiOpts)
--       mainRender = defaultMultiMainRender
--   
--   </pre>
--   
--   We do not provide this instance in general so that backends can choose
--   to opt-in to this form or provide a different instance that makes more
--   sense.
defaultMultiMainRender :: Mainable d => (MainOpts d, DiagramMultiOpts) -> [(String, d)] -> IO ()
instance GHC.Internal.Data.Data.Data Diagrams.Backend.CmdLine.DiagramAnimOpts
instance GHC.Internal.Data.Data.Data Diagrams.Backend.CmdLine.DiagramMultiOpts
instance GHC.Internal.Data.Data.Data Diagrams.Backend.CmdLine.DiagramOpts
instance (Diagrams.Backend.CmdLine.ToResult d, Diagrams.Backend.CmdLine.Mainable (Diagrams.Backend.CmdLine.ResultOf d)) => Diagrams.Backend.CmdLine.Mainable (a -> d)
instance Diagrams.Backend.CmdLine.Mainable d => Diagrams.Backend.CmdLine.Mainable (GHC.Types.IO d)
instance Diagrams.Backend.CmdLine.Parseable (Data.Colour.Internal.AlphaColour GHC.Types.Double)
instance Diagrams.Backend.CmdLine.Parseable (Data.Colour.Internal.Colour GHC.Types.Double)
instance Diagrams.Backend.CmdLine.Parseable Diagrams.Backend.CmdLine.DiagramAnimOpts
instance Diagrams.Backend.CmdLine.Parseable Diagrams.Backend.CmdLine.DiagramMultiOpts
instance Diagrams.Backend.CmdLine.Parseable Diagrams.Backend.CmdLine.DiagramOpts
instance Diagrams.Backend.CmdLine.Parseable GHC.Types.Double
instance Diagrams.Backend.CmdLine.Parseable GHC.Types.Int
instance Diagrams.Backend.CmdLine.Parseable GHC.Internal.Base.String
instance (Diagrams.Backend.CmdLine.Parseable a, Diagrams.Backend.CmdLine.Parseable b) => Diagrams.Backend.CmdLine.Parseable (a, b)
instance (Diagrams.Backend.CmdLine.Parseable a, Diagrams.Backend.CmdLine.Parseable b, Diagrams.Backend.CmdLine.Parseable c) => Diagrams.Backend.CmdLine.Parseable (a, b, c)
instance (Diagrams.Backend.CmdLine.Parseable a, Diagrams.Backend.CmdLine.Parseable b, Diagrams.Backend.CmdLine.Parseable c, Diagrams.Backend.CmdLine.Parseable d) => Diagrams.Backend.CmdLine.Parseable (a, b, c, d)
instance Diagrams.Backend.CmdLine.Parseable ()
instance GHC.Internal.Show.Show Diagrams.Backend.CmdLine.DiagramAnimOpts
instance GHC.Internal.Show.Show Diagrams.Backend.CmdLine.DiagramMultiOpts
instance GHC.Internal.Show.Show Diagrams.Backend.CmdLine.DiagramOpts
instance Diagrams.Backend.CmdLine.ToResult (Diagrams.Animation.Animation b v n)
instance Diagrams.Backend.CmdLine.ToResult d => Diagrams.Backend.CmdLine.ToResult (a -> d)
instance Diagrams.Backend.CmdLine.ToResult d => Diagrams.Backend.CmdLine.ToResult (GHC.Types.IO d)
instance Diagrams.Backend.CmdLine.ToResult [Diagrams.Core.Types.QDiagram b v n GHC.Internal.Data.Semigroup.Internal.Any]
instance Diagrams.Backend.CmdLine.ToResult [(GHC.Internal.Base.String, Diagrams.Core.Types.QDiagram b v n GHC.Internal.Data.Semigroup.Internal.Any)]
instance Diagrams.Backend.CmdLine.ToResult (Diagrams.Core.Types.QDiagram b v n GHC.Internal.Data.Semigroup.Internal.Any)


-- | This module only contains exports defined in <tt>diagrams-lib</tt> or
--   <tt>diagrams-core</tt>. This module can be used if you want to avoid
--   some potential conflicts with other modules, but importing
--   <a>Diagrams.Prelude</a> (which includes re-exports from other
--   packages) is often more convenient.
module Diagrams

-- | A bounding box is an axis-aligned region determined by two points
--   indicating its "lower" and "upper" corners. It can also represent an
--   empty bounding box - the points are wrapped in <tt>Maybe</tt>.
data BoundingBox (v :: Type -> Type) n

-- | An empty bounding box. This is the same thing as <tt>mempty</tt>, but
--   it doesn't require the same type constraints that the <tt>Monoid</tt>
--   instance does.
emptyBox :: forall (v :: Type -> Type) n. BoundingBox v n

-- | Create a bounding box from a point that is component-wise
--   <tt>(&lt;=)</tt> than the other. If this is not the case, then
--   <tt>mempty</tt> is returned.
fromCorners :: forall (v :: Type -> Type) n. (Additive v, Foldable v, Ord n) => Point v n -> Point v n -> BoundingBox v n

-- | Create a degenerate bounding "box" containing only a single point.
fromPoint :: forall (v :: Type -> Type) n. Point v n -> BoundingBox v n

-- | Create the smallest bounding box containing all the given points.
fromPoints :: forall (v :: Type -> Type) n. (Additive v, Ord n) => [Point v n] -> BoundingBox v n

-- | Create a bounding box for any enveloped object (such as a diagram or
--   path).
boundingBox :: forall (v :: Type -> Type) n a. (InSpace v n a, HasBasis v, Enveloped a) => a -> BoundingBox v n

-- | Queries whether the BoundingBox is empty.
isEmptyBox :: forall (v :: Type -> Type) n. BoundingBox v n -> Bool

-- | Gets the lower and upper corners that define the bounding box.
getCorners :: forall (v :: Type -> Type) n. BoundingBox v n -> Maybe (Point v n, Point v n)

-- | Computes all of the corners of the bounding box.
getAllCorners :: forall (v :: Type -> Type) n. (Additive v, Traversable v) => BoundingBox v n -> [Point v n]

-- | Get the size of the bounding box - the vector from the
--   (component-wise) lesser point to the greater point.
boxExtents :: (Additive v, Num n) => BoundingBox v n -> v n

-- | Get the center point in a bounding box.
boxCenter :: forall (v :: Type -> Type) n. (Additive v, Fractional n) => BoundingBox v n -> Maybe (Point v n)

-- | Get the center of a the bounding box of an enveloped object, return
--   <a>Nothing</a> for object with empty envelope.
mCenterPoint :: forall (v :: Type -> Type) n a. (InSpace v n a, HasBasis v, Enveloped a) => a -> Maybe (Point v n)

-- | Get the center of a the bounding box of an enveloped object, return
--   the origin for object with empty envelope.
centerPoint :: forall (v :: Type -> Type) n a. (InSpace v n a, HasBasis v, Enveloped a) => a -> Point v n

-- | Create a transformation mapping points from one bounding box to the
--   other. Returns <a>Nothing</a> if either of the boxes are empty.
boxTransform :: forall (v :: Type -> Type) n. (Additive v, Fractional n) => BoundingBox v n -> BoundingBox v n -> Maybe (Transformation v n)

-- | Transforms an enveloped thing to fit within a <tt>BoundingBox</tt>. If
--   the bounding box is empty, then the result is also <tt>mempty</tt>.
boxFit :: forall (v :: Type -> Type) n a. (InSpace v n a, HasBasis v, Enveloped a, Transformable a, Monoid a) => BoundingBox v n -> a -> a

-- | Check whether a point is <i>strictly</i> contained in a bounding box.
contains' :: forall (v :: Type -> Type) n. (Additive v, Foldable v, Ord n) => BoundingBox v n -> Point v n -> Bool

-- | Test whether the first bounding box is <i>strictly</i> contained
--   inside the second.
inside' :: forall (v :: Type -> Type) n. (Additive v, Foldable v, Ord n) => BoundingBox v n -> BoundingBox v n -> Bool

-- | Test whether the first bounding box lies <i>strictly</i> outside the
--   second (they do not intersect at all).
outside' :: forall (v :: Type -> Type) n. (Additive v, Foldable v, Ord n) => BoundingBox v n -> BoundingBox v n -> Bool

-- | <tt>boxGrid f box</tt> returns a grid of regularly spaced points
--   inside the box, such that there are <tt>(1/f)</tt> points along each
--   dimension. For example, for a 3D box with corners at (0,0,0) and
--   (2,2,2), <tt>boxGrid 0.1</tt> would yield a grid of approximately 1000
--   points (it might actually be <tt>11^3</tt> instead of <tt>10^3</tt>)
--   spaced <tt>0.2</tt> units apart.
boxGrid :: forall (v :: Type -> Type) n. (Traversable v, Additive v, Num n, Enum n) => n -> BoundingBox v n -> [Point v n]

-- | Determine whether a trail is a line.
isLine :: forall (v :: Type -> Type) n. Trail v n -> Bool

-- | Type tag for trails with distinct endpoints.
data Line

-- | Intuitively, a trail is a single, continuous path through space.
--   However, a trail has no fixed starting point; it merely specifies
--   <i>how</i> to move through space, not <i>where</i>. For example, "take
--   three steps forward, then turn right twenty degrees and take two more
--   steps" is an intuitive analog of a trail; these instructions specify a
--   path through space from any given starting location. To be precise,
--   trails are <i>translation-invariant</i>; applying a translation to a
--   trail has no effect.
--   
--   A <tt><a>Located</a> Trail</tt>, on the other hand, is a trail paired
--   with some concrete starting location ("start at the big tree on the
--   corner, then take three steps forward, ..."). See the
--   <a>Diagrams.Located</a> module for help working with <a>Located</a>
--   values.
--   
--   Formally, the semantics of a trail is a continuous (though not
--   necessarily differentiable) function from the real interval [0,1] to
--   vectors in some vector space. (In contrast, a <a>Located</a> trail is
--   a continuous function from [0,1] to <i>points</i> in some
--   <i>affine</i> space.)
--   
--   There are two types of trails:
--   
--   <ul>
--   <li>A "line" (think of the "train", "subway", or "bus" variety, rather
--   than the "straight" variety...) is a trail with two distinct
--   endpoints. Actually, a line can have the same start and end points,
--   but it is still <i>drawn</i> as if it had distinct endpoints: the two
--   endpoints will have the appropriate end caps, and the trail will not
--   be filled. Lines have a <tt>Monoid</tt> instance where
--   <tt>mappend</tt> corresponds to concatenation, <i>i.e.</i> chaining
--   one line after the other.</li>
--   <li>A "loop" is required to end in the same place it starts (that is,
--   t(0) = t(1)). Loops are filled and are drawn as one continuous loop,
--   with the appropriate join at the start/endpoint rather than end caps.
--   Loops do not have a <tt>Monoid</tt> instance.</li>
--   </ul>
--   
--   To convert between lines and loops, see <a>glueLine</a>,
--   <a>closeLine</a>, and <a>cutLoop</a>.
--   
--   To construct trails, see <a>emptyTrail</a>, <a>trailFromSegments</a>,
--   <a>trailFromVertices</a>, <a>trailFromOffsets</a>, and friends. You
--   can also get any type of trail from any function which returns a
--   <tt>TrailLike</tt> (<i>e.g.</i> functions in
--   <a>Diagrams.TwoD.Shapes</a>, and many others; see
--   <a>Diagrams.TrailLike</a>).
--   
--   To extract information from trails, see <a>withLine</a>,
--   <a>isLoop</a>, <a>trailSegments</a>, <a>trailOffsets</a>,
--   <a>trailVertices</a>, and friends.
data Trail' l (v :: Type -> Type) n
[Line] :: forall (v :: Type -> Type) n. SegTree v n -> Trail' Line v n
[Loop] :: forall (v :: Type -> Type) n. SegTree v n -> Segment Open v n -> Trail' Loop v n

-- | <tt>Trail</tt> is a wrapper around <tt>Trail'</tt>, hiding whether the
--   underlying <tt>Trail'</tt> is a line or loop (though which it is can
--   be recovered; see <i>e.g.</i> <a>withTrail</a>).
data Trail (v :: Type -> Type) n
[Trail] :: forall l (v :: Type -> Type) n. Trail' l v n -> Trail v n

-- | Compute the total offset of anything measured by <a>SegMeasure</a>.
offset :: (OrderedField n, Metric v, Measured (SegMeasure v n) t) => t -> v n

-- | Make a line into a loop by "gluing" the endpoint to the starting
--   point. In particular, the offset of the final segment is modified so
--   that it ends at the starting point of the entire trail. Typically, you
--   would first construct a line which you know happens to end where it
--   starts, and then call <a>glueLine</a> to turn it into a loop.
--   
--   
--   <pre>
--   glueLineEx = pad 1.1 . hsep 1
--     $ [almostClosed # strokeLine, almostClosed # glueLine # strokeLoop]
--   
--   almostClosed :: Trail' Line V2 Double
--   almostClosed = fromOffsets $ map r2 [(2, -1), (-3, -0.5), (-2, 1), (1, 0.5)]
--   </pre>
--   
--   <tt>glueLine</tt> is left inverse to <a>cutLoop</a>, that is,
--   
--   <pre>
--   glueLine . cutLoop === id
--   
--   </pre>
glueLine :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail' Line v n -> Trail' Loop v n

-- | Make a line into a loop by adding a new linear segment from the line's
--   end to its start.
--   
--   <tt>closeLine</tt> does not have any particularly nice theoretical
--   properties, but can be useful <i>e.g.</i> when you want to make a
--   closed polygon out of a list of points where the initial point is not
--   repeated at the end. To use <a>glueLine</a>, one would first have to
--   duplicate the initial vertex, like
--   
--   <pre>
--   <a>glueLine</a> . <a>lineFromVertices</a> $ ps ++ [head ps]
--   </pre>
--   
--   Using <tt>closeLine</tt>, however, one can simply
--   
--   <pre>
--   closeLine . lineFromVertices $ ps
--   </pre>
--   
--   
--   <pre>
--   closeLineEx = pad 1.1 . centerXY . hcat' (with &amp; sep .~ 1)
--     $ [almostClosed # strokeLine, almostClosed # closeLine # strokeLoop]
--   </pre>
closeLine :: forall (v :: Type -> Type) n. Trail' Line v n -> Trail' Loop v n

-- | Turn a loop into a line by "cutting" it at the common start/end point,
--   resulting in a line which just happens to start and end at the same
--   place.
--   
--   <tt>cutLoop</tt> is right inverse to <a>glueLine</a>, that is,
--   
--   <pre>
--   glueLine . cutLoop === id
--   
--   </pre>
cutLoop :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail' Loop v n -> Trail' Line v n

-- | Prism onto a <a>Line</a>.
_Line :: forall (v :: Type -> Type) n p f. (Choice p, Applicative f) => p (Trail' Line v n) (f (Trail' Line v n)) -> p (Trail v n) (f (Trail v n))

-- | Prism onto a <a>Loop</a>.
_Loop :: forall (v :: Type -> Type) n p f. (Choice p, Applicative f) => p (Trail' Loop v n) (f (Trail' Loop v n)) -> p (Trail v n) (f (Trail v n))

-- | Prism onto a <a>Located</a> <a>Line</a>.
_LocLine :: forall (v :: Type -> Type) n p f. (Choice p, Applicative f) => p (Located (Trail' Line v n)) (f (Located (Trail' Line v n))) -> p (Located (Trail v n)) (f (Located (Trail v n)))

-- | Prism onto a <a>Located</a> <a>Loop</a>.
_LocLoop :: forall (v :: Type -> Type) n p f. (Choice p, Applicative f) => p (Located (Trail' Loop v n)) (f (Located (Trail' Loop v n))) -> p (Located (Trail v n)) (f (Located (Trail v n)))

-- | Convert a <a>Trail'</a> into a <a>Trail</a>, hiding the type-level
--   distinction between lines and loops.
wrapTrail :: forall l (v :: Type -> Type) n. Trail' l v n -> Trail v n

-- | Convert a line into a <a>Trail</a>. This is the same as
--   <a>wrapTrail</a>, but with a more specific type, which can
--   occasionally be convenient for fixing the type of a polymorphic
--   expression.
wrapLine :: forall (v :: Type -> Type) n. Trail' Line v n -> Trail v n

-- | Convert a loop into a <a>Trail</a>. This is the same as
--   <a>wrapTrail</a>, but with a more specific type, which can
--   occasionally be convenient for fixing the type of a polymorphic
--   expression.
wrapLoop :: forall (v :: Type -> Type) n. Trail' Loop v n -> Trail v n

-- | Modify a <tt>Trail</tt>, specifying two separate transformations for
--   the cases of a line or a loop.
onTrail :: forall (v :: Type -> Type) n l1 l2. (Trail' Line v n -> Trail' l1 v n) -> (Trail' Loop v n -> Trail' l2 v n) -> Trail v n -> Trail v n

-- | Modify a <tt>Trail</tt> by specifying a transformation on lines. If
--   the trail is a line, the transformation will be applied directly. If
--   it is a loop, it will first be cut using <a>cutLoop</a>, the
--   transformation applied, and then glued back into a loop with
--   <a>glueLine</a>. That is,
--   
--   <pre>
--   onLine f === onTrail f (glueLine . f . cutLoop)
--   
--   </pre>
--   
--   Note that there is no corresponding <tt>onLoop</tt> function, because
--   there is no nice way in general to convert a line into a loop, operate
--   on it, and then convert back.
onLine :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => (Trail' Line v n -> Trail' Line v n) -> Trail v n -> Trail v n

-- | <tt>glueTrail</tt> is a variant of <a>glueLine</a> which works on
--   <a>Trail</a>s. It performs <a>glueLine</a> on lines and is the
--   identity on loops.
glueTrail :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail v n -> Trail v n

-- | <tt>closeTrail</tt> is a variant of <a>closeLine</a> for <a>Trail</a>,
--   which performs <a>closeLine</a> on lines and is the identity on loops.
closeTrail :: forall (v :: Type -> Type) n. Trail v n -> Trail v n

-- | <tt>cutTrail</tt> is a variant of <a>cutLoop</a> for <a>Trail</a>; it
--   is the is the identity on lines and performs <a>cutLoop</a> on loops.
cutTrail :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail v n -> Trail v n

-- | The empty line, which is the identity for concatenation of lines.
emptyLine :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail' Line v n

-- | A wrapped variant of <a>emptyLine</a>.
emptyTrail :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail v n

-- | Construct a line containing only linear segments from a list of
--   vertices. Note that only the relative offsets between the vertices
--   matters; the information about their absolute position will be
--   discarded. That is, for all vectors <tt>v</tt>,
--   
--   <pre>
--   lineFromVertices === lineFromVertices . <a>translate</a> v
--   </pre>
--   
--   If you want to retain the position information, you should instead use
--   the more general <tt>fromVertices</tt> function to construct, say, a
--   <tt><a>Located</a> (<a>Trail'</a> <a>Line</a> v)</tt> or a
--   <tt><a>Located</a> (<a>Trail</a> v)</tt>.
--   
--   
--   <pre>
--   import Diagrams.Coordinates
--   lineFromVerticesEx = pad 1.1 . centerXY . strokeLine
--     $ lineFromVertices [origin, 0 ^&amp; 1, 1 ^&amp; 2, 5 ^&amp; 1]
--   </pre>
lineFromVertices :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => [Point v n] -> Trail' Line v n

-- | <tt>trailFromVertices === <a>wrapTrail</a> .
--   <a>lineFromVertices</a></tt>, for conveniently constructing a
--   <tt>Trail</tt> instead of a <tt>Trail' Line</tt>.
trailFromVertices :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => [Point v n] -> Trail v n

-- | Construct a line containing only linear segments from a list of
--   vectors, where each vector represents the offset from one vertex to
--   the next. See also <tt>fromOffsets</tt>.
--   
--   
--   <pre>
--   import Diagrams.Coordinates
--   lineFromOffsetsEx = strokeLine $ lineFromOffsets [ 2 ^&amp; 1, 2 ^&amp; (-1), 2 ^&amp; 0.5 ]
--   </pre>
lineFromOffsets :: (Metric v, OrderedField n) => [v n] -> Trail' Line v n

-- | <tt>trailFromOffsets === <a>wrapTrail</a> .
--   <a>lineFromOffsets</a></tt>, for conveniently constructing a
--   <tt>Trail</tt> instead of a <tt>Trail' Line</tt>.
trailFromOffsets :: (Metric v, OrderedField n) => [v n] -> Trail v n

-- | Construct a line from a list of closed segments.
lineFromSegments :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => [Segment Closed v n] -> Trail' Line v n

-- | <tt>trailFromSegments === <a>wrapTrail</a> .
--   <a>lineFromSegments</a></tt>, for conveniently constructing a
--   <tt>Trail</tt> instead of a <tt>Trail'</tt>.
trailFromSegments :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => [Segment Closed v n] -> Trail v n

-- | Construct a loop from a list of closed segments and an open segment
--   that completes the loop.
loopFromSegments :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => [Segment Closed v n] -> Segment Open v n -> Trail' Loop v n

-- | A generic eliminator for <a>Trail'</a>, taking functions specifying
--   what to do in the case of a line or a loop.
withTrail' :: forall (v :: Type -> Type) n r l. (Trail' Line v n -> r) -> (Trail' Loop v n -> r) -> Trail' l v n -> r

-- | A generic eliminator for <a>Trail</a>, taking functions specifying
--   what to do in the case of a line or a loop.
withTrail :: forall (v :: Type -> Type) n r. (Trail' Line v n -> r) -> (Trail' Loop v n -> r) -> Trail v n -> r

-- | An eliminator for <tt>Trail</tt> based on eliminating lines: if the
--   trail is a line, the given function is applied; if it is a loop, it is
--   first converted to a line with <a>cutLoop</a>. That is,
--   
--   <pre>
--   withLine f === <a>withTrail</a> f (f . <a>cutLoop</a>)
--   </pre>
withLine :: forall (v :: Type -> Type) n r. (Metric v, OrderedField n) => (Trail' Line v n -> r) -> Trail v n -> r

-- | Test whether a line is empty.
isLineEmpty :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail' Line v n -> Bool

-- | Test whether a trail is empty. Note that loops are never empty.
isTrailEmpty :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail v n -> Bool

-- | Determine whether a trail is a loop.
isLoop :: forall (v :: Type -> Type) n. Trail v n -> Bool

-- | Extract the segments of a trail. If the trail is a loop it will first
--   have <a>cutLoop</a> applied.
trailSegments :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail v n -> [Segment Closed v n]

-- | Extract the segments comprising a line.
lineSegments :: forall (v :: Type -> Type) n. Trail' Line v n -> [Segment Closed v n]

-- | Extract the segments comprising a loop: a list of closed segments, and
--   one final open segment.
loopSegments :: forall (v :: Type -> Type) n. Trail' Loop v n -> ([Segment Closed v n], Segment Open v n)

-- | Modify a line by applying a function to its list of segments.
onLineSegments :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => ([Segment Closed v n] -> [Segment Closed v n]) -> Trail' Line v n -> Trail' Line v n

-- | Extract the offsets of the segments of a trail.
trailOffsets :: (Metric v, OrderedField n) => Trail v n -> [v n]

-- | Compute the offset from the start of a trail to the end. Satisfies
--   
--   <pre>
--   trailOffset === sumV . trailOffsets
--   
--   </pre>
--   
--   but is more efficient.
--   
--   
--   <pre>
--   trailOffsetEx = (strokeLine almostClosed &lt;&gt; showOffset) # centerXY # pad 1.1
--     where showOffset = fromOffsets [trailOffset (wrapLine almostClosed)]
--                      # strokeP # lc red
--   </pre>
trailOffset :: (Metric v, OrderedField n) => Trail v n -> v n

-- | Extract the offsets of the segments of a line.
lineOffsets :: Trail' Line v n -> [v n]

-- | Compute the offset from the start of a line to the end. (Note, there
--   is no corresponding <tt>loopOffset</tt> function because by definition
--   it would be constantly zero.)
lineOffset :: (Metric v, OrderedField n) => Trail' Line v n -> v n

-- | Extract the offsets of the segments of a loop.
loopOffsets :: (Metric v, OrderedField n) => Trail' Loop v n -> [v n]

-- | Extract the vertices of a concretely located trail. Here a
--   <i>vertex</i> is defined as a non-differentiable point on the trail,
--   <i>i.e.</i> a sharp corner. (Vertices are thus a subset of the places
--   where segments join; if you want all joins between segments, see
--   <a>trailPoints</a>.) The tolerance determines how close the tangents
--   of two segments must be at their endpoints to consider the transition
--   point to be differentiable.
--   
--   Note that for loops, the starting vertex will <i>not</i> be repeated
--   at the end. If you want this behavior, you can use <a>cutTrail</a> to
--   make the loop into a line first, which happens to repeat the same
--   vertex at the start and end, <i>e.g.</i> with <tt>trailVertices .
--   mapLoc cutTrail</tt>.
--   
--   It does not make sense to ask for the vertices of a <a>Trail</a> by
--   itself; if you want the vertices of a trail with the first vertex at,
--   say, the origin, you can use <tt>trailVertices . (`at` origin)</tt>.
trailVertices' :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => n -> Located (Trail v n) -> [Point v n]

-- | Extract the vertices of a concretely located line. See
--   <a>trailVertices</a> for more information.
lineVertices' :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => n -> Located (Trail' Line v n) -> [Point v n]

-- | Extract the vertices of a concretely located loop. Note that the
--   initial vertex is not repeated at the end. See <a>trailVertices</a>
--   for more information.
loopVertices' :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => n -> Located (Trail' Loop v n) -> [Point v n]

-- | Like <a>trailVertices'</a>, with a default tolerance.
trailVertices :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Located (Trail v n) -> [Point v n]

-- | Like <a>lineVertices'</a>, with a default tolerance.
lineVertices :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Located (Trail' Line v n) -> [Point v n]

-- | Same as <a>loopVertices'</a>, with a default tolerance.
loopVertices :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Located (Trail' Loop v n) -> [Point v n]

-- | Convert a concretely located trail into a list of located segments.
trailLocSegments :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Located (Trail v n) -> [Located (Segment Closed v n)]

-- | Convert a concretely located trail into a list of fixed segments.
--   <a>unfixTrail</a> is almost its left inverse.
fixTrail :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Located (Trail v n) -> [FixedSegment v n]

-- | Convert a list of fixed segments into a located trail. Note that this
--   may lose information: it throws away the locations of all but the
--   first <tt>FixedSegment</tt>. This does not matter precisely when each
--   <tt>FixedSegment</tt> begins where the previous one ends.
--   
--   This is almost left inverse to <a>fixTrail</a>, that is,
--   <tt>unfixTrail . fixTrail == id</tt>, except for the fact that
--   <tt>unfixTrail</tt> will never yield a <tt>Loop</tt>. In the case of a
--   loop, we instead have <tt>glueTrail . unfixTrail . fixTrail ==
--   id</tt>. On the other hand, it is not the case that <tt>fixTrail .
--   unfixTrail == id</tt> since <tt>unfixTrail</tt> may lose information.
unfixTrail :: forall (v :: Type -> Type) n. (Metric v, Ord n, Floating n) => [FixedSegment v n] -> Located (Trail v n)

-- | Reverse a trail. Semantically, if a trail given by a function t from
--   [0,1] to vectors, then the reverse of t is given by t'(s) = t(1-s).
--   <tt>reverseTrail</tt> is an involution, that is,
--   
--   <pre>
--   reverseTrail . reverseTrail === id
--   
--   </pre>
reverseTrail :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail v n -> Trail v n

-- | Reverse a concretely located trail. The endpoint of the original trail
--   becomes the starting point of the reversed trail, so the original and
--   reversed trails comprise exactly the same set of points.
--   <tt>reverseLocTrail</tt> is an involution, <i>i.e.</i>
--   
--   <pre>
--   reverseLocTrail . reverseLocTrail === id
--   
--   </pre>
reverseLocTrail :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Located (Trail v n) -> Located (Trail v n)

-- | Reverse a line. See <a>reverseTrail</a>.
reverseLine :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail' Line v n -> Trail' Line v n

-- | Reverse a concretely located line. See <a>reverseLocTrail</a>.
reverseLocLine :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Located (Trail' Line v n) -> Located (Trail' Line v n)

-- | Reverse a loop. See <a>reverseTrail</a>.
reverseLoop :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail' Loop v n -> Trail' Loop v n

-- | Reverse a concretely located loop. See <a>reverseLocTrail</a>. Note
--   that this is guaranteed to preserve the location.
reverseLocLoop :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Located (Trail' Loop v n) -> Located (Trail' Loop v n)

-- | Type tag for "loopy" trails which return to their starting point.
data Loop

-- | A <tt>SegTree</tt> represents a sequence of closed segments, stored in
--   a fingertree so we can easily recover various monoidal measures of the
--   segments (number of segments, arc length, envelope...) and also easily
--   slice and dice them according to the measures (<i>e.g.</i>, split off
--   the smallest number of segments from the beginning which have a
--   combined arc length of at least 5).
newtype SegTree (v :: Type -> Type) n
SegTree :: FingerTree (SegMeasure v n) (Segment Closed v n) -> SegTree (v :: Type -> Type) n

-- | Given a default result (to be used in the case of an empty trail), and
--   a function to map a single measure to a result, extract the given
--   measure for a trail and use it to compute a result. Put another way,
--   lift a function on a single measure (along with a default value) to a
--   function on an entire trail.
trailMeasure :: forall (v :: Type -> Type) n m t a. (SegMeasure v n :>: m, Measured (SegMeasure v n) t) => a -> (m -> a) -> t -> a

-- | Compute the number of segments of anything measured by
--   <a>SegMeasure</a> (<i>e.g.</i> <tt>SegMeasure</tt> itself,
--   <tt>Segment</tt>, <tt>SegTree</tt>, <tt>Trail</tt>s...)
numSegs :: forall c (v :: Type -> Type) n a. (Num c, Measured (SegMeasure v n) a) => a -> c

-- | A newtype wrapper around trails which exists solely for its
--   <a>Parametric</a>, <a>DomainBounds</a> and <a>EndValues</a> instances.
--   The idea is that if <tt>tr</tt> is a trail, you can write, <i>e.g.</i>
--   
--   <pre>
--   getSegment tr <a>atParam</a> 0.6
--   
--   </pre>
--   
--   or
--   
--   <pre>
--   atStart (getSegment tr)
--   
--   </pre>
--   
--   to get the segment at parameter 0.6 or the first segment in the trail,
--   respectively.
--   
--   The codomain for <a>GetSegment</a>, <i>i.e.</i> the result you get
--   from calling <a>atParam</a>, <a>atStart</a>, or <a>atEnd</a>, is
--   <a>GetSegmentCodomain</a>, which is a newtype wrapper around <tt>Maybe
--   (v, Segment Closed v, AnIso' n n)</tt>. <tt>Nothing</tt> results if
--   the trail is empty; otherwise, you get:
--   
--   <ul>
--   <li>the offset from the start of the trail to the beginning of the
--   segment,</li>
--   <li>the segment itself, and</li>
--   <li>a reparameterization isomorphism: in the forward direction, it
--   translates from parameters on the whole trail to a parameters on the
--   segment. Note that for technical reasons you have to call
--   <a>cloneIso</a> on the <tt>AnIso'</tt> value to get a real isomorphism
--   you can use.</li>
--   </ul>
newtype GetSegment t
GetSegment :: t -> GetSegment t

-- | Create a <a>GetSegment</a> wrapper around a trail, after which you can
--   call <a>atParam</a>, <a>atStart</a>, or <a>atEnd</a> to extract a
--   segment.
getSegment :: t -> GetSegment t
newtype GetSegmentCodomain (v :: Type -> Type) n
GetSegmentCodomain :: Maybe (v n, Segment Closed v n, AnIso' n n) -> GetSegmentCodomain (v :: Type -> Type) n

-- | A <i>path</i> is a (possibly empty) list of <a>Located</a>
--   <a>Trail</a>s. Hence, unlike trails, paths are not translationally
--   invariant, and they form a monoid under <i>superposition</i> (placing
--   one path on top of another) rather than concatenation.
newtype Path (v :: Type -> Type) n
Path :: [Located (Trail v n)] -> Path (v :: Type -> Type) n

-- | Extract the located trails making up a <a>Path</a>.
pathTrails :: forall (v :: Type -> Type) n. Path v n -> [Located (Trail v n)]

-- | Type class for things that can be converted to a <a>Path</a>.
--   
--   Note that this class is very different from <a>TrailLike</a>.
--   <a>TrailLike</a> is usually the result of a library function to give
--   you a convenient, polymorphic result (<a>Path</a>, <a>Diagram</a>
--   etc.).
class ToPath t

-- | <a>toPath</a> takes something that can be converted to <a>Path</a> and
--   returns the <a>Path</a>.
toPath :: ToPath t => t -> Path (V t) (N t)

-- | Convert a trail to a path beginning at the origin.
pathFromTrail :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail v n -> Path v n

-- | Convert a trail to a path with a particular starting point.
pathFromTrailAt :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Trail v n -> Point v n -> Path v n

-- | Convert a located trail to a singleton path. This is equivalent to
--   <a>trailLike</a>, but provided with a more specific name and type for
--   convenience.
pathFromLocTrail :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Located (Trail v n) -> Path v n

-- | Extract the vertices of a path, resulting in a separate list of
--   vertices for each component trail. Here a <i>vertex</i> is defined as
--   a non-differentiable point on the trail, <i>i.e.</i> a sharp corner.
--   (Vertices are thus a subset of the places where segments join; if you
--   want all joins between segments, see <a>pathPoints</a>.) The tolerance
--   determines how close the tangents of two segments must be at their
--   endpoints to consider the transition point to be differentiable. See
--   <a>trailVertices</a> for more information.
pathVertices' :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => n -> Path v n -> [[Point v n]]

-- | Like <a>pathVertices'</a>, with a default tolerance.
pathVertices :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Path v n -> [[Point v n]]

-- | Compute the total offset of each trail comprising a path (see
--   <a>trailOffset</a>).
pathOffsets :: (Metric v, OrderedField n) => Path v n -> [v n]

-- | Compute the <i>centroid</i> of a path (<i>i.e.</i> the average
--   location of its <i>vertices</i>; see <a>pathVertices</a>).
pathCentroid :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Path v n -> Point v n

-- | Convert a path into a list of lists of located segments.
pathLocSegments :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Path v n -> [[Located (Segment Closed v n)]]

-- | Convert a path into a list of lists of <a>FixedSegment</a>s.
fixPath :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Path v n -> [[FixedSegment v n]]

-- | Scale a path using its centroid (see <a>pathCentroid</a>) as the base
--   point for the scale.
scalePath :: forall (v :: Type -> Type) n. (HasLinearMap v, Metric v, OrderedField n) => n -> Path v n -> Path v n

-- | Reverse all the component trails of a path.
reversePath :: forall (v :: Type -> Type) n. (Metric v, OrderedField n) => Path v n -> Path v n

-- | "Explode" a path by exploding every component trail (see
--   <a>explodeTrail</a>).
explodePath :: forall t (v :: Type -> Type) n. (V t ~ v, N t ~ n, TrailLike t) => Path v n -> [[t]]

-- | Partition a path into two paths based on a predicate on trails: the
--   first containing all the trails for which the predicate returns
--   <tt>True</tt>, and the second containing the remaining trails.
partitionPath :: forall (v :: Type -> Type) n. (Located (Trail v n) -> Bool) -> Path v n -> (Path v n, Path v n)

-- | A vector is described by a <tt>Direction</tt> and a magnitude. So we
--   can think of a <tt>Direction</tt> as a vector that has forgotten its
--   magnitude. <tt>Direction</tt>s can be used with <a>fromDirection</a>
--   and the lenses provided by its instances.
data Direction (v :: Type -> Type) n

-- | _Dir is provided to allow efficient implementations of functions in
--   particular vector-spaces, but should be used with care as it exposes
--   too much information.
_Dir :: forall v n p f. (Profunctor p, Functor f) => p (v n) (f (v n)) -> p (Direction v n) (f (Direction v n))

-- | <tt>direction v</tt> is the direction in which <tt>v</tt> points.
--   Returns an unspecified value when given the zero vector as input.
direction :: v n -> Direction v n

-- | <tt>fromDirection d</tt> is the unit vector in the direction
--   <tt>d</tt>.
fromDirection :: (Metric v, Floating n) => Direction v n -> v n

-- | Synonym for <a>fromDirection</a>.
fromDir :: (Metric v, Floating n) => Direction v n -> v n

-- | compute the positive angle between the two directions in their common
--   plane
angleBetweenDirs :: forall (v :: Type -> Type) n. (Metric v, Floating n, Ord n) => Direction v n -> Direction v n -> Angle n

-- | <tt>dirBetween p q</tt> returns the direction from <tt>p</tt> to
--   <tt>q</tt>.
dirBetween :: forall (v :: Type -> Type) n. (Additive v, Num n) => Point v n -> Point v n -> Direction v n


-- | A module to re-export most of the functionality of the diagrams core
--   and standard library.
module Diagrams.Prelude
class ColourOps (f :: Type -> Type)

-- | <tt>darken s c</tt> blends a colour with black without changing it's
--   opacity.
--   
--   For <a>Colour</a>, <tt>darken s c = blend s c mempty</tt>
darken :: (ColourOps f, Num a) => a -> f a -> f a

-- | This type represents a <a>Colour</a> that may be semi-transparent.
--   
--   The <a>Monoid</a> instance allows you to composite colours.
--   
--   <pre>
--   x `mappend` y == x `over` y
--   </pre>
--   
--   To get the (pre-multiplied) colour channel of an <a>AlphaColour</a>
--   <tt>c</tt>, simply composite <tt>c</tt> over black.
--   
--   <pre>
--   c `over` black
--   </pre>
data AlphaColour a

-- | This type represents the human preception of colour. The <tt>a</tt>
--   parameter is a numeric type used internally for the representation.
--   
--   The <a>Monoid</a> instance allows one to add colours, but beware that
--   adding colours can take you out of gamut. Consider using <a>blend</a>
--   whenever possible.
data Colour a

-- | Change the type used to represent the colour coordinates.
colourConvert :: (Fractional b, Real a) => Colour a -> Colour b
black :: Num a => Colour a

-- | This <a>AlphaColour</a> is entirely transparent and has no associated
--   colour channel.
transparent :: Num a => AlphaColour a

-- | Change the type used to represent the colour coordinates.
alphaColourConvert :: (Fractional b, Real a) => AlphaColour a -> AlphaColour b

-- | Creates an opaque <a>AlphaColour</a> from a <a>Colour</a>.
opaque :: Num a => Colour a -> AlphaColour a

-- | Returns an <a>AlphaColour</a> more transparent by a factor of
--   <tt>o</tt>.
dissolve :: Num a => a -> AlphaColour a -> AlphaColour a

-- | Creates an <a>AlphaColour</a> from a <a>Colour</a> with a given
--   opacity.
--   
--   <pre>
--   c `withOpacity` o == dissolve o (opaque c)
--   </pre>
withOpacity :: Num a => Colour a -> a -> AlphaColour a

-- | Compute the weighted average of two points. e.g.
--   
--   <pre>
--   blend 0.4 a b = 0.4*a + 0.6*b
--   </pre>
--   
--   The weight can be negative, or greater than 1.0; however, be aware
--   that non-convex combinations may lead to out of gamut colours.
blend :: (Num a, AffineSpace f) => a -> f a -> f a -> f a

-- | Returns the opacity of an <a>AlphaColour</a>.
alphaChannel :: AlphaColour a -> a
black :: Num a => Colour a
readColourName :: (MonadFail m, Monad m, Ord a, Floating a) => String -> m (Colour a)
aliceblue :: (Ord a, Floating a) => Colour a
antiquewhite :: (Ord a, Floating a) => Colour a
aqua :: (Ord a, Floating a) => Colour a
aquamarine :: (Ord a, Floating a) => Colour a
azure :: (Ord a, Floating a) => Colour a
beige :: (Ord a, Floating a) => Colour a
bisque :: (Ord a, Floating a) => Colour a
blanchedalmond :: (Ord a, Floating a) => Colour a
blue :: (Ord a, Floating a) => Colour a
blueviolet :: (Ord a, Floating a) => Colour a
brown :: (Ord a, Floating a) => Colour a
burlywood :: (Ord a, Floating a) => Colour a
cadetblue :: (Ord a, Floating a) => Colour a
chartreuse :: (Ord a, Floating a) => Colour a
chocolate :: (Ord a, Floating a) => Colour a
coral :: (Ord a, Floating a) => Colour a
cornflowerblue :: (Ord a, Floating a) => Colour a
cornsilk :: (Ord a, Floating a) => Colour a
crimson :: (Ord a, Floating a) => Colour a
cyan :: (Ord a, Floating a) => Colour a
darkblue :: (Ord a, Floating a) => Colour a
darkcyan :: (Ord a, Floating a) => Colour a
darkgoldenrod :: (Ord a, Floating a) => Colour a
darkgray :: (Ord a, Floating a) => Colour a
darkgreen :: (Ord a, Floating a) => Colour a
darkgrey :: (Ord a, Floating a) => Colour a
darkkhaki :: (Ord a, Floating a) => Colour a
darkmagenta :: (Ord a, Floating a) => Colour a
darkolivegreen :: (Ord a, Floating a) => Colour a
darkorange :: (Ord a, Floating a) => Colour a
darkorchid :: (Ord a, Floating a) => Colour a
darkred :: (Ord a, Floating a) => Colour a
darksalmon :: (Ord a, Floating a) => Colour a
darkseagreen :: (Ord a, Floating a) => Colour a
darkslateblue :: (Ord a, Floating a) => Colour a
darkslategray :: (Ord a, Floating a) => Colour a
darkslategrey :: (Ord a, Floating a) => Colour a
darkturquoise :: (Ord a, Floating a) => Colour a
darkviolet :: (Ord a, Floating a) => Colour a
deeppink :: (Ord a, Floating a) => Colour a
deepskyblue :: (Ord a, Floating a) => Colour a
dimgray :: (Ord a, Floating a) => Colour a
dimgrey :: (Ord a, Floating a) => Colour a
dodgerblue :: (Ord a, Floating a) => Colour a
firebrick :: (Ord a, Floating a) => Colour a
floralwhite :: (Ord a, Floating a) => Colour a
forestgreen :: (Ord a, Floating a) => Colour a
fuchsia :: (Ord a, Floating a) => Colour a
gainsboro :: (Ord a, Floating a) => Colour a
ghostwhite :: (Ord a, Floating a) => Colour a
gold :: (Ord a, Floating a) => Colour a
goldenrod :: (Ord a, Floating a) => Colour a
gray :: (Ord a, Floating a) => Colour a
grey :: (Ord a, Floating a) => Colour a
green :: (Ord a, Floating a) => Colour a
greenyellow :: (Ord a, Floating a) => Colour a
honeydew :: (Ord a, Floating a) => Colour a
hotpink :: (Ord a, Floating a) => Colour a
indianred :: (Ord a, Floating a) => Colour a
indigo :: (Ord a, Floating a) => Colour a
ivory :: (Ord a, Floating a) => Colour a
khaki :: (Ord a, Floating a) => Colour a
lavender :: (Ord a, Floating a) => Colour a
lavenderblush :: (Ord a, Floating a) => Colour a
lawngreen :: (Ord a, Floating a) => Colour a
lemonchiffon :: (Ord a, Floating a) => Colour a
lightblue :: (Ord a, Floating a) => Colour a
lightcoral :: (Ord a, Floating a) => Colour a
lightcyan :: (Ord a, Floating a) => Colour a
lightgoldenrodyellow :: (Ord a, Floating a) => Colour a
lightgray :: (Ord a, Floating a) => Colour a
lightgreen :: (Ord a, Floating a) => Colour a
lightgrey :: (Ord a, Floating a) => Colour a
lightpink :: (Ord a, Floating a) => Colour a
lightsalmon :: (Ord a, Floating a) => Colour a
lightseagreen :: (Ord a, Floating a) => Colour a
lightskyblue :: (Ord a, Floating a) => Colour a
lightslategray :: (Ord a, Floating a) => Colour a
lightslategrey :: (Ord a, Floating a) => Colour a
lightsteelblue :: (Ord a, Floating a) => Colour a
lightyellow :: (Ord a, Floating a) => Colour a
lime :: (Ord a, Floating a) => Colour a
limegreen :: (Ord a, Floating a) => Colour a
linen :: (Ord a, Floating a) => Colour a
magenta :: (Ord a, Floating a) => Colour a
maroon :: (Ord a, Floating a) => Colour a
mediumaquamarine :: (Ord a, Floating a) => Colour a
mediumblue :: (Ord a, Floating a) => Colour a
mediumorchid :: (Ord a, Floating a) => Colour a
mediumpurple :: (Ord a, Floating a) => Colour a
mediumseagreen :: (Ord a, Floating a) => Colour a
mediumslateblue :: (Ord a, Floating a) => Colour a
mediumspringgreen :: (Ord a, Floating a) => Colour a
mediumturquoise :: (Ord a, Floating a) => Colour a
mediumvioletred :: (Ord a, Floating a) => Colour a
midnightblue :: (Ord a, Floating a) => Colour a
mintcream :: (Ord a, Floating a) => Colour a
mistyrose :: (Ord a, Floating a) => Colour a
moccasin :: (Ord a, Floating a) => Colour a
navajowhite :: (Ord a, Floating a) => Colour a
navy :: (Ord a, Floating a) => Colour a
oldlace :: (Ord a, Floating a) => Colour a
olive :: (Ord a, Floating a) => Colour a
olivedrab :: (Ord a, Floating a) => Colour a
orange :: (Ord a, Floating a) => Colour a
orangered :: (Ord a, Floating a) => Colour a
orchid :: (Ord a, Floating a) => Colour a
palegoldenrod :: (Ord a, Floating a) => Colour a
palegreen :: (Ord a, Floating a) => Colour a
paleturquoise :: (Ord a, Floating a) => Colour a
palevioletred :: (Ord a, Floating a) => Colour a
papayawhip :: (Ord a, Floating a) => Colour a
peachpuff :: (Ord a, Floating a) => Colour a
peru :: (Ord a, Floating a) => Colour a
pink :: (Ord a, Floating a) => Colour a
plum :: (Ord a, Floating a) => Colour a
powderblue :: (Ord a, Floating a) => Colour a
purple :: (Ord a, Floating a) => Colour a
red :: (Ord a, Floating a) => Colour a
rosybrown :: (Ord a, Floating a) => Colour a
royalblue :: (Ord a, Floating a) => Colour a
saddlebrown :: (Ord a, Floating a) => Colour a
salmon :: (Ord a, Floating a) => Colour a
sandybrown :: (Ord a, Floating a) => Colour a
seagreen :: (Ord a, Floating a) => Colour a
seashell :: (Ord a, Floating a) => Colour a
sienna :: (Ord a, Floating a) => Colour a
silver :: (Ord a, Floating a) => Colour a
skyblue :: (Ord a, Floating a) => Colour a
slateblue :: (Ord a, Floating a) => Colour a
slategray :: (Ord a, Floating a) => Colour a
slategrey :: (Ord a, Floating a) => Colour a
snow :: (Ord a, Floating a) => Colour a
springgreen :: (Ord a, Floating a) => Colour a
steelblue :: (Ord a, Floating a) => Colour a
teal :: (Ord a, Floating a) => Colour a
thistle :: (Ord a, Floating a) => Colour a
tomato :: (Ord a, Floating a) => Colour a
turquoise :: (Ord a, Floating a) => Colour a
violet :: (Ord a, Floating a) => Colour a
wheat :: (Ord a, Floating a) => Colour a
white :: (Ord a, Floating a) => Colour a
whitesmoke :: (Ord a, Floating a) => Colour a
yellow :: (Ord a, Floating a) => Colour a
yellowgreen :: (Ord a, Floating a) => Colour a

-- | An <a>Iso</a> between the lazy variant of a structure and its strict
--   counterpart.
--   
--   <pre>
--   <a>strict</a> = <a>from</a> <a>lazy</a>
--   </pre>
strict :: Strict lazy strict => Iso' lazy strict

-- | 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>
--   
--   <pre>
--   <a>lens</a> :: (s -&gt; a) -&gt; (s -&gt; a -&gt; s) -&gt; <a>Lens'</a> s a
--   </pre>
lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b

-- | 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 :: Type -> Type). Applicative f => a -> f b -> s -> f t

-- | A form of <a>Traversal</a> that can be stored monomorphically in a
--   container.
newtype ReifiedTraversal s t a b
Traversal :: Traversal s t a b -> ReifiedTraversal s t a b
[runTraversal] :: ReifiedTraversal s t a b -> Traversal s t a b
pattern Empty :: AsEmpty s => 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 :: Type -> Type). (Contravariant f, Applicative f) => a -> f a -> s -> f s

-- | Reify a <a>Fold</a> so it can be stored safely in a container.
--   
--   This can also be useful for creatively combining folds as
--   <tt><a>ReifiedFold</a> s</tt> is isomorphic to <tt>ReaderT s []</tt>
--   and provides similar instances.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world")^..runFold ((,) &lt;$&gt; Fold _2 &lt;*&gt; Fold both)
--   [("world","hello"),("world","world")]
--   </pre>
newtype ReifiedFold s a
Fold :: Fold s a -> ReifiedFold s a
[runFold] :: ReifiedFold s a -> Fold s a
pattern List :: IsList l => [Item l] -> l

-- | 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 -> Optical' p (Indexed i) f a a

-- | The class of contravariant functors.
--   
--   Whereas in Haskell, one can think of a <a>Functor</a> as containing or
--   producing values, a contravariant functor is a functor that can be
--   thought of as <i>consuming</i> values.
--   
--   As an example, consider the type of predicate functions <tt>a -&gt;
--   Bool</tt>. One such predicate might be <tt>negative x = x &lt; 0</tt>,
--   which classifies integers as to whether they are negative. However,
--   given this predicate, we can re-use it in other situations, providing
--   we have a way to map values <i>to</i> integers. For instance, we can
--   use the <tt>negative</tt> predicate on a person's bank balance to work
--   out if they are currently overdrawn:
--   
--   <pre>
--   newtype Predicate a = Predicate { getPredicate :: a -&gt; Bool }
--   
--   instance Contravariant Predicate where
--     contramap :: (a' -&gt; a) -&gt; (Predicate a -&gt; Predicate a')
--     contramap f (Predicate p) = Predicate (p . f)
--                                            |   `- First, map the input...
--                                            `----- then apply the predicate.
--   
--   overdrawn :: Predicate Person
--   overdrawn = contramap personBankBalance negative
--   </pre>
--   
--   Any instance should be subject to the following laws:
--   
--   <ul>
--   <li><i>Identity</i> <tt><a>contramap</a> <a>id</a> =
--   <a>id</a></tt></li>
--   <li><i>Composition</i> <tt><a>contramap</a> (g . f) = <a>contramap</a>
--   f . <a>contramap</a> g</tt></li>
--   </ul>
--   
--   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 :: Type -> Type)
contramap :: Contravariant f => (a' -> a) -> f a -> f a'

-- | Replace all locations in the output with the same value. The default
--   definition is <tt><a>contramap</a> . <a>const</a></tt>, but this may
--   be overridden with a more efficient version.
(>$) :: Contravariant f => b -> f b -> f a
infixl 4 >$

-- | A bifunctor is a type constructor that takes two type arguments and is
--   a functor in <i>both</i> arguments. That is, unlike with
--   <a>Functor</a>, a type constructor such as <a>Either</a> does not need
--   to be partially applied for a <a>Bifunctor</a> instance, and the
--   methods in this class permit mapping functions over the <a>Left</a>
--   value or the <a>Right</a> value, or both at the same time.
--   
--   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.
--   
--   The class definition of a <a>Bifunctor</a> <tt>p</tt> uses the
--   <a>QuantifiedConstraints</a> language extension to quantify over the
--   first type argument <tt>a</tt> in its context. The context requires
--   that <tt>p a</tt> must be a <a>Functor</a> for all <tt>a</tt>. In
--   other words a partially applied <a>Bifunctor</a> must be a
--   <a>Functor</a>. This makes <a>Functor</a> a superclass of
--   <a>Bifunctor</a> such that a function with a <a>Bifunctor</a>
--   constraint may use <a>fmap</a> in its implementation. <a>Functor</a>
--   has been a quantified superclass of <a>Bifunctor</a> since
--   base-4.18.0.0.
--   
--   You can define a <a>Bifunctor</a> by either defining <a>bimap</a> or
--   by defining both <a>first</a> and <a>second</a>. The <a>second</a>
--   method must agree with <a>fmap</a>:
--   
--   <pre>
--   <a>second</a> ≡ <a>fmap</a>
--   </pre>
--   
--   From this it follows that:
--   
--   <pre>
--   <a>second</a> <a>id</a> ≡ <a>id</a>
--   </pre>
--   
--   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 forall a. () => Functor p a => Bifunctor (p :: Type -> Type -> Type)

-- | Map over both arguments at the same time.
--   
--   <pre>
--   <a>bimap</a> f g ≡ <a>first</a> f <a>.</a> <a>second</a> g
--   </pre>
--   
--   <h4><b>Examples</b></h4>
--   
--   <pre>
--   &gt;&gt;&gt; bimap toUpper (+1) ('j', 3)
--   ('J',4)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; bimap toUpper (+1) (Left 'j')
--   Left 'J'
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; bimap toUpper (+1) (Right 3)
--   Right 4
--   </pre>
bimap :: Bifunctor p => (a -> b) -> (c -> d) -> p a c -> p b d

-- | An <a>Iso</a> between the strict variant of a structure and its lazy
--   counterpart.
--   
--   <pre>
--   <a>lazy</a> = <a>from</a> <a>strict</a>
--   </pre>
lazy :: Strict lazy strict => Iso' strict lazy

-- | Functors representing data structures that can be transformed to
--   structures of the <i>same shape</i> by performing an
--   <a>Applicative</a> (or, therefore, <a>Monad</a>) action on each
--   element from left to right.
--   
--   A more detailed description of what <i>same shape</i> means, the
--   various methods, how traversals are constructed, and example advanced
--   use-cases can be found in the <b>Overview</b> section of
--   <a>Data.Traversable#overview</a>.
--   
--   For the class laws see the <b>Laws</b> section of
--   <a>Data.Traversable#laws</a>.
class (Functor t, Foldable t) => Traversable (t :: Type -> Type)

-- | Map each element of a structure to an action, evaluate these actions
--   from left to right, and collect the results. For a version that
--   ignores the results see <a>traverse_</a>.
--   
--   <h4><b>Examples</b></h4>
--   
--   Basic usage:
--   
--   In the first two examples we show each evaluated action mapping to the
--   output structure.
--   
--   <pre>
--   &gt;&gt;&gt; traverse Just [1,2,3,4]
--   Just [1,2,3,4]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; traverse id [Right 1, Right 2, Right 3, Right 4]
--   Right [1,2,3,4]
--   </pre>
--   
--   In the next examples, we show that <a>Nothing</a> and <a>Left</a>
--   values short circuit the created structure.
--   
--   <pre>
--   &gt;&gt;&gt; traverse (const Nothing) [1,2,3,4]
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; traverse (\x -&gt; if odd x then Just x else Nothing)  [1,2,3,4]
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; traverse id [Right 1, Right 2, Right 3, Right 4, Left 0]
--   Left 0
--   </pre>
traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)

-- | Attempt to extract the left-most element from a container, and a
--   version of the container without that element.
--   
--   <pre>
--   &gt;&gt;&gt; uncons []
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; uncons [a, b, c]
--   Just (a,[b,c])
--   </pre>
uncons :: Cons s s a a => s -> Maybe (a, s)

-- | Attempt to extract the right-most element from a container, and a
--   version of the container without that element.
--   
--   <pre>
--   &gt;&gt;&gt; unsnoc (LazyT.pack "hello!")
--   Just ("hello",'!')
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; unsnoc (LazyT.pack "")
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; unsnoc (Seq.fromList [b,c,a])
--   Just (fromList [b,c],a)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; unsnoc (Seq.fromList [])
--   Nothing
--   </pre>
unsnoc :: Snoc s s a a => s -> Maybe (s, a)

-- | Flipped version of <a>&lt;$&gt;</a>.
--   
--   <pre>
--   (<a>&lt;&amp;&gt;</a>) = <a>flip</a> <a>fmap</a>
--   </pre>
--   
--   <h4><b>Examples</b></h4>
--   
--   Apply <tt>(+1)</tt> to a list, a <a>Just</a> and a <a>Right</a>:
--   
--   <pre>
--   &gt;&gt;&gt; Just 2 &lt;&amp;&gt; (+1)
--   Just 3
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [1,2,3] &lt;&amp;&gt; (+1)
--   [2,3,4]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Right 3 &lt;&amp;&gt; (+1)
--   Right 4
--   </pre>
(<&>) :: Functor f => f a -> (a -> b) -> f b
infixl 1 <&>

-- | <a>&amp;</a> is a reverse application operator. This provides
--   notational convenience. Its precedence is one higher than that of the
--   forward application operator <a>$</a>, which allows <a>&amp;</a> to be
--   nested in <a>$</a>.
--   
--   This is a version of <tt><a>flip</a> <a>id</a></tt>, where <a>id</a>
--   is specialized from <tt>a -&gt; a</tt> to <tt>(a -&gt; b) -&gt; (a
--   -&gt; b)</tt> which by the associativity of <tt>(-&gt;)</tt> is <tt>(a
--   -&gt; b) -&gt; a -&gt; b</tt>. flipping this yields <tt>a -&gt; (a
--   -&gt; b) -&gt; b</tt> which is the type signature of <a>&amp;</a>
--   
--   <h4><b>Examples</b></h4>
--   
--   <pre>
--   &gt;&gt;&gt; 5 &amp; (+1) &amp; show
--   "6"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; sqrt $ [1 / n^2 | n &lt;- [1..1000]] &amp; sum &amp; (*6)
--   3.1406380562059946
--   </pre>
(&) :: a -> (a -> b) -> b
infixl 1 &

-- | Propositional equality. If <tt>a :~: b</tt> is inhabited by some
--   terminating value, then the type <tt>a</tt> is the same as the type
--   <tt>b</tt>. To use this equality in practice, pattern-match on the
--   <tt>a :~: b</tt> to get out the <tt>Refl</tt> constructor; in the body
--   of the pattern-match, the compiler knows that <tt>a ~ b</tt>.
data (a :: k) :~: (b :: k)
[Refl] :: forall {k} (a :: k). a :~: a
infix 4 :~:

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

-- | Build an (index-preserving) <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>
--   
--   <pre>
--   <a>to</a> :: (s -&gt; a) -&gt; <a>IndexPreservingGetter</a> s a
--   </pre>
to :: (Profunctor p, Contravariant f) => (s -> a) -> Optic' p f s a

-- | The <a>Const</a> functor.
--   
--   <h4><b>Examples</b></h4>
--   
--   <pre>
--   &gt;&gt;&gt; fmap (++ "World") (Const "Hello")
--   Const "Hello"
--   </pre>
--   
--   Because we ignore the second type parameter to <a>Const</a>, the
--   Applicative instance, which has <tt><a>(&lt;*&gt;)</a> :: Monoid m
--   =&gt; Const m (a -&gt; b) -&gt; Const m a -&gt; Const m b</tt>
--   essentially turns into <tt>Monoid m =&gt; m -&gt; m -&gt; m</tt>,
--   which is <a>(&lt;&gt;)</a>
--   
--   <pre>
--   &gt;&gt;&gt; Const [1, 2, 3] &lt;*&gt; Const [4, 5, 6]
--   Const [1,2,3,4,5,6]
--   </pre>
newtype Const a (b :: k)
Const :: a -> Const a (b :: k)
[getConst] :: Const a (b :: k) -> a

-- | Identity functor and monad. (a non-strict monad)
--   
--   <h4><b>Examples</b></h4>
--   
--   <pre>
--   &gt;&gt;&gt; fmap (+1) (Identity 0)
--   Identity 1
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Identity [1, 2, 3] &lt;&gt; Identity [4, 5, 6]
--   Identity [1,2,3,4,5,6]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; do
--         x &lt;- Identity 10
--         y &lt;- Identity (x + 5)
--         pure (x + y)
--   Identity 25
--   </pre>
newtype Identity a
Identity :: a -> Identity a
[runIdentity] :: Identity a -> a

-- | <a>cons</a> an element onto a container.
--   
--   This is an infix alias for <a>cons</a>.
--   
--   <pre>
--   &gt;&gt;&gt; a &lt;| []
--   [a]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; a &lt;| [b, c]
--   [a,b,c]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; a &lt;| Seq.fromList []
--   fromList [a]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; a &lt;| Seq.fromList [b, c]
--   fromList [a,b,c]
--   </pre>
(<|) :: Cons s s a a => a -> s -> s
infixr 5 <|

-- | <a>cons</a> an element onto a container.
--   
--   <pre>
--   &gt;&gt;&gt; cons a []
--   [a]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; cons a [b, c]
--   [a,b,c]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; cons a (Seq.fromList [])
--   fromList [a]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; cons a (Seq.fromList [b, c])
--   fromList [a,b,c]
--   </pre>
cons :: Cons s s a a => a -> s -> s
infixr 5 `cons`

-- | <a>snoc</a> an element onto a container.
--   
--   <pre>
--   &gt;&gt;&gt; snoc (Seq.fromList []) a
--   fromList [a]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; snoc (Seq.fromList [b, c]) a
--   fromList [b,c,a]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; snoc (LazyT.pack "hello") '!'
--   "hello!"
--   </pre>
snoc :: Snoc s s a a => s -> a -> s
infixl 5 `snoc`

-- | 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 :: ASetter s t a b -> (a -> b) -> s -> t
pattern (:>) :: Snoc a a b b => a -> b -> a
infixl 5 :>
pattern (:<) :: Cons b b a a => a -> b -> b
infixr 5 :<

-- | <a>snoc</a> an element onto a container.
--   
--   This is an infix alias for <a>snoc</a>.
--   
--   <pre>
--   &gt;&gt;&gt; Seq.fromList [] |&gt; a
--   fromList [a]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Seq.fromList [b, c] |&gt; a
--   fromList [b,c,a]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; LazyT.pack "hello" |&gt; '!'
--   "hello!"
--   </pre>
(|>) :: Snoc s s a a => s -> a -> s
infixl 5 |>
pattern Strict :: Strict s t => t -> s
pattern Lazy :: Strict t s => t -> s

-- | Isomorphism families can be composed with another <a>Lens</a> using
--   (<a>.</a>) and <a>id</a>.
--   
--   Since every <a>Iso</a> is both a valid <a>Lens</a> and a valid
--   <a>Prism</a>, the laws for those types imply the following laws for an
--   <a>Iso</a> <tt>f</tt>:
--   
--   <pre>
--   f <a>.</a> <a>from</a> f ≡ <a>id</a>
--   <a>from</a> f <a>.</a> f ≡ <a>id</a>
--   </pre>
--   
--   Note: Composition with an <a>Iso</a> is index- and measure-
--   preserving.
type Iso s t a b = forall (p :: Type -> Type -> Type) (f :: Type -> Type). (Profunctor p, Functor f) => p a f b -> p s f t

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

-- | 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.
--   
--   In addition, the index <tt>i</tt> should satisfy the requirement that
--   it stays unchanged even when modifying the value <tt>a</tt>, otherwise
--   traversals like <tt>indices</tt> break the <a>Traversal</a> laws.
type IndexedTraversal i s t a b = forall (p :: Type -> Type -> Type) (f :: Type -> Type). (Indexable i p, Applicative f) => p a f b -> s -> f t

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

-- | 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 :: Type -> Type -> Type) (f :: Type -> Type). (Indexable i p, Contravariant f, Applicative f) => p a f a -> s -> f s
newtype ReifiedIndexedFold i s a
IndexedFold :: IndexedFold i s a -> ReifiedIndexedFold i s a
[runIndexedFold] :: ReifiedIndexedFold i s a -> IndexedFold i s a

-- | A <a>Prism</a> <tt>l</tt> is a <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 three 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 by <tt>l</tt> and <tt>a</tt>:
--   
--   <pre>
--   <a>preview</a> l s ≡ <a>Just</a> a ⟹ <a>review</a> l a ≡ s
--   </pre>
--   
--   Third, if you get non-match <tt>t</tt>, you can convert it result back
--   to <tt>s</tt>:
--   
--   <pre>
--   <a>matching</a> l s ≡ <a>Left</a> t ⟹ <a>matching</a> l t ≡ <a>Left</a> s
--   </pre>
--   
--   The first 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 an <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 :: Type -> Type -> Type) (f :: Type -> Type). (Choice p, Applicative f) => p a f b -> p s f t

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

-- | 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 v s)  ≡ v
--   </pre>
--   
--   2) Putting back what you got doesn't change anything:
--   
--   <pre>
--   <a>set</a> l (<a>view</a> l s) s  ≡ s
--   </pre>
--   
--   3) Setting twice is the same as setting once:
--   
--   <pre>
--   <a>set</a> l v' (<a>set</a> l v s) ≡ <a>set</a> l v' s
--   </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>.
--   
--   There are some emergent properties of these laws:
--   
--   1) <tt><a>set</a> l s</tt> must be injective for every <tt>s</tt> This
--   is a consequence of law #1
--   
--   2) <tt><a>set</a> l</tt> must be surjective, because of law #2, which
--   indicates that it is possible to obtain any <tt>v</tt> from some
--   <tt>s</tt> such that <tt><a>set</a> s v = s</tt>
--   
--   3) Given just the first two laws you can prove a weaker form of law #3
--   where the values <tt>v</tt> that you are setting match:
--   
--   <pre>
--   <a>set</a> l v (<a>set</a> l v s) ≡ <a>set</a> l v s
--   </pre>
--   
--   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 :: Type -> Type). Functor f => a -> f b -> s -> f t

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

-- | 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 :: Type -> Type) (p :: Type -> Type -> Type). (Indexable i p, Functor f) => p a f b -> s -> f t

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

-- | 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>(s -&gt; a)</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 :: Type -> Type). (Contravariant f, Functor f) => a -> f a -> s -> f s

-- | Reify a <a>Getter</a> so it can be stored safely in a container.
--   
--   This can also be useful when combining getters in novel ways, as
--   <a>ReifiedGetter</a> is isomorphic to <tt>(-&gt;)</tt> and provides
--   similar instances.
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world","!!!")^.runGetter ((,) &lt;$&gt; Getter _2 &lt;*&gt; Getter (_1.to length))
--   ("world",5)
--   </pre>
newtype ReifiedGetter s a
Getter :: Getter s a -> ReifiedGetter s a
[runGetter] :: ReifiedGetter s a -> Getter s 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 :: Type -> Type -> Type) (f :: Type -> Type). (Indexable i p, Contravariant f, Functor f) => p a f a -> s -> f s

-- | Reify an <a>IndexedGetter</a> so it can be stored safely in a
--   container.
newtype ReifiedIndexedGetter i s a
IndexedGetter :: IndexedGetter i s a -> ReifiedIndexedGetter i s a
[runIndexedGetter] :: ReifiedIndexedGetter i s a -> IndexedGetter i s 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 :: k -> Type) s (t :: k) a (b :: k) = 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.
type Over (p :: k -> Type -> Type) (f :: k1 -> Type) s (t :: k1) (a :: k) (b :: k1) = p a f b -> s -> f t

-- | Retrieve the <tt>Last</tt> 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> <tt>Last</tt> <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

-- | 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><a>preview</a></tt> or <tt>^?'</tt> and gives you back access to
--   the outermost <a>Just</a> constructor more quickly, but does so in a
--   way that builds an intermediate structure, and thus may have worse
--   constant factors. This also means that it can not be used in any
--   <a>MonadReader</a>, but must instead have <tt>s</tt> passed as its
--   last argument, unlike <a>preview</a>.
--   
--   Note: this could been named <tt>headOf</tt>.
--   
--   <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

-- | Traverse over all of the targets of a <a>Fold1</a>, computing an
--   <a>Apply</a> based answer.
--   
--   As long as you have <a>Applicative</a> or <a>Functor</a> effect you
--   are better using <a>traverseOf_</a>. The <a>traverse1Of_</a> is useful
--   only when you have genuine <a>Apply</a> effect.
--   
--   <pre>
--   &gt;&gt;&gt; traverse1Of_ both1 (\ks -&gt; Map.fromList [ (k, ()) | k &lt;- ks ]) ("abc", "bcd")
--   fromList [('b',()),('c',())]
--   </pre>
--   
--   <pre>
--   <a>traverse1Of_</a> :: <a>Apply</a> f =&gt; <a>Fold1</a> s a -&gt; (a -&gt; f r) -&gt; s -&gt; f ()
--   </pre>
traverse1Of_ :: Functor f => Getting (TraversedF r f) s a -> (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>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_ :: Functor f => Getting (Traversed r f) s a -> (a -> f r) -> s -> f ()

-- | 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

-- | 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 :: Type -> Type -> Type) a b t
Bazaar :: (forall (f :: Type -> Type). Applicative f => p a (f b) -> f t) -> Bazaar (p :: Type -> Type -> Type) a b t
[runBazaar] :: Bazaar (p :: Type -> Type -> Type) a b t -> forall (f :: Type -> Type). Applicative f => p a (f b) -> f t

-- | 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>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
--   </pre>
taking :: (Conjoined p, Applicative f) => Int -> Traversing p f s t a a -> Over p f s t 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 :: Type -> Type). Settable f => a -> f b -> s -> f t

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

-- | 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 (MonadState s m, MonadState t n) => Zoom (m :: Type -> Type) (n :: Type -> Type) s t | m -> s, n -> t, m t -> n, n s -> m

-- | Run a monadic action in a larger <a>State</a> than it was defined in,
--   using a <a>Lens'</a> or <a>Traversal'</a>.
--   
--   This is commonly used to lift actions in a simpler <a>State</a>
--   <a>Monad</a> into a <a>State</a> <a>Monad</a> with a larger
--   <a>State</a> type.
--   
--   When applied to a <a>Traversal'</a> over multiple values, the actions
--   for each target are executed sequentially and the results are
--   aggregated.
--   
--   This can be used to edit pretty much any <a>Monad</a> transformer
--   stack with a <a>State</a> in it!
--   
--   <pre>
--   &gt;&gt;&gt; flip State.evalState (a,b) $ zoom _1 $ use id
--   a
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; flip State.execState (a,b) $ zoom _1 $ id .= c
--   (c,b)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; flip State.execState [(a,b),(c,d)] $ zoom traverse $ _2 %= f
--   [(a,f b),(c,f d)]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; flip State.runState [(a,b),(c,d)] $ zoom traverse $ _2 &lt;%= f
--   (f b &lt;&gt; f d &lt;&gt; mempty,[(a,f b),(c,f d)])
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; flip State.evalState (a,b) $ zoom both (use id)
--   a &lt;&gt; b
--   </pre>
--   
--   <pre>
--   <a>zoom</a> :: <a>Monad</a> m             =&gt; <a>Lens'</a> s t      -&gt; <a>StateT</a> t m a -&gt; <a>StateT</a> s m a
--   <a>zoom</a> :: (<a>Monad</a> m, <a>Monoid</a> c) =&gt; <a>Traversal'</a> s t -&gt; <a>StateT</a> t m c -&gt; <a>StateT</a> s m c
--   <a>zoom</a> :: (<a>Monad</a> m, <a>Monoid</a> w)             =&gt; <a>Lens'</a> s t      -&gt; <a>RWST</a> r w t m c -&gt; <a>RWST</a> r w s m c
--   <a>zoom</a> :: (<a>Monad</a> m, <a>Monoid</a> w, <a>Monoid</a> c) =&gt; <a>Traversal'</a> s t -&gt; <a>RWST</a> r w t m c -&gt; <a>RWST</a> r w s m c
--   <a>zoom</a> :: (<a>Monad</a> m, <a>Monoid</a> w, <tt>Error</tt> e)  =&gt; <a>Lens'</a> s t      -&gt; <tt>ErrorT</tt> e (<a>RWST</a> r w t m) c -&gt; <tt>ErrorT</tt> e (<a>RWST</a> r w s m) c
--   <a>zoom</a> :: (<a>Monad</a> m, <a>Monoid</a> w, <a>Monoid</a> c, <tt>Error</tt> e) =&gt; <a>Traversal'</a> s t -&gt; <tt>ErrorT</tt> e (<a>RWST</a> r w t m) c -&gt; <tt>ErrorT</tt> e (<a>RWST</a> r w s m) c
--   ...
--   </pre>
zoom :: Zoom m n s t => LensLike' (Zoomed m c) t s -> m c -> n c
infixr 2 `zoom`

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

-- | 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 a</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 -> Const r a -> s -> Const r s

-- | Map each part of a structure viewed through a <a>Lens</a>,
--   <a>Getter</a>, <a>Fold</a> or <a>Traversal</a> to a monoid and combine
--   the results.
--   
--   <pre>
--   &gt;&gt;&gt; foldMapOf (folded . both . _Just) Sum [(Just 21, Just 21)]
--   Sum {getSum = 42}
--   </pre>
--   
--   <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>Semigroup</a> r =&gt; <a>Fold1</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>Semigroup</a> r =&gt; <a>Traversal1'</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 :: Getting r s a -> (a -> r) -> s -> r

-- | 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 t 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 it may be beneficial to think of it as having one of
--   these slightly more liberal type signatures:
--   
--   <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 t b -> m t

-- | 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>firstOf</a> and <a>^?</a>, which are similar with some subtle
--   differences (explained below).
--   
--   <pre>
--   <a>listToMaybe</a> <a>.</a> <tt>toList</tt> ≡ <a>preview</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>preview</a> = <a>view</a> <a>.</a> <a>pre</a>
--   </pre>
--   
--   Unlike <a>^?</a>, this function uses a <a>MonadReader</a> to read the
--   value to be focused in on. This allows one to pass the value as the
--   last argument by using the <a>MonadReader</a> instance for <tt>(-&gt;)
--   s</tt> However, it may also be used as part of some deeply nested
--   transformer stack.
--   
--   <a>preview</a> uses a monoidal value to obtain the result. This means
--   that it generally has good performance, but can occasionally cause
--   space leaks or even stack overflows on some data types. There is
--   another function, <a>firstOf</a>, which avoids these issues at the
--   cost of a slight constant performance cost and a little less
--   flexibility.
--   
--   It may be helpful to think of <a>preview</a> as having one of the
--   following more specialized types:
--   
--   <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>
--   
--   <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)

-- | 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. This is because <a>^?</a> works by using the
--   <a>First</a> monoid, which can occasionally cause space leaks.
--   
--   <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>
--   
--   This operator works as an infix version of <a>preview</a>.
--   
--   <pre>
--   (<a>^?</a>) ≡ <a>flip</a> <a>preview</a>
--   </pre>
--   
--   It may be helpful to think of <a>^?</a> as having one of the following
--   more specialized types:
--   
--   <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
infixl 8 ^?

-- | Retrieve the value targeted by a <a>Prism</a> or return the original
--   value while allowing the type to change if it does not match.
--   
--   <pre>
--   &gt;&gt;&gt; matching _Just (Just 12)
--   Right 12
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; matching _Just (Nothing :: Maybe Int) :: Either (Maybe Bool) Int
--   Left Nothing
--   </pre>
matching :: APrism s t a b -> s -> Either t a

-- | 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

-- | 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

-- | 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 :: k1 -> k1 -> k2 -> k2 -> k) (s :: k1) (a :: k2) = f s s a 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.
--   
--   <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

-- | 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

-- | 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>runTraversal</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 (getting (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

-- | 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

-- | 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

-- | Access the 2nd field of a tuple.
--   
--   <pre>
--   &gt;&gt;&gt; _2 .~ "hello" $ (1,(),3,4)
--   (1,"hello",3,4)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (1,2,3,4) &amp; _2 *~ 3
--   (1,6,3,4)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; _2 print (1,2)
--   2
--   (1,())
--   </pre>
--   
--   <pre>
--   <a>anyOf</a> <a>_2</a> :: (s -&gt; <a>Bool</a>) -&gt; (a, s) -&gt; <a>Bool</a>
--   <a>traverse</a> <a>.</a> <a>_2</a> :: (<a>Applicative</a> f, <a>Traversable</a> t) =&gt; (a -&gt; f b) -&gt; t (s, a) -&gt; f (t (s, b))
--   <a>foldMapOf</a> (<a>traverse</a> <a>.</a> <a>_2</a>) :: (<a>Traversable</a> t, <a>Monoid</a> m) =&gt; (s -&gt; m) -&gt; t (b, s) -&gt; m
--   </pre>
_2 :: Field2 s t a b => Lens s t a b
($dm_2) :: (Field2 s t a b, Generic s, Generic t, GIxed N1 (Rep s) (Rep t) a b) => Lens s t a b
class Functor f => FunctorWithIndex i (f :: Type -> Type) | f -> i
imap :: FunctorWithIndex i f => (i -> a -> b) -> f a -> f b

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

-- | 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>Simple</a> <a>Setter</a>
--   </pre>
type Setter' s a = Setter s s a 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
infixl 8 ^.

-- | 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
infixr 4 .~

-- | 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>
(%~) :: ASetter s t a b -> (a -> b) -> s -> t
infixr 4 %~

-- | 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
infixr 4 +~

-- | <pre>
--   type <a>Iso'</a> = <a>Simple</a> <a>Iso</a>
--   </pre>
type Iso' s a = Iso s s a 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
infixr 4 -~

-- | 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
infixr 4 *~

-- | 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
infixr 4 //~

-- | 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
infixr 4 ^~

-- | 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
infixr 4 ^^~

-- | 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
infixr 4 **~

-- | 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
infixr 4 ||~

-- | 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
infixr 4 &&~

-- | 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>
--   
--   <a>?~</a> can be used type-changily:
--   
--   <pre>
--   &gt;&gt;&gt; ('a', ('b', 'c')) &amp; _2.both ?~ 'x'
--   ('a',(Just 'x',Just '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
infixr 4 ?~

-- | Modify the target of a <a>Semigroup</a> value by using
--   <tt>(<a>&lt;&gt;</a>)</tt>.
--   
--   <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>Semigroup</a> a =&gt; <a>Setter</a> s t a a    -&gt; a -&gt; s -&gt; t
--   (<a>&lt;&gt;~</a>) :: <a>Semigroup</a> a =&gt; <a>Iso</a> s t a a       -&gt; a -&gt; s -&gt; t
--   (<a>&lt;&gt;~</a>) :: <a>Semigroup</a> a =&gt; <a>Lens</a> s t a a      -&gt; a -&gt; s -&gt; t
--   (<a>&lt;&gt;~</a>) :: <a>Semigroup</a> a =&gt; <a>Traversal</a> s t a a -&gt; a -&gt; s -&gt; t
--   </pre>
(<>~) :: Semigroup a => ASetter s t a a -> a -> s -> t
infixr 4 <>~

-- | 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>
(%=) :: MonadState s m => ASetter s s a b -> (a -> b) -> m ()
infix 4 %=

-- | 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 ()
infix 4 +=

-- | 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 ()
infix 4 -=

-- | 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 ()
infix 4 *=

-- | 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 ()
infix 4 //=

-- | 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 ()
infix 4 ^=

-- | 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 ()
infix 4 ^^=

-- | 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 ()
infix 4 **=

-- | 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 ()
infix 4 ||=

-- | 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 ()
infix 4 &&=

-- | 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>
--   
--   <i>It puts the state in the monad or it gets the hose again.</i>
(.=) :: MonadState s m => ASetter s s a b -> b -> m ()
infix 4 .=

-- | 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 ()
infix 4 ?=

-- | Modify the target(s) of a <a>Lens'</a>, <a>Iso</a>, <a>Setter</a> or
--   <a>Traversal</a> by using <tt>(<a>&lt;&gt;</a>)</tt>.
--   
--   <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>Semigroup</a> a) =&gt; <a>Setter'</a> s a -&gt; a -&gt; m ()
--   (<a>&lt;&gt;=</a>) :: (<a>MonadState</a> s m, <a>Semigroup</a> a) =&gt; <a>Iso'</a> s a -&gt; a -&gt; m ()
--   (<a>&lt;&gt;=</a>) :: (<a>MonadState</a> s m, <a>Semigroup</a> a) =&gt; <a>Lens'</a> s a -&gt; a -&gt; m ()
--   (<a>&lt;&gt;=</a>) :: (<a>MonadState</a> s m, <a>Semigroup</a> a) =&gt; <a>Traversal'</a> s a -&gt; a -&gt; m ()
--   </pre>
(<>=) :: (MonadState s m, Semigroup a) => ASetter' s a -> a -> m ()
infix 4 <>=

-- | Modify the target of a <a>Semigroup</a> value by using
--   <tt>(<a>&lt;&gt;</a>)</tt>. However, unlike <a>&lt;&gt;~</a>, it is
--   prepend to the head side.
--   
--   <pre>
--   &gt;&gt;&gt; ["world"] &amp; id &lt;&gt;:~ ["hello"]
--   ["hello","world"]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (["world"], ["lens"]) &amp; _1 &lt;&gt;:~ ["hello"]
--   (["hello","world"],["lens"])
--   </pre>
(<>:~) :: Semigroup b => ASetter s t b b -> b -> s -> t
infixr 4 <>:~

-- | Modify the target(s) of a <a>Lens'</a>, <a>Iso</a>, <a>Setter</a> or
--   <a>Traversal</a> by using <tt>(<a>&lt;&gt;</a>)</tt>. However, unlike
--   <a>&lt;&gt;=</a>, it is prepend to the head side.
(<>:=) :: (MonadState s m, Semigroup a) => ASetter' s a -> a -> m ()
infix 4 <>:=

-- | Adjust every target of an <a>IndexedSetter</a>, <a>IndexedLens</a> or
--   <a>IndexedTraversal</a> with access to the index.
--   
--   <pre>
--   (<a>%@~</a>) ≡ <a>iover</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
infixr 4 %@~

-- | Fold a container with indices returning both the indices and the
--   values.
--   
--   The result is only valid to compose in a <tt>Traversal</tt>, if you
--   don't edit the index as edits to the index have no effect.
--   
--   <pre>
--   &gt;&gt;&gt; [10, 20, 30] ^.. ifolded . withIndex
--   [(0,10),(1,20),(2,30)]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [10, 20, 30] ^.. ifolded . withIndex . alongside negated (re _Show)
--   [(0,"10"),(-1,"20"),(-2,"30")]
--   </pre>
withIndex :: (Indexable i p, Functor f) => p (i, s) (f (j, t)) -> Indexed i s (f t)

-- | Set with pass-through.
--   
--   This is mostly present for consistency, but may be useful 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)
infixr 4 <.~

-- | 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
infix 4 <.=

-- | 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::Int))
--   True
--   </pre>
--   
--   <pre>
--   <a>any</a> ≡ <a>anyOf</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>ianyOf</a> l ≡ <a>anyOf</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 :: Getting Any s a -> (a -> Bool) -> s -> Bool

-- | 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

-- | <a>alongside</a> makes a <a>Lens</a> from two other lenses or a
--   <a>Getter</a> from two other getters by executing them on their
--   respective halves of a product.
--   
--   <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')
--   <a>alongside</a> :: <a>Getter</a> s   a   -&gt; <a>Getter</a> s'    a'    -&gt; <a>Getter</a> (s,s')        (a,a')
--   </pre>
alongside :: LensLike (AlongsideLeft f b') s t a b -> LensLike (AlongsideRight f t) s' t' a' b' -> LensLike f (s, s') (t, t') (a, a') (b, b')
class AsEmpty a

-- | <pre>
--   &gt;&gt;&gt; isn't _Empty [1,2,3]
--   True
--   </pre>
_Empty :: AsEmpty a => Prism' a ()
($dm_Empty) :: (AsEmpty a, Monoid a, Eq a) => Prism' 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>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
--   </pre>
dropping :: (Conjoined p, Applicative f) => Int -> Over p (Indexing f) s t a a -> Over p f s t a a

-- | Provides access to 1st field of a tuple.
class Field1 s t a b | s -> a, t -> b, s b -> t, t a -> s

-- | Access the 1st field of a tuple (and possibly change its type).
--   
--   <pre>
--   &gt;&gt;&gt; (1,2)^._1
--   1
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; _1 .~ "hello" $ (1,2)
--   ("hello",2)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (1,2) &amp; _1 .~ "hello"
--   ("hello",2)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; _1 putStrLn ("hello","world")
--   hello
--   ((),"world")
--   </pre>
--   
--   This can also be used on larger tuples as well:
--   
--   <pre>
--   &gt;&gt;&gt; (1,2,3,4,5) &amp; _1 +~ 41
--   (42,2,3,4,5)
--   </pre>
--   
--   <pre>
--   <a>_1</a> :: <a>Lens</a> (a,b) (a',b) a a'
--   <a>_1</a> :: <a>Lens</a> (a,b,c) (a',b,c) a a'
--   <a>_1</a> :: <a>Lens</a> (a,b,c,d) (a',b,c,d) a a'
--   ...
--   <a>_1</a> :: <a>Lens</a> (a,b,c,d,e,f,g,h,i) (a',b,c,d,e,f,g,h,i) a a'
--   </pre>
_1 :: Field1 s t a b => Lens s t a b
($dm_1) :: (Field1 s t a b, Generic s, Generic t, GIxed N0 (Rep s) (Rep t) a b) => Lens s t a b

-- | 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>
--   <a>itraverseOf</a> <tt>itraversed</tt> ≡ <tt>itraverse</tt>
--   </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>Apply</a> f       =&gt; <a>Traversal1</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 :: LensLike f s t a b -> (a -> f b) -> s -> f t

-- | 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 :: forall a c b p f. (Choice p, Applicative f) => p a (f b) -> p (Either a c) (f (Either b c))

-- | 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>
--   <tt>for</tt> ≡ <a>forOf</a> <a>traverse</a>
--   <a>ifor</a> l s ≡ <tt>for</tt> 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 :: LensLike f s t a b -> s -> (a -> f b) -> f t

-- | 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
--   <a>itraverseOf</a> :: <a>Apply</a> f       =&gt; <a>IndexedTraversal1</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

-- | 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
--   <a>imapMOf</a> :: <tt>Bind</tt>  m =&gt; <a>IndexedTraversal1</a> i s t a b -&gt; (i -&gt; a -&gt; m b) -&gt; s -&gt; m t
--   </pre>
imapMOf :: Over (Indexed i) (WrappedMonad m) s t a b -> (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
ifor :: (TraversableWithIndex i t, Applicative f) => t a -> (i -> a -> f b) -> f (t b)

-- | 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]

-- | 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>
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world") &amp; each.each %~ Char.toUpper
--   ("HELLO","WORLD")
--   </pre>
class Each s t a b | s -> a, t -> b, s b -> t, t a -> s
each :: Each s t a b => Traversal s t a b
($dmeach) :: forall (g :: Type -> Type). (Each s t a b, Traversable g, s ~ g a, t ~ g b) => Traversal s t a b

-- | 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 ≡ <tt>forM</tt> 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 :: LensLike (WrappedMonad m) s t a b -> (a -> m b) -> s -> m t

-- | <a>forMOf</a> is a flipped version of <a>mapMOf</a>, consistent with
--   the definition of <tt>forM</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; forMOf both (1,3) $ \x -&gt; [x, x + 1]
--   [(1,3),(1,4),(2,3),(2,4)]
--   </pre>
--   
--   <pre>
--   <tt>forM</tt> ≡ <a>forMOf</a> <a>traverse</a>
--   <a>forMOf</a> l ≡ <a>flip</a> (<a>mapMOf</a> l)
--   <a>iforMOf</a> l s ≡ <tt>forM</tt> 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 :: LensLike (WrappedMonad m) s t a b -> s -> (a -> m b) -> m t

-- | This generalizes <a>mapAccumR</a> to an arbitrary <a>Traversal</a>.
--   
--   <pre>
--   <tt>mapAccumR</tt> ≡ <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 :: LensLike (Backwards (State acc)) s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)

-- | This generalizes <a>mapAccumL</a> to an arbitrary <a>Traversal</a>.
--   
--   <pre>
--   <tt>mapAccumL</tt> ≡ <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 :: LensLike (State acc) s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)

-- | Fuse a composition of lenses using <a>Yoneda</a> to provide
--   <a>fmap</a> fusion.
--   
--   In general, given a pair of lenses <tt>foo</tt> and <tt>bar</tt>
--   
--   <pre>
--   fusing (foo.bar) = foo.bar
--   </pre>
--   
--   however, <tt>foo</tt> and <tt>bar</tt> are either going to <a>fmap</a>
--   internally or they are trivial.
--   
--   <a>fusing</a> exploits the <a>Yoneda</a> lemma to merge these separate
--   uses into a single <a>fmap</a>.
--   
--   This is particularly effective when the choice of functor <tt>f</tt>
--   is unknown at compile time or when the <a>Lens</a> <tt>foo.bar</tt> in
--   the above description is recursive or complex enough to prevent
--   inlining.
--   
--   <pre>
--   <a>fusing</a> :: <a>Lens</a> s t a b -&gt; <a>Lens</a> s t a b
--   </pre>
fusing :: Functor f => LensLike (Yoneda f) s t a b -> LensLike f s t a b

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

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

-- | 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 Product foldMap [1,2,3,4]
--   24
--   </pre>
--   
--   You may want to think of this combinator as having the following,
--   simpler, type.
--   
--   <pre>
--   ala :: Rewrapping s t =&gt; (Unwrapped s -&gt; s) -&gt; ((Unwrapped t -&gt; t) -&gt; e -&gt; s) -&gt; e -&gt; Unwrapped s
--   </pre>
ala :: (Functor f, Rewrapping s t) => (Unwrapped s -> s) -> ((Unwrapped t -> t) -> f s) -> f (Unwrapped 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>
--   alaf :: Rewrapping s t =&gt; (Unwrapped s -&gt; s) -&gt; ((r -&gt; t) -&gt; e -&gt; s) -&gt; (r -&gt; Unwrapped t) -&gt; e -&gt; Unwrapped s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; alaf Sum foldMap Prelude.length ["hello","world"]
--   10
--   </pre>
alaf :: (Functor f, Functor g, Rewrapping s t) => (Unwrapped s -> s) -> (f t -> g s) -> f (Unwrapped t) -> g (Unwrapped s)

-- | Modify the target(s) of a <a>Lens'</a>, <a>Iso</a>, <a>Setter</a> or
--   <a>Traversal</a> using <tt>(<a>&lt;|</a>)</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; (["world"], ["lens"]) &amp; _1 &lt;|~ "hello"
--   (["hello","world"],["lens"])
--   </pre>
(<|~) :: Cons b b a a => ASetter s t b b -> a -> s -> t
infixr 4 <|~

-- | Modify the target(s) of a <a>Lens'</a>, <a>Iso</a>, <a>Setter</a> or
--   <a>Traversal</a> using <tt>(<a>&lt;|</a>)</tt>.
(<|=) :: (MonadState s m, Cons b b a a) => ASetter s s b b -> a -> m ()
infix 4 <|=

-- | Modify the target(s) of a <a>Lens'</a>, <a>Iso</a>, <a>Setter</a> or
--   <a>Traversal</a> using <tt>(<a>|&gt;</a>)</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; (["world"], ["lens"]) &amp; _1 |&gt;~ "hello"
--   (["world","hello"],["lens"])
--   </pre>
(|>~) :: Snoc b b a a => ASetter s t b b -> a -> s -> t
infixr 4 |>~

-- | Modify the target(s) of a <a>Lens'</a>, <a>Iso</a>, <a>Setter</a> or
--   <a>Traversal</a> using <tt>(<a>|&gt;</a>)</tt>.
(|>=) :: (MonadState s m, Snoc b b a a) => ASetter s s b b -> a -> m ()
infix 4 |>=

-- | 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 :: Type -> Type) (n :: Type -> Type) b a | m -> b, n -> a, m a -> n, n b -> m

-- | Run a monadic action in a larger environment than it was defined in,
--   using a <a>Getter</a>.
--   
--   This acts like <a>local</a>, but can in many cases change the type of
--   the environment as well.
--   
--   This is commonly used to lift actions in a simpler <a>Reader</a>
--   <a>Monad</a> into a <a>Monad</a> with a larger environment type.
--   
--   This can be used to edit pretty much any <a>Monad</a> transformer
--   stack with an environment in it:
--   
--   <pre>
--   &gt;&gt;&gt; (1,2) &amp; magnify _2 (+1)
--   3
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; flip Reader.runReader (1,2) $ magnify _1 Reader.ask
--   1
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; flip Reader.runReader (1,2,[10..20]) $ magnify (_3._tail) Reader.ask
--   [11,12,13,14,15,16,17,18,19,20]
--   </pre>
--   
--   The type can be read as
--   
--   <pre>
--   magnify :: LensLike' (Magnified m c) a b -&gt; m c -&gt; n c
--   </pre>
--   
--   but the higher-rank constraints make it easier to apply
--   <tt>magnify</tt> to a <a>Getter</a> in highly-polymorphic code.
--   
--   <pre>
--   <a>magnify</a> :: <a>Getter</a> s a -&gt; (a -&gt; r) -&gt; s -&gt; r
--   <a>magnify</a> :: <a>Monoid</a> r =&gt; <a>Fold</a> s a   -&gt; (a -&gt; r) -&gt; s -&gt; r
--   </pre>
--   
--   <pre>
--   <a>magnify</a> :: <a>Monoid</a> w                 =&gt; <a>Getter</a> s t -&gt; <a>RWS</a> t w st c -&gt; <a>RWS</a> s w st c
--   <a>magnify</a> :: (<a>Monoid</a> w, <a>Monoid</a> c) =&gt; <a>Fold</a> s a   -&gt; <a>RWS</a> a w st c -&gt; <a>RWS</a> s w st c
--   ...
--   </pre>
magnify :: Magnify m n b a => ((Functor (Magnified m c), Contravariant (Magnified m c)) => LensLike' (Magnified m c) a b) -> m c -> n c
infixr 2 `magnify`

-- | 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>)
--   </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>)
--   </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

-- | <a>Traversal</a> of the immediate children of this structure.
--   
--   If you're using GHC 7.2 or newer and your type has a <a>Data</a>
--   instance, <a>plate</a> will default to <a>uniplate</a> and you can
--   choose to not override it with your own definition.
plate :: Plated a => Traversal' a a
($dmplate) :: (Plated a, Data a) => Traversal' a a

-- | 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

-- | Obtain a <a>Fold</a> from any <a>Foldable</a> indexed by ordinal
--   position.
--   
--   <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 :: forall (f :: Type -> Type) a. Foldable f => IndexedFold Int (f a) a

-- | Traverse both parts of a <a>Bitraversable</a> container with matching
--   types.
--   
--   Usually that type will be a pair. Use <a>each</a> to traverse the
--   elements of arbitrary homogeneous tuples.
--   
--   <pre>
--   &gt;&gt;&gt; (1,2) &amp; both *~ 10
--   (10,20)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over both length ("hello","world")
--   (5,5)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ("hello","world")^.both
--   "helloworld"
--   </pre>
--   
--   <pre>
--   <a>both</a> :: <a>Traversal</a> (a, a)       (b, b)       a b
--   <a>both</a> :: <a>Traversal</a> (<a>Either</a> a a) (<a>Either</a> b b) a b
--   </pre>
both :: forall (r :: Type -> Type -> Type) a b. Bitraversable r => Traversal (r a a) (r b b) a b

-- | <a>Wrapped</a> provides isomorphisms to wrap and unwrap newtypes or
--   data types with one constructor.
class Wrapped s where {
    type Unwrapped s;
    type Unwrapped s = GUnwrapped Rep s;
}

-- | An isomorphism between <tt>s</tt> and <tt>a</tt>.
--   
--   If your type has a <a>Generic</a> instance, <a>_Wrapped'</a> will
--   default to <a>_GWrapped'</a>, and you can choose to not override it
--   with your own definition.
_Wrapped' :: Wrapped s => Iso' s (Unwrapped s)
($dm_Wrapped') :: forall (d :: Meta) (c :: Meta) (s' :: Meta) a. (Wrapped s, Generic s, D1 d (C1 c (S1 s' (Rec0 a))) ~ Rep s, Unwrapped s ~ GUnwrapped (Rep s)) => Iso' s (Unwrapped s)
pattern Wrapped :: Rewrapped s s => Unwrapped s -> s

-- | 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)

-- | Try the first <a>Traversal</a> (or <a>Fold</a>), falling back on the
--   second <a>Traversal</a> (or <a>Fold</a>) if it returns no entries.
--   
--   This is only a valid <a>Traversal</a> if the second <a>Traversal</a>
--   is disjoint from the result of the first or returns exactly the same
--   results. These conditions are trivially met when given a <a>Lens</a>,
--   <a>Iso</a>, <a>Getter</a>, <a>Prism</a> or "affine" Traversal -- one
--   that has 0 or 1 target.
--   
--   Mutatis mutandis for <a>Fold</a>.
--   
--   <pre>
--   &gt;&gt;&gt; [0,1,2,3] ^? failing (ix 1) (ix 2)
--   Just 1
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [0,1,2,3] ^? failing (ix 42) (ix 2)
--   Just 2
--   </pre>
--   
--   <pre>
--   <a>failing</a> :: <a>Traversal</a> s t a b -&gt; <a>Traversal</a> s t a b -&gt; <a>Traversal</a> s t a b
--   <a>failing</a> :: <a>Prism</a> s t a b     -&gt; <a>Prism</a> s t a b     -&gt; <a>Traversal</a> s t a b
--   <a>failing</a> :: <a>Fold</a> s a          -&gt; <a>Fold</a> s a          -&gt; <a>Fold</a> s a
--   </pre>
--   
--   These cases are also supported, trivially, but are boring, because the
--   left hand side always succeeds.
--   
--   <pre>
--   <a>failing</a> :: <a>Lens</a> s t a b      -&gt; <a>Traversal</a> s t a b -&gt; <a>Traversal</a> s t a b
--   <a>failing</a> :: <a>Iso</a> s t a b       -&gt; <a>Traversal</a> s t a b -&gt; <a>Traversal</a> s t a b
--   <a>failing</a> :: <a>Equality</a> s t a b  -&gt; <a>Traversal</a> s t a b -&gt; <a>Traversal</a> s t a b
--   <a>failing</a> :: <a>Getter</a> s a        -&gt; <a>Fold</a> s a          -&gt; <a>Fold</a> s a
--   </pre>
--   
--   If both of the inputs are indexed, the result is also indexed, so you
--   can apply this to a pair of indexed traversals or indexed folds,
--   obtaining an indexed traversal or indexed fold.
--   
--   <pre>
--   <a>failing</a> :: <a>IndexedTraversal</a> i s t a b -&gt; <a>IndexedTraversal</a> i s t a b -&gt; <a>IndexedTraversal</a> i s t a b
--   <a>failing</a> :: <a>IndexedFold</a> i s a          -&gt; <a>IndexedFold</a> i s a          -&gt; <a>IndexedFold</a> i s a
--   </pre>
--   
--   These cases are also supported, trivially, but are boring, because the
--   left hand side always succeeds.
--   
--   <pre>
--   <a>failing</a> :: <a>IndexedLens</a> i s t a b      -&gt; <a>IndexedTraversal</a> i s t a b -&gt; <a>IndexedTraversal</a> i s t a b
--   <a>failing</a> :: <a>IndexedGetter</a> i s a        -&gt; <a>IndexedGetter</a> i s a        -&gt; <a>IndexedFold</a> i s a
--   </pre>
failing :: (Conjoined p, Applicative f) => Traversing p f s t a b -> Over p f s t a b -> Over p f s t a b
infixl 5 `failing`
class (FunctorWithIndex i t, FoldableWithIndex i t, Traversable t) => TraversableWithIndex i (t :: Type -> Type) | t -> i
itraverse :: (TraversableWithIndex i t, Applicative f) => (i -> a -> f b) -> t a -> f (t b)
class Foldable f => FoldableWithIndex i (f :: Type -> Type) | f -> i
ifoldMap :: (FoldableWithIndex i f, Monoid m) => (i -> a -> m) -> f a -> m
ifoldMap' :: (FoldableWithIndex i f, Monoid m) => (i -> a -> m) -> f a -> m
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
imapM :: (TraversableWithIndex i t, Monad m) => (i -> a -> m b) -> t a -> m (t b)
iforM :: (TraversableWithIndex i t, Monad m) => t a -> (i -> a -> m b) -> m (t b)
imapAccumR :: TraversableWithIndex i t => (i -> s -> a -> (s, b)) -> s -> t a -> (s, t b)
imapAccumL :: TraversableWithIndex i t => (i -> s -> a -> (s, b)) -> s -> t a -> (s, t b)
iany :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Bool
iall :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Bool
inone :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Bool
itraverse_ :: (FoldableWithIndex i t, Applicative f) => (i -> a -> f b) -> t a -> f ()
ifor_ :: (FoldableWithIndex i t, Applicative f) => t a -> (i -> a -> f b) -> f ()
imapM_ :: (FoldableWithIndex i t, Monad m) => (i -> a -> m b) -> t a -> m ()
iforM_ :: (FoldableWithIndex i t, Monad m) => t a -> (i -> a -> m b) -> m ()
iconcatMap :: FoldableWithIndex i f => (i -> a -> [b]) -> f a -> [b]
ifind :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Maybe (i, a)
ifoldrM :: (FoldableWithIndex i f, Monad m) => (i -> a -> b -> m b) -> b -> f a -> m b
ifoldlM :: (FoldableWithIndex i f, Monad m) => (i -> b -> a -> m b) -> b -> f a -> m b
itoList :: FoldableWithIndex i f => f a -> [(i, a)]

-- | 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 :: Type -> Type -> Type)

-- | Map over both arguments at the same time.
--   
--   <pre>
--   <a>dimap</a> f g ≡ <a>lmap</a> f <a>.</a> <a>rmap</a> g
--   </pre>
dimap :: Profunctor p => (a -> b) -> (c -> d) -> p b c -> p a d

-- | Map the first argument contravariantly.
--   
--   <pre>
--   <a>lmap</a> f ≡ <a>dimap</a> f <a>id</a>
--   </pre>
lmap :: Profunctor p => (a -> b) -> p b c -> p a c

-- | Map the second argument covariantly.
--   
--   <pre>
--   <a>rmap</a> ≡ <a>dimap</a> <a>id</a>
--   </pre>
rmap :: Profunctor p => (b -> c) -> p a b -> p a c

-- | The generalization of <a>Costar</a> of <a>Functor</a> that is strong
--   with respect to <a>Either</a>.
--   
--   Note: This is also a notion of strength, except with regards to
--   another monoidal structure that we can choose to equip Hask with: the
--   cocartesian coproduct.
class Profunctor p => Choice (p :: Type -> Type -> Type)

-- | Laws:
--   
--   <pre>
--   <a>left'</a> ≡ <a>dimap</a> swapE swapE <a>.</a> <a>right'</a> where
--     swapE :: <a>Either</a> a b -&gt; <a>Either</a> b a
--     swapE = <a>either</a> <a>Right</a> <a>Left</a>
--   <a>rmap</a> <a>Left</a> ≡ <a>lmap</a> <a>Left</a> <a>.</a> <a>left'</a>
--   <a>lmap</a> (<a>right</a> f) <a>.</a> <a>left'</a> ≡ <a>rmap</a> (<a>right</a> f) <a>.</a> <a>left'</a>
--   <a>left'</a> <a>.</a> <a>left'</a> ≡ <a>dimap</a> assocE unassocE <a>.</a> <a>left'</a> where
--     assocE :: <a>Either</a> (<a>Either</a> a b) c -&gt; <a>Either</a> a (<a>Either</a> b c)
--     assocE (<a>Left</a> (<a>Left</a> a)) = <a>Left</a> a
--     assocE (<a>Left</a> (<a>Right</a> b)) = <a>Right</a> (<a>Left</a> b)
--     assocE (<a>Right</a> c) = <a>Right</a> (<a>Right</a> c)
--     unassocE :: <a>Either</a> a (<a>Either</a> b c) -&gt; <a>Either</a> (<a>Either</a> a b) c
--     unassocE (<a>Left</a> a) = <a>Left</a> (<a>Left</a> a)
--     unassocE (<a>Right</a> (<a>Left</a> b)) = <a>Left</a> (<a>Right</a> b)
--     unassocE (<a>Right</a> (<a>Right</a> c)) = <a>Right</a> c
--   </pre>
left' :: Choice p => p a b -> p (Either a c) (Either b c)

-- | Laws:
--   
--   <pre>
--   <a>right'</a> ≡ <a>dimap</a> swapE swapE <a>.</a> <a>left'</a> where
--     swapE :: <a>Either</a> a b -&gt; <a>Either</a> b a
--     swapE = <a>either</a> <a>Right</a> <a>Left</a>
--   <a>rmap</a> <a>Right</a> ≡ <a>lmap</a> <a>Right</a> <a>.</a> <a>right'</a>
--   <a>lmap</a> (<a>left</a> f) <a>.</a> <a>right'</a> ≡ <a>rmap</a> (<a>left</a> f) <a>.</a> <a>right'</a>
--   <a>right'</a> <a>.</a> <a>right'</a> ≡ <a>dimap</a> unassocE assocE <a>.</a> <a>right'</a> where
--     assocE :: <a>Either</a> (<a>Either</a> a b) c -&gt; <a>Either</a> a (<a>Either</a> b c)
--     assocE (<a>Left</a> (<a>Left</a> a)) = <a>Left</a> a
--     assocE (<a>Left</a> (<a>Right</a> b)) = <a>Right</a> (<a>Left</a> b)
--     assocE (<a>Right</a> c) = <a>Right</a> (<a>Right</a> c)
--     unassocE :: <a>Either</a> a (<a>Either</a> b c) -&gt; <a>Either</a> (<a>Either</a> a b) c
--     unassocE (<a>Left</a> a) = <a>Left</a> (<a>Left</a> a)
--     unassocE (<a>Right</a> (<a>Left</a> b)) = <a>Left</a> (<a>Right</a> b)
--     unassocE (<a>Right</a> (<a>Right</a> c)) = <a>Right</a> c
--   </pre>
right' :: Choice p => p a b -> p (Either c a) (Either c b)
foldBy :: Foldable t => (a -> a -> a) -> a -> t a -> a
foldMapBy :: Foldable t => (r -> r -> r) -> r -> (a -> r) -> t a -> r
traverseBy :: Traversable t => (forall x. () => x -> f x) -> (forall x y. () => f (x -> y) -> f x -> f y) -> (a -> f b) -> t a -> f (t b)
sequenceBy :: Traversable t => (forall x. () => x -> f x) -> (forall x y. () => f (x -> y) -> f x -> f y) -> t (f a) -> f (t a)
class (Foldable1 t, Traversable t) => Traversable1 (t :: Type -> Type)
traverse1 :: (Traversable1 t, Apply f) => (a -> f b) -> t a -> f (t b)

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

-- | 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 class permits overloading of function application for things that
--   also admit a notion of a key or index.
class Conjoined p => Indexable i (p :: Type -> Type -> Type)

-- | 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, Costrong p, ArrowLoop p, ArrowApply p, ArrowChoice p, Closed p) => Conjoined (p :: Type -> Type -> Type)

-- | <a>Conjoined</a> is strong enough to let us distribute every
--   <a>Conjoined</a> <a>Profunctor</a> over every Haskell <a>Functor</a>.
--   This is effectively a generalization of <a>fmap</a>.
distrib :: (Conjoined p, Functor f) => p a b -> p (f a) (f b)

-- | This permits us to make a decision at an outermost point about whether
--   or not we use an index.
--   
--   Ideally any use of this function should be done in such a way so that
--   you compute the same answer, but this cannot be enforced at the type
--   level.
conjoined :: Conjoined p => (p ~ (->) => q (a -> b) r) -> q (p a b) r -> q (p 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>Over</a> p 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>Over</a> p 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

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

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

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

-- | Used internally by <a>mapM_</a> and the like.
--   
--   The argument <tt>a</tt> of the result should not be used!
--   
--   See 4.16 Changelog entry for the explanation of "why not Apply f
--   =&gt;"?
data Sequenced a (m :: Type -> Type)

-- | 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 :: Type -> Type)

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

-- | The indexed store can be used to characterize a <a>Lens</a> and is
--   used by <a>cloneLens</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

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

-- | 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>Bazaar1</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>Bazaar1</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>Bazaar1</a> holds many stores and you can easily
--   add more.
--   
--   This is a final encoding of <a>Bazaar1</a>.
newtype Bazaar1 (p :: Type -> Type -> Type) a b t
Bazaar1 :: (forall (f :: Type -> Type). Apply f => p a (f b) -> f t) -> Bazaar1 (p :: Type -> Type -> Type) a b t
[runBazaar1] :: Bazaar1 (p :: Type -> Type -> Type) a b t -> forall (f :: Type -> Type). Apply 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 :: Type -> Type -> Type) a = Bazaar p a a

-- | 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

-- | 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 :: Type -> Type -> Type)

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

-- | Anything <a>Settable</a> must be isomorphic to the <a>Identity</a>
--   <a>Functor</a>.
class (Applicative f, Distributive f, Traversable f) => Settable (f :: Type -> Type)

-- | 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 :: Type -> Type -> Type) (f :: Type -> Type) s a = Over p f s s a a

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

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

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

-- | <pre>
--   type <a>Optical'</a> p q f s a = <a>Simple</a> (<a>Optical</a> p q f) s a
--   </pre>
type Optical' (p :: k -> k1 -> Type) (q :: k -> k1 -> Type) (f :: k -> k1) (s :: k) (a :: k) = Optical p q f s s a a

-- | <pre>
--   type <a>LensLike</a> f s t a b = <a>Optical</a> (-&gt;) (-&gt;) f s t a b
--   </pre>
--   
--   <pre>
--   type <a>Over</a> p f s t a b = <a>Optical</a> p (-&gt;) f s t a b
--   </pre>
--   
--   <pre>
--   type <a>Optic</a> p f s t a b = <a>Optical</a> p p f s t a b
--   </pre>
type Optical (p :: k -> k1 -> Type) (q :: k2 -> k1 -> Type) (f :: k3 -> k1) (s :: k2) (t :: k3) (a :: k) (b :: k3) = p a f b -> q s f t

-- | <pre>
--   type <a>Optic'</a> p f s a = <a>Simple</a> (<a>Optic</a> p f) s a
--   </pre>
type Optic' (p :: k -> k1 -> Type) (f :: k -> k1) (s :: k) (a :: k) = Optic p f s s a a

-- | A valid <a>Optic</a> <tt>l</tt> should satisfy the laws:
--   
--   <pre>
--   l <a>pure</a> ≡ <a>pure</a>
--   l (<tt>Procompose</tt> f g) = <tt>Procompose</tt> (l f) (l g)
--   </pre>
--   
--   This gives rise to the laws for <a>Equality</a>, <a>Iso</a>,
--   <a>Prism</a>, <a>Lens</a>, <a>Traversal</a>, <a>Traversal1</a>,
--   <a>Setter</a>, <a>Fold</a>, <a>Fold1</a>, and <a>Getter</a> as well
--   along with their index-preserving variants.
--   
--   <pre>
--   type <a>LensLike</a> f s t a b = <a>Optic</a> (-&gt;) f s t a b
--   </pre>
type Optic (p :: k -> k1 -> Type) (f :: k2 -> k1) (s :: k) (t :: k2) (a :: k) (b :: k2) = p a f b -> p s f t
type IndexPreservingFold1 s a = forall (p :: Type -> Type -> Type) (f :: Type -> Type). (Conjoined p, Contravariant f, Apply f) => p a f a -> p s f s
type IndexedFold1 i s a = forall (p :: Type -> Type -> Type) (f :: Type -> Type). (Indexable i p, Contravariant f, Apply f) => p a f a -> s -> f s

-- | A relevant Fold (aka <a>Fold1</a>) has one or more targets.
type Fold1 s a = forall (f :: Type -> Type). (Contravariant f, Apply f) => a -> f a -> 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 :: Type -> Type -> Type) (f :: Type -> Type). (Conjoined p, Contravariant f, Applicative f) => p a f a -> p s f s

-- | 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 :: Type -> Type -> Type) (f :: Type -> Type). (Conjoined p, Contravariant f, Functor f) => p a f a -> p s f s

-- | Composable <a>asTypeOf</a>. Useful for constraining excess
--   polymorphism, <tt>foo . (id :: As Int) . bar</tt>.
type As (a :: k2) = Equality' a a

-- | A <a>Simple</a> <a>Equality</a>.
type Equality' (s :: k2) (a :: k2) = Equality s s a a

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

-- | 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 t b = Optic' Tagged :: Type -> Type -> Type Identity t b

-- | This is a limited form of a <a>Prism</a> that can only be used for
--   <tt>re</tt> 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 <tt>unto</tt>. You can also
--   use any <a>Prism</a> or <a>Iso</a> directly as a <a>Review</a>.
type Review t b = forall (p :: Type -> Type -> Type) (f :: Type -> Type). (Choice p, Bifunctor p, Settable f) => Optic' p f t b

-- | <pre>
--   type <tt>IndexedPreservingSetter'</tt> i = <a>Simple</a> <tt>IndexedPreservingSetter</tt>
--   </pre>
type IndexPreservingSetter' s a = IndexPreservingSetter 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 :: Type -> Type -> Type) (f :: Type -> Type). (Conjoined p, Settable f) => p a f b -> p 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>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 :: Type -> Type) (p :: Type -> Type -> Type). (Indexable i p, Settable f) => p a f b -> s -> f t

-- | Reify an <a>IndexedSetter</a> so it can be stored safely in a
--   container.
newtype ReifiedIndexedSetter i s t a b
IndexedSetter :: IndexedSetter i s t a b -> ReifiedIndexedSetter i s t a b
[runIndexedSetter] :: ReifiedIndexedSetter i s t a b -> IndexedSetter i s t a b
type IndexPreservingTraversal1' s a = IndexPreservingTraversal1 s s a a
type IndexPreservingTraversal1 s t a b = forall (p :: Type -> Type -> Type) (f :: Type -> Type). (Conjoined p, Apply 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>IndexPreservingTraversal</a> leaves any index it is composed
--   with alone.
type IndexPreservingTraversal s t a b = forall (p :: Type -> Type -> Type) (f :: Type -> Type). (Conjoined p, Applicative f) => p a f b -> p s f t
type IndexedTraversal1' i s a = IndexedTraversal1 i s s a a
type IndexedTraversal1 i s t a b = forall (p :: Type -> Type -> Type) (f :: Type -> Type). (Indexable i p, Apply 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
type Traversal1' s a = Traversal1 s s a a

-- | A <a>Traversal</a> which targets at least one element.
--   
--   Note that since <a>Apply</a> is not a superclass of
--   <a>Applicative</a>, a <a>Traversal1</a> cannot always be used in place
--   of a <a>Traversal</a>. In such circumstances <a>cloneTraversal</a>
--   will convert a <a>Traversal1</a> into a <a>Traversal</a>.
type Traversal1 s t a b = forall (f :: Type -> Type). Apply f => a -> f b -> 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 IndexPreservingLens s t a b = forall (p :: Type -> Type -> Type) (f :: Type -> Type). (Conjoined p, Functor f) => p a f b -> p 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

-- | 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 :: Type -> Type -> Type) s a = Setting p 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 :: Type -> Type -> Type) s t a b = p a Identity b -> s -> Identity 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

-- | 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.
type AnIndexedSetter i s t a b = Indexed i a Identity b -> s -> Identity 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 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.
type ASetter s t a b = a -> Identity b -> s -> Identity t

-- | 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 :: forall (f :: Type -> Type) a b. 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> was not a superclass of <a>Monad</a>
--   until GHC 7.10.
--   
--   <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 :: forall (m :: Type -> Type) a b. 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 . _Unwrapping' Op . contramapped) (*12) [(*2),(+1),(^3)]
--   [24,13,1728]
--   </pre>
contramapped :: forall (f :: Type -> Type) b a. Contravariant f => Setter (f b) (f a) 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

-- | 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) -> Optical p q f 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

-- | 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

-- | 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 qualified 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)
infixr 4 <?~

-- | 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 ()

-- | This is an alias for (<a>%=</a>).
modifying :: MonadState s m => ASetter s s a b -> (a -> b) -> m ()

-- | 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 ()
infixr 2 <~

-- | 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> "foo" <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
infix 4 <?=

-- | 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 allows 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 allows 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 allows 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 allows 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

-- | Modify the value of the <tt>Reader</tt> environment associated with
--   the target of a <a>Setter</a>, <a>Lens</a>, or <a>Traversal</a>.
--   
--   <pre>
--   <a>locally</a> l <a>id</a> a ≡ a
--   <a>locally</a> l f <a>.</a> locally l g ≡ <a>locally</a> l (f <a>.</a> g)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (1,1) &amp; locally _1 (+1) (uncurry (+))
--   3
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "," &amp; locally ($) ("Hello" &lt;&gt;) (&lt;&gt; " world!")
--   "Hello, world!"
--   </pre>
--   
--   <pre>
--   locally :: MonadReader s m =&gt; <a>Iso</a> s s a b       -&gt; (a -&gt; b) -&gt; m r -&gt; m r
--   locally :: MonadReader s m =&gt; <a>Lens</a> s s a b      -&gt; (a -&gt; b) -&gt; m r -&gt; m r
--   locally :: MonadReader s m =&gt; <a>Traversal</a> s s a b -&gt; (a -&gt; b) -&gt; m r -&gt; m r
--   locally :: MonadReader s m =&gt; <a>Setter</a> s s a b    -&gt; (a -&gt; b) -&gt; m r -&gt; m r
--   </pre>
locally :: MonadReader s m => ASetter s s a b -> (a -> b) -> m r -> m r

-- | This is a generalization of <a>locally</a> that allows one to make
--   indexed <a>local</a> changes to a <tt>Reader</tt> environment
--   associated with the target of a <a>Setter</a>, <a>Lens</a>, or
--   <a>Traversal</a>.
--   
--   <pre>
--   <a>locally</a> l f ≡ <a>ilocally</a> l f . const
--   <a>ilocally</a> l f ≡ <a>locally</a> l f . <a>Indexed</a>
--   </pre>
--   
--   <pre>
--   ilocally :: MonadReader s m =&gt; <a>IndexedLens</a> s s a b      -&gt; (i -&gt; a -&gt; b) -&gt; m r -&gt; m r
--   ilocally :: MonadReader s m =&gt; <a>IndexedTraversal</a> s s a b -&gt; (i -&gt; a -&gt; b) -&gt; m r -&gt; m r
--   ilocally :: MonadReader s m =&gt; <a>IndexedSetter</a> s s a b    -&gt; (i -&gt; a -&gt; b) -&gt; m r -&gt; m r
--   </pre>
ilocally :: MonadReader s m => AnIndexedSetter i s s a b -> (i -> a -> b) -> m r -> m r

-- | 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

-- | Set with index. Equivalent to <a>iover</a> with the current value
--   ignored.
--   
--   When you do not need access to the index, then <a>set</a> is more
--   liberal in what it can accept.
--   
--   <pre>
--   <a>set</a> l ≡ <a>iset</a> l <a>.</a> <a>const</a>
--   </pre>
--   
--   <pre>
--   <a>iset</a> :: <a>IndexedSetter</a> i s t a b    -&gt; (i -&gt; b) -&gt; s -&gt; t
--   <a>iset</a> :: <a>IndexedLens</a> i s t a b      -&gt; (i -&gt; b) -&gt; s -&gt; t
--   <a>iset</a> :: <a>IndexedTraversal</a> i s t a b -&gt; (i -&gt; b) -&gt; s -&gt; t
--   </pre>
iset :: AnIndexedSetter i s t a b -> (i -> 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>isets</a> is that it takes a "semantic editor
--   combinator" which has been modified to carry an index and transforms
--   it into a <a>IndexedSetter</a>.
isets :: ((i -> a -> b) -> s -> t) -> IndexedSetter i s t a b

-- | Replace every target of an <a>IndexedSetter</a>, <a>IndexedLens</a> or
--   <a>IndexedTraversal</a> with access to the index.
--   
--   <pre>
--   (<a>.@~</a>) ≡ <a>iset</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> b ≡ l <a>.@~</a> <a>const</a> b
--   </pre>
--   
--   <pre>
--   (<a>.@~</a>) :: <a>IndexedSetter</a> i s t a b    -&gt; (i -&gt; b) -&gt; s -&gt; t
--   (<a>.@~</a>) :: <a>IndexedLens</a> i s t a b      -&gt; (i -&gt; b) -&gt; s -&gt; t
--   (<a>.@~</a>) :: <a>IndexedTraversal</a> i s t a b -&gt; (i -&gt; b) -&gt; s -&gt; t
--   </pre>
(.@~) :: AnIndexedSetter i s t a b -> (i -> b) -> s -> t
infixr 4 .@~

-- | 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 ()
infix 4 %@=

-- | This is an alias for (<a>%@=</a>).
imodifying :: MonadState s m => AnIndexedSetter i s s a b -> (i -> a -> b) -> m ()

-- | Replace 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> b ≡ l <a>.@=</a> <a>const</a> b
--   </pre>
--   
--   <pre>
--   (<a>.@=</a>) :: <a>MonadState</a> s m =&gt; <a>IndexedSetter</a> i s s a b    -&gt; (i -&gt; b) -&gt; m ()
--   (<a>.@=</a>) :: <a>MonadState</a> s m =&gt; <a>IndexedLens</a> i s s a b      -&gt; (i -&gt; b) -&gt; m ()
--   (<a>.@=</a>) :: <a>MonadState</a> s m =&gt; <a>IndexedTraversal</a> i s t a b -&gt; (i -&gt; b) -&gt; m ()
--   </pre>
(.@=) :: MonadState s m => AnIndexedSetter i s s a b -> (i -> b) -> m ()
infix 4 .@=

-- | Run an arrow command and use the output to set all the targets of a
--   <a>Lens</a>, <a>Setter</a> or <a>Traversal</a> to the result.
--   
--   <a>assignA</a> can be used very similarly to (<a>&lt;~</a>), except
--   that the type of the object being modified can change; for example:
--   
--   <pre>
--   runKleisli action ((), (), ()) where
--     action =      assignA _1 (Kleisli (const getVal1))
--              &gt;&gt;&gt; assignA _2 (Kleisli (const getVal2))
--              &gt;&gt;&gt; assignA _3 (Kleisli (const getVal3))
--     getVal1 :: Either String Int
--     getVal1 = ...
--     getVal2 :: Either String Bool
--     getVal2 = ...
--     getVal3 :: Either String Char
--     getVal3 = ...
--   </pre>
--   
--   has the type <tt><a>Either</a> <a>String</a> (<a>Int</a>, <a>Bool</a>,
--   <a>Char</a>)</tt>
--   
--   <pre>
--   <a>assignA</a> :: <a>Arrow</a> p =&gt; <a>Iso</a> s t a b       -&gt; p s b -&gt; p s t
--   <a>assignA</a> :: <a>Arrow</a> p =&gt; <a>Lens</a> s t a b      -&gt; p s b -&gt; p s t
--   <a>assignA</a> :: <a>Arrow</a> p =&gt; <a>Traversal</a> s t a b -&gt; p s b -&gt; p s t
--   <a>assignA</a> :: <a>Arrow</a> p =&gt; <a>Setter</a> s t a b    -&gt; p s b -&gt; p s t
--   </pre>
assignA :: Arrow p => ASetter s t a b -> p s b -> p s t

-- | <a>mapOf</a> is a deprecated alias for <a>over</a>.
mapOf :: ASetter s t a b -> (a -> b) -> s -> t

-- | 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>
imapOf :: AnIndexedSetter i s t a b -> (i -> a -> b) -> s -> t

-- | <pre>
--   type <a>AnIndexedLens'</a> = <a>Simple</a> (<a>AnIndexedLens</a> i)
--   </pre>
type AnIndexedLens' i s a = AnIndexedLens i 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 = Optical Indexed i (->) Pretext Indexed i 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 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

-- | Obtain a getter and a setter from a lens, reversing <a>lens</a>.
withLens :: ALens s t a b -> ((s -> a) -> (s -> b -> t) -> r) -> r

-- | Build an index-preserving <a>Lens</a> from a <a>Getter</a> and a
--   <a>Setter</a>.
iplens :: (s -> a) -> (s -> b -> t) -> IndexPreservingLens 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

-- | This can be used to chain lens operations using <tt>op=</tt> syntax
--   rather than <tt>op~</tt> syntax for simple non-type-changing cases.
--   
--   <pre>
--   &gt;&gt;&gt; (10,20) &amp; _1 .~ 30 &amp; _2 .~ 40
--   (30,40)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (10,20) &amp;~ do _1 .= 30; _2 .= 40
--   (30,40)
--   </pre>
--   
--   This does not support type-changing assignment, <i>e.g.</i>
--   
--   <pre>
--   &gt;&gt;&gt; (10,20) &amp; _1 .~ "hello"
--   ("hello",20)
--   </pre>
(&~) :: s -> State s a -> s
infixl 1 &~

-- | (<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.
--   
--   <pre>
--   &gt;&gt;&gt; [66,97,116,109,97,110] &amp; each %%~ \a -&gt; ("na", chr a)
--   ("nananananana","Batman")
--   </pre>
--   
--   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>
(%%~) :: forall {k} f s (t :: k) a (b :: k). LensLike f s t a b -> (a -> f b) -> s -> f t
infixr 4 %%~

-- | 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>
(%%=) :: forall {k} s m p r (a :: k) b. MonadState s m => Over p ((,) r) s s a b -> p a (r, b) -> m r
infix 4 %%=

-- | This is convenient to <a>flip</a> argument order of composite
--   functions defined as:
--   
--   <pre>
--   fab ?? a = fmap ($ a) fab
--   </pre>
--   
--   For the <a>Functor</a> instance <tt>f = ((-&gt;) r)</tt> you can
--   reason about this function as if the definition was <tt>(<a>??</a>) ≡
--   <a>flip</a></tt>:
--   
--   <pre>
--   &gt;&gt;&gt; (h ?? x) a
--   h a x
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; execState ?? [] $ modify (1:)
--   [1]
--   </pre>
--   
--   <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
infixl 1 ??

-- | 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 :: forall a b p f. (Conjoined p, Functor f) => p a (f b) -> p (Either a a) (f (Either b b))

-- | 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 :: forall (p :: Type -> Type -> Type -> Type) a c s b. IndexedComonadStore p => Lens (p a c s) (p b c s) 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

-- | Modify the target of a <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 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>
(<%~) :: LensLike ((,) b) s t a b -> (a -> b) -> s -> (b, t)
infixr 4 <%~

-- | 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 => LensLike ((,) a) s t a a -> a -> s -> (a, t)
infixr 4 <+~

-- | 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 => LensLike ((,) a) s t a a -> a -> s -> (a, t)
infixr 4 <-~

-- | 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 => LensLike ((,) a) s t a a -> a -> s -> (a, t)
infixr 4 <*~

-- | 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 => LensLike ((,) a) s t a a -> a -> s -> (a, t)
infixr 4 <//~

-- | 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 operation, (<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) => LensLike ((,) a) s t a a -> e -> s -> (a, t)
infixr 4 <^~

-- | 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 operation, (<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) => LensLike ((,) a) s t a a -> e -> s -> (a, t)
infixr 4 <^^~

-- | 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 operation, (<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 => LensLike ((,) a) s t a a -> a -> s -> (a, t)
infixr 4 <**~

-- | 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>
(<||~) :: LensLike ((,) Bool) s t Bool Bool -> Bool -> s -> (Bool, t)
infixr 4 <||~

-- | 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>
(<&&~) :: LensLike ((,) Bool) s t Bool Bool -> Bool -> s -> (Bool, t)
infixr 4 <&&~

-- | 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; (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>
(<<%~) :: LensLike ((,) a) s t a b -> (a -> b) -> s -> (a, t)
infixr 4 <<%~

-- | Replace 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>
(<<.~) :: LensLike ((,) a) s t a b -> b -> s -> (a, t)
infixr 4 <<.~

-- | Replace the target of a <a>Lens</a> with a <a>Just</a> value, but
--   return the old value.
--   
--   If you do not need the old value (<a>?~</a>) is more flexible.
--   
--   <pre>
--   &gt;&gt;&gt; import qualified Data.Map as Map
--   
--   &gt;&gt;&gt; _2.at "hello" &lt;&lt;?~ "world" $ (42,Map.fromList [("goodnight","gracie")])
--   (Nothing,(42,fromList [("goodnight","gracie"),("hello","world")]))
--   </pre>
--   
--   <pre>
--   (<a>&lt;&lt;?~</a>) :: <a>Iso</a> s t a (<a>Maybe</a> b)       -&gt; b -&gt; s -&gt; (a, t)
--   (<a>&lt;&lt;?~</a>) :: <a>Lens</a> s t a (<a>Maybe</a> b)      -&gt; b -&gt; s -&gt; (a, t)
--   (<a>&lt;&lt;?~</a>) :: <a>Traversal</a> s t a (<a>Maybe</a> b) -&gt; b -&gt; s -&gt; (a, t)
--   </pre>
(<<?~) :: LensLike ((,) a) s t a (Maybe b) -> b -> s -> (a, t)
infixr 4 <<?~

-- | Increment the target of a numerically valued <a>Lens</a> and return
--   the old value.
--   
--   When you do not need the old value, (<a>+~</a>) is more flexible.
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; _1 &lt;&lt;+~ c
--   (a,(a + c,b))
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; _2 &lt;&lt;+~ c
--   (b,(a,b + c))
--   </pre>
--   
--   <pre>
--   (<a>&lt;&lt;+~</a>) :: <a>Num</a> a =&gt; <a>Lens'</a> s a -&gt; a -&gt; s -&gt; (a, s)
--   (<a>&lt;&lt;+~</a>) :: <a>Num</a> a =&gt; <a>Iso'</a> s a -&gt; a -&gt; s -&gt; (a, s)
--   </pre>
(<<+~) :: Num a => LensLike' ((,) a) s a -> a -> s -> (a, s)
infixr 4 <<+~

-- | Decrement the target of a numerically valued <a>Lens</a> and return
--   the old value.
--   
--   When you do not need the old value, (<a>-~</a>) is more flexible.
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; _1 &lt;&lt;-~ c
--   (a,(a - c,b))
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; _2 &lt;&lt;-~ c
--   (b,(a,b - c))
--   </pre>
--   
--   <pre>
--   (<a>&lt;&lt;-~</a>) :: <a>Num</a> a =&gt; <a>Lens'</a> s a -&gt; a -&gt; s -&gt; (a, s)
--   (<a>&lt;&lt;-~</a>) :: <a>Num</a> a =&gt; <a>Iso'</a> s a -&gt; a -&gt; s -&gt; (a, s)
--   </pre>
(<<-~) :: Num a => LensLike' ((,) a) s a -> a -> s -> (a, s)
infixr 4 <<-~

-- | Multiply the target of a numerically valued <a>Lens</a> and return the
--   old value.
--   
--   When you do not need the old value, (<a>-~</a>) is more flexible.
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; _1 &lt;&lt;*~ c
--   (a,(a * c,b))
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; _2 &lt;&lt;*~ c
--   (b,(a,b * c))
--   </pre>
--   
--   <pre>
--   (<a>&lt;&lt;*~</a>) :: <a>Num</a> a =&gt; <a>Lens'</a> s a -&gt; a -&gt; s -&gt; (a, s)
--   (<a>&lt;&lt;*~</a>) :: <a>Num</a> a =&gt; <a>Iso'</a> s a -&gt; a -&gt; s -&gt; (a, s)
--   </pre>
(<<*~) :: Num a => LensLike' ((,) a) s a -> a -> s -> (a, s)
infixr 4 <<*~

-- | Divide the target of a numerically valued <a>Lens</a> and return the
--   old value.
--   
--   When you do not need the old value, (<a>//~</a>) is more flexible.
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; _1 &lt;&lt;//~ c
--   (a,(a / c,b))
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ("Hawaii",10) &amp; _2 &lt;&lt;//~ 2
--   (10.0,("Hawaii",5.0))
--   </pre>
--   
--   <pre>
--   (<a>&lt;&lt;//~</a>) :: Fractional a =&gt; <a>Lens'</a> s a -&gt; a -&gt; s -&gt; (a, s)
--   (<a>&lt;&lt;//~</a>) :: Fractional a =&gt; <a>Iso'</a> s a -&gt; a -&gt; s -&gt; (a, s)
--   </pre>
(<<//~) :: Fractional a => LensLike' ((,) a) s a -> a -> s -> (a, s)
infixr 4 <<//~

-- | Raise the target of a numerically valued <a>Lens</a> to a non-negative
--   power and return the old value.
--   
--   When you do not need the old value, (<a>^~</a>) is more flexible.
--   
--   <pre>
--   (<a>&lt;&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;&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) => LensLike' ((,) a) s a -> e -> s -> (a, s)
infixr 4 <<^~

-- | Raise the target of a fractionally valued <a>Lens</a> to an integral
--   power and return the old value.
--   
--   When you do not need the old value, (<a>^^~</a>) is more flexible.
--   
--   <pre>
--   (<a>&lt;&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;&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) => LensLike' ((,) a) s a -> e -> s -> (a, s)
infixr 4 <<^^~

-- | Raise the target of a floating-point valued <a>Lens</a> to an
--   arbitrary power and return the old value.
--   
--   When you do not need the old value, (<a>**~</a>) is more flexible.
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; _1 &lt;&lt;**~ c
--   (a,(a**c,b))
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b) &amp; _2 &lt;&lt;**~ c
--   (b,(a,b**c))
--   </pre>
--   
--   <pre>
--   (<a>&lt;&lt;**~</a>) :: <a>Floating</a> a =&gt; <a>Lens'</a> s a -&gt; a -&gt; s -&gt; (a, s)
--   (<a>&lt;&lt;**~</a>) :: <a>Floating</a> a =&gt; <a>Iso'</a> s a -&gt; a -&gt; s -&gt; (a, s)
--   </pre>
(<<**~) :: Floating a => LensLike' ((,) a) s a -> a -> s -> (a, s)
infixr 4 <<**~

-- | Logically <a>||</a> the target of a <a>Bool</a>-valued <a>Lens</a> and
--   return the old value.
--   
--   When you do not need the old value, (<a>||~</a>) is more flexible.
--   
--   <pre>
--   &gt;&gt;&gt; (False,6) &amp; _1 &lt;&lt;||~ True
--   (False,(True,6))
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ("hello",True) &amp; _2 &lt;&lt;||~ False
--   (True,("hello",True))
--   </pre>
--   
--   <pre>
--   (<a>&lt;&lt;||~</a>) :: <a>Lens'</a> s <a>Bool</a> -&gt; <a>Bool</a> -&gt; s -&gt; (<a>Bool</a>, s)
--   (<a>&lt;&lt;||~</a>) :: <a>Iso'</a> s <a>Bool</a> -&gt; <a>Bool</a> -&gt; s -&gt; (<a>Bool</a>, s)
--   </pre>
(<<||~) :: LensLike' ((,) Bool) s Bool -> Bool -> s -> (Bool, s)
infixr 4 <<||~

-- | Logically <a>&amp;&amp;</a> the target of a <a>Bool</a>-valued
--   <a>Lens</a> and return the old value.
--   
--   When you do not need the old value, (<a>&amp;&amp;~</a>) is more
--   flexible.
--   
--   <pre>
--   &gt;&gt;&gt; (False,6) &amp; _1 &lt;&lt;&amp;&amp;~ True
--   (False,(False,6))
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ("hello",True) &amp; _2 &lt;&lt;&amp;&amp;~ False
--   (True,("hello",False))
--   </pre>
--   
--   <pre>
--   (<a>&lt;&lt;&amp;&amp;~</a>) :: <a>Lens'</a> s Bool -&gt; Bool -&gt; s -&gt; (Bool, s)
--   (<a>&lt;&lt;&amp;&amp;~</a>) :: <a>Iso'</a> s Bool -&gt; Bool -&gt; s -&gt; (Bool, s)
--   </pre>
(<<&&~) :: LensLike' ((,) Bool) s Bool -> Bool -> s -> (Bool, s)
infixr 4 <<&&~

-- | Modify the target of a monoidally valued <a>Lens</a> by using
--   (<a>&lt;&gt;</a>) a new value and return the old value.
--   
--   When you do not need the old value, (<a>&lt;&gt;~</a>) is more
--   flexible.
--   
--   <pre>
--   &gt;&gt;&gt; (Sum a,b) &amp; _1 &lt;&lt;&lt;&gt;~ Sum c
--   (Sum {getSum = a},(Sum {getSum = a + c},b))
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; _2 &lt;&lt;&lt;&gt;~ ", 007" $ ("James", "Bond")
--   ("Bond",("James","Bond, 007"))
--   </pre>
--   
--   <pre>
--   (<a>&lt;&lt;&lt;&gt;~</a>) :: <a>Semigroup</a> r =&gt; <a>Lens'</a> s r -&gt; r -&gt; s -&gt; (r, s)
--   (<a>&lt;&lt;&lt;&gt;~</a>) :: <a>Semigroup</a> r =&gt; <a>Iso'</a> s r -&gt; r -&gt; s -&gt; (r, s)
--   </pre>
(<<<>~) :: Semigroup r => LensLike' ((,) r) s r -> r -> s -> (r, s)
infixr 4 <<<>~

-- | Modify the target of a <a>Lens</a> into your <tt>Monad'</tt>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>
(<%=) :: MonadState s m => LensLike ((,) b) s s a b -> (a -> b) -> m b
infix 4 <%=

-- | Add to the target of a numerically valued <a>Lens</a> into your
--   <tt>Monad'</tt>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
infix 4 <+=

-- | Subtract from the target of a numerically valued <a>Lens</a> into your
--   <tt>Monad'</tt>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
infix 4 <-=

-- | Multiply the target of a numerically valued <a>Lens</a> into your
--   <tt>Monad'</tt>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
infix 4 <*=

-- | Divide the target of a fractionally valued <a>Lens</a> into your
--   <tt>Monad'</tt>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
infix 4 <//=

-- | Raise the target of a numerically valued <a>Lens</a> into your
--   <tt>Monad'</tt>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
infix 4 <^=

-- | Raise the target of a fractionally valued <a>Lens</a> into your
--   <tt>Monad'</tt>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
infix 4 <^^=

-- | Raise the target of a floating-point valued <a>Lens</a> into your
--   <tt>Monad'</tt>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
infix 4 <**=

-- | Logically <a>||</a> a Boolean valued <a>Lens</a> into your
--   <tt>Monad'</tt>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
infix 4 <||=

-- | Logically <a>&amp;&amp;</a> a Boolean valued <a>Lens</a> into your
--   <tt>Monad'</tt>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
infix 4 <&&=

-- | Modify the target of a <a>Lens</a> into your <tt>Monad'</tt>s state by
--   a user supplied function and return the <i>old</i> value that was
--   replaced.
--   
--   When applied to a <a>Traversal</a>, 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> a) =&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) => Over p ((,) a) s s a b -> p a b -> m a
infix 4 <<%=

-- | Replace the target of a <a>Lens</a> into your <tt>Monad'</tt>s state
--   with a user supplied value and return the <i>old</i> value that was
--   replaced.
--   
--   When applied to a <a>Traversal</a>, 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; m a
--   (<a>&lt;&lt;.=</a>) :: <a>MonadState</a> s m             =&gt; <a>Iso'</a> s a       -&gt; a -&gt; m a
--   (<a>&lt;&lt;.=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> a) =&gt; <a>Traversal'</a> s a -&gt; a -&gt; m a
--   </pre>
(<<.=) :: MonadState s m => LensLike ((,) a) s s a b -> b -> m a
infix 4 <<.=

-- | Replace the target of a <a>Lens</a> into your <tt>Monad'</tt>s state
--   with <a>Just</a> a user supplied value and return the <i>old</i> value
--   that was replaced.
--   
--   When applied to a <a>Traversal</a>, 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 t a (Maybe b)      -&gt; b -&gt; m a
--   (<a>&lt;&lt;?=</a>) :: <a>MonadState</a> s m             =&gt; <a>Iso</a> s t a (Maybe b)       -&gt; b -&gt; m a
--   (<a>&lt;&lt;?=</a>) :: (<a>MonadState</a> s m, <a>Monoid</a> a) =&gt; <a>Traversal</a> s t a (Maybe b) -&gt; b -&gt; m a
--   </pre>
(<<?=) :: MonadState s m => LensLike ((,) a) s s a (Maybe b) -> b -> m a
infix 4 <<?=

-- | Modify the target of a <a>Lens</a> into your <tt>Monad'</tt>s state by
--   adding a value and return the <i>old</i> value that was replaced.
--   
--   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, <a>Num</a> a) =&gt; <a>Lens'</a> s a -&gt; a -&gt; m a
--   (<a>&lt;&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
infix 4 <<+=

-- | Modify the target of a <a>Lens</a> into your <tt>Monad'</tt>s state by
--   subtracting a value and return the <i>old</i> value that was replaced.
--   
--   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, <a>Num</a> a) =&gt; <a>Lens'</a> s a -&gt; a -&gt; m a
--   (<a>&lt;&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
infix 4 <<-=

-- | Modify the target of a <a>Lens</a> into your <tt>Monad'</tt>s state by
--   multipling a value and return the <i>old</i> value that was replaced.
--   
--   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, <a>Num</a> a) =&gt; <a>Lens'</a> s a -&gt; a -&gt; m a
--   (<a>&lt;&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
infix 4 <<*=

-- | Modify the target of a <a>Lens</a> into your <a>Monad</a>s state by
--   dividing by a value and return the <i>old</i> value that was replaced.
--   
--   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, <a>Fractional</a> a) =&gt; <a>Lens'</a> s a -&gt; a -&gt; m a
--   (<a>&lt;&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
infix 4 <<//=

-- | Modify the target of a <a>Lens</a> into your <tt>Monad'</tt>s state by
--   raising it by a non-negative power and return the <i>old</i> value
--   that was replaced.
--   
--   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, <a>Num</a> a, <a>Integral</a> e) =&gt; <a>Lens'</a> s a -&gt; e -&gt; m a
--   (<a>&lt;&lt;^=</a>) :: (<a>MonadState</a> s m, <a>Num</a> a, <a>Integral</a> e) =&gt; <a>Iso'</a> s a -&gt; a -&gt; m a
--   </pre>
(<<^=) :: (MonadState s m, Num a, Integral e) => LensLike' ((,) a) s a -> e -> m a
infix 4 <<^=

-- | Modify the target of a <a>Lens</a> into your <tt>Monad'</tt>s state by
--   raising it by an integral power and return the <i>old</i> value that
--   was replaced.
--   
--   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, <a>Fractional</a> a, <a>Integral</a> e) =&gt; <a>Lens'</a> s a -&gt; e -&gt; m a
--   (<a>&lt;&lt;^^=</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
--   </pre>
(<<^^=) :: (MonadState s m, Fractional a, Integral e) => LensLike' ((,) a) s a -> e -> m a
infix 4 <<^^=

-- | Modify the target of a <a>Lens</a> into your <tt>Monad'</tt>s state by
--   raising it by an arbitrary power and return the <i>old</i> value that
--   was replaced.
--   
--   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, <a>Floating</a> a) =&gt; <a>Lens'</a> s a -&gt; a -&gt; m a
--   (<a>&lt;&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
infix 4 <<**=

-- | Modify the target of a <a>Lens</a> into your <tt>Monad'</tt>s state by
--   taking its logical <a>||</a> with a value and return the <i>old</i>
--   value that was replaced.
--   
--   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>Bool</a> -&gt; <a>Bool</a> -&gt; m <a>Bool</a>
--   (<a>&lt;&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
infix 4 <<||=

-- | Modify the target of a <a>Lens</a> into your <tt>Monad'</tt>s state by
--   taking its logical <a>&amp;&amp;</a> with a value and return the
--   <i>old</i> value that was replaced.
--   
--   When you do not need the result of the operation, (<a>&amp;&amp;=</a>)
--   is more flexible.
--   
--   <pre>
--   (<a>&lt;&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;&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
infix 4 <<&&=

-- | Modify the target of a <a>Lens</a> into your <tt>Monad'</tt>s state by
--   using (<a>&lt;&gt;</a>) and return the <i>old</i> value that was
--   replaced.
--   
--   When you do not need the result of the operation, (<a>&lt;&gt;=</a>)
--   is more flexible.
--   
--   <pre>
--   (<a>&lt;&lt;&lt;&gt;=</a>) :: (<a>MonadState</a> s m, <a>Semigroup</a> r) =&gt; <a>Lens'</a> s r -&gt; r -&gt; m r
--   (<a>&lt;&lt;&lt;&gt;=</a>) :: (<a>MonadState</a> s m, <a>Semigroup</a> r) =&gt; <a>Iso'</a> s r -&gt; r -&gt; m r
--   </pre>
(<<<>=) :: (MonadState s m, Semigroup r) => LensLike' ((,) r) s r -> r -> m r
infix 4 <<<>=

-- | 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
infixr 2 <<~

-- | (<a>&lt;&gt;</a>) a <a>Semigroup</a> 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.
(<<>~) :: Semigroup m => LensLike ((,) m) s t m m -> m -> s -> (m, t)
infixr 4 <<>~

-- | (<a>&lt;&gt;</a>) a <a>Semigroup</a> value onto the end of the target
--   of a <a>Lens</a> into your <tt>Monad'</tt>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, Semigroup r) => LensLike' ((,) r) s r -> r -> m r
infix 4 <<>=

-- | (<a>&lt;&gt;</a>) a <a>Semigroup</a> value onto the front of the
--   target of a <a>Lens</a> and return the result. However, unlike
--   (<a>&lt;&lt;&gt;~</a>), it is prepended to the head side.
--   
--   When you do not need the result of the operation, (<a>&lt;&gt;:~</a>)
--   is more flexible.
(<<>:~) :: Semigroup m => LensLike ((,) m) s t m m -> m -> s -> (m, t)
infixr 4 <<>:~

-- | (<a>&lt;&gt;</a>) a <a>Semigroup</a> value onto the front of the
--   target of a <a>Lens</a> and return the <i>old</i> result. However,
--   unlike (<a>&lt;&lt;&gt;~</a>), it is prepended to the head side.
--   
--   When you do not need the result of the operation, (<a>&lt;&gt;:~</a>)
--   is more flexible.
(<<<>:~) :: Semigroup m => LensLike' ((,) m) s m -> m -> s -> (m, s)
infixr 4 <<<>:~

-- | (<a>&lt;&gt;</a>) a <a>Semigroup</a> value onto the front of the
--   target of a <a>Lens</a> into your <tt>Monad'</tt>s state and return
--   the result. However, unlike (<a>&lt;&lt;&gt;=</a>), it is prepended to
--   the head side.
--   
--   When you do not need the result of the operation, (<a>&lt;&gt;:=</a>)
--   is more flexible.
(<<>:=) :: (MonadState s m, Semigroup r) => LensLike' ((,) r) s r -> r -> m r
infix 4 <<>:=

-- | (<a>&lt;&gt;</a>) a <a>Semigroup</a> value onto the front of the
--   target of a <a>Lens</a> into your <tt>Monad'</tt>s state and return
--   the <i>old</i> result. However, unlike (<a>&lt;&lt;&lt;&gt;=</a>), it
--   is prepended to the head side.
--   
--   When you do not need the result of the operation, (<a>&lt;&gt;:=</a>)
--   is more flexible.
(<<<>:=) :: (MonadState s m, Semigroup r) => LensLike' ((,) r) s r -> r -> m r
infix 4 <<<>:=

-- | <a>over</a> for Arrows.
--   
--   Unlike <a>over</a>, <a>overA</a> can't accept a simple <a>Setter</a>,
--   but requires a full lens, or close enough.
--   
--   <pre>
--   &gt;&gt;&gt; overA _1 ((+1) *** (+2)) ((1,2),6)
--   ((2,4),6)
--   </pre>
--   
--   <pre>
--   overA :: Arrow ar =&gt; Lens s t a b -&gt; ar a b -&gt; ar s t
--   </pre>
overA :: Arrow ar => LensLike (Context a b) s t a b -> ar a b -> ar s t

-- | 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>
(<%@~) :: Over (Indexed i) ((,) b) s t a b -> (i -> a -> b) -> s -> (b, t)
infixr 4 <%@~

-- | 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>
(<<%@~) :: Over (Indexed i) ((,) a) s t a b -> (i -> a -> b) -> s -> (a, t)
infixr 4 <<%@~

-- | 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>
(%%@~) :: forall {k1} i f s (t :: k1) a (b :: k1). Over (Indexed i) f s t a b -> (i -> a -> f b) -> s -> f t
infixr 4 %%@~

-- | 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 => Over (Indexed i) ((,) r) s s a b -> (i -> a -> (r, b)) -> m r
infix 4 %%@=

-- | 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 => Over (Indexed i) ((,) b) s s a b -> (i -> a -> b) -> m b
infix 4 <%@=

-- | 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 => Over (Indexed i) ((,) a) s s a b -> (i -> a -> b) -> m a
infix 4 <<%@=

-- | 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
infixl 8 ^#

-- | 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","there") &amp; _2 #~ "world"
--   ("hello","world")
--   </pre>
(#~) :: ALens s t a b -> b -> s -> t
infixr 4 #~

-- | 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
infixr 4 #%~

-- | 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
infixr 4 #%%~

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

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

-- | 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)
infixr 4 <#%~

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

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

-- | 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)
infixr 4 <#~

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

-- | 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 :: forall {k} p f (a :: k) b. 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 :: forall a f. Functor f => (() -> f ()) -> a -> f a

-- | A <a>Lens</a> focusing on the first element of a <a>Traversable1</a>
--   container.
--   
--   <pre>
--   &gt;&gt;&gt; 2 :| [3, 4] &amp; head1 +~ 10
--   12 :| [3,4]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Identity True ^. head1
--   True
--   </pre>
head1 :: forall (t :: Type -> Type) a. Traversable1 t => Lens' (t a) a

-- | A <a>Lens</a> focusing on the last element of a <a>Traversable1</a>
--   container.
--   
--   <pre>
--   &gt;&gt;&gt; 2 :| [3, 4] &amp; last1 +~ 10
--   2 :| [3,14]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Node 'a' [Node 'b' [], Node 'c' []] ^. last1
--   'c'
--   </pre>
last1 :: forall (t :: Type -> Type) a. Traversable1 t => Lens' (t a) a

-- | Provides access to the 19th field of a tuple.
class Field19 s t a b | s -> a, t -> b, s b -> t, t a -> s

-- | Access the 19th field of a tuple.
_19 :: Field19 s t a b => Lens s t a b
($dm_19) :: (Field19 s t a b, Generic s, Generic t, GIxed N18 (Rep s) (Rep t) a b) => Lens s t a b

-- | Provides access to the 18th field of a tuple.
class Field18 s t a b | s -> a, t -> b, s b -> t, t a -> s

-- | Access the 18th field of a tuple.
_18 :: Field18 s t a b => Lens s t a b
($dm_18) :: (Field18 s t a b, Generic s, Generic t, GIxed N17 (Rep s) (Rep t) a b) => Lens s t a b

-- | Provides access to the 17th field of a tuple.
class Field17 s t a b | s -> a, t -> b, s b -> t, t a -> s

-- | Access the 17th field of a tuple.
_17 :: Field17 s t a b => Lens s t a b
($dm_17) :: (Field17 s t a b, Generic s, Generic t, GIxed N16 (Rep s) (Rep t) a b) => Lens s t a b

-- | Provides access to the 16th field of a tuple.
class Field16 s t a b | s -> a, t -> b, s b -> t, t a -> s

-- | Access the 16th field of a tuple.
_16 :: Field16 s t a b => Lens s t a b
($dm_16) :: (Field16 s t a b, Generic s, Generic t, GIxed N15 (Rep s) (Rep t) a b) => Lens s t a b

-- | Provides access to the 15th field of a tuple.
class Field15 s t a b | s -> a, t -> b, s b -> t, t a -> s

-- | Access the 15th field of a tuple.
_15 :: Field15 s t a b => Lens s t a b
($dm_15) :: (Field15 s t a b, Generic s, Generic t, GIxed N14 (Rep s) (Rep t) a b) => Lens s t a b

-- | Provides access to the 14th field of a tuple.
class Field14 s t a b | s -> a, t -> b, s b -> t, t a -> s

-- | Access the 14th field of a tuple.
_14 :: Field14 s t a b => Lens s t a b
($dm_14) :: (Field14 s t a b, Generic s, Generic t, GIxed N13 (Rep s) (Rep t) a b) => Lens s t a b

-- | Provides access to the 13th field of a tuple.
class Field13 s t a b | s -> a, t -> b, s b -> t, t a -> s

-- | Access the 13th field of a tuple.
_13 :: Field13 s t a b => Lens s t a b
($dm_13) :: (Field13 s t a b, Generic s, Generic t, GIxed N12 (Rep s) (Rep t) a b) => Lens s t a b

-- | Provides access to the 12th field of a tuple.
class Field12 s t a b | s -> a, t -> b, s b -> t, t a -> s

-- | Access the 12th field of a tuple.
_12 :: Field12 s t a b => Lens s t a b
($dm_12) :: (Field12 s t a b, Generic s, Generic t, GIxed N11 (Rep s) (Rep t) a b) => Lens s t a b

-- | Provides access to the 11th field of a tuple.
class Field11 s t a b | s -> a, t -> b, s b -> t, t a -> s

-- | Access the 11th field of a tuple.
_11 :: Field11 s t a b => Lens s t a b
($dm_11) :: (Field11 s t a b, Generic s, Generic t, GIxed N10 (Rep s) (Rep t) a b) => Lens s t a b

-- | Provides access to the 10th field of a tuple.
class Field10 s t a b | s -> a, t -> b, s b -> t, t a -> s

-- | Access the 10th field of a tuple.
_10 :: Field10 s t a b => Lens s t a b
($dm_10) :: (Field10 s t a b, Generic s, Generic t, GIxed N9 (Rep s) (Rep t) a b) => Lens 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

-- | Access the 9th field of a tuple.
_9 :: Field9 s t a b => Lens s t a b
($dm_9) :: (Field9 s t a b, Generic s, Generic t, GIxed N8 (Rep s) (Rep t) a b) => Lens 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

-- | Access the 8th field of a tuple.
_8 :: Field8 s t a b => Lens s t a b
($dm_8) :: (Field8 s t a b, Generic s, Generic t, GIxed N7 (Rep s) (Rep t) a b) => Lens 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

-- | Access the 7th field of a tuple.
_7 :: Field7 s t a b => Lens s t a b
($dm_7) :: (Field7 s t a b, Generic s, Generic t, GIxed N6 (Rep s) (Rep t) a b) => Lens 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

-- | Access the 6th field of a tuple.
_6 :: Field6 s t a b => Lens s t a b
($dm_6) :: (Field6 s t a b, Generic s, Generic t, GIxed N5 (Rep s) (Rep t) a b) => Lens 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

-- | Access the 5th field of a tuple.
_5 :: Field5 s t a b => Lens s t a b
($dm_5) :: (Field5 s t a b, Generic s, Generic t, GIxed N4 (Rep s) (Rep t) a b) => Lens 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

-- | Access the 4th field of a tuple.
_4 :: Field4 s t a b => Lens s t a b
($dm_4) :: (Field4 s t a b, Generic s, Generic t, GIxed N3 (Rep s) (Rep t) a b) => Lens 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

-- | Access the 3rd field of a tuple.
_3 :: Field3 s t a b => Lens s t a b
($dm_3) :: (Field3 s t a b, Generic s, Generic t, GIxed N2 (Rep s) (Rep t) a b) => Lens s t a b

-- | Strict version of <a>_1</a>
_1' :: Field1 s t a b => Lens s t a b

-- | Strict version of <a>_2</a>
_2' :: Field2 s t a b => Lens s t a b

-- | Strict version of <a>_3</a>
_3' :: Field3 s t a b => Lens s t a b

-- | Strict version of <a>_4</a>
_4' :: Field4 s t a b => Lens s t a b

-- | Strict version of <a>_5</a>
_5' :: Field5 s t a b => Lens s t a b

-- | Strict version of <a>_6</a>
_6' :: Field6 s t a b => Lens s t a b

-- | Strict version of <a>_7</a>
_7' :: Field7 s t a b => Lens s t a b

-- | Strict version of <a>_8</a>
_8' :: Field8 s t a b => Lens s t a b

-- | Strict version of <a>_9</a>
_9' :: Field9 s t a b => Lens s t a b

-- | Strict version of <a>_10</a>
_10' :: Field10 s t a b => Lens s t a b

-- | Strict version of <a>_11</a>
_11' :: Field11 s t a b => Lens s t a b

-- | Strict version of <a>_12</a>
_12' :: Field12 s t a b => Lens s t a b

-- | Strict version of <a>_13</a>
_13' :: Field13 s t a b => Lens s t a b

-- | Strict version of <a>_14</a>
_14' :: Field14 s t a b => Lens s t a b

-- | Strict version of <a>_15</a>
_15' :: Field15 s t a b => Lens s t a b

-- | Strict version of <a>_16</a>
_16' :: Field16 s t a b => Lens s t a b

-- | Strict version of <a>_17</a>
_17' :: Field17 s t a b => Lens s t a b

-- | Strict version of <a>_18</a>
_18' :: Field18 s t a b => Lens s t a b

-- | Strict version of <a>_19</a>
_19' :: Field19 s t a b => Lens s t a b

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

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

-- | <pre>
--   <a>ito</a> :: (s -&gt; (i, a)) -&gt; <a>IndexedGetter</a> i s a
--   </pre>
ito :: (Indexable i p, Contravariant f) => (s -> (i, a)) -> Over' p f s a

-- | Build an constant-valued (index-preserving) <a>Getter</a> from an
--   arbitrary Haskell value.
--   
--   <pre>
--   <a>like</a> a <a>.</a> <a>like</a> b ≡ <a>like</a> b
--   a <a>^.</a> <a>like</a> b ≡ b
--   a <a>^.</a> <a>like</a> b ≡ a <a>^.</a> <a>to</a> (<a>const</a> b)
--   </pre>
--   
--   This can be useful as a second case <tt>failing</tt> a <a>Fold</a>
--   e.g. <tt>foo <tt>failing</tt> <a>like</a> 0</tt>
--   
--   <pre>
--   <a>like</a> :: a -&gt; <a>IndexPreservingGetter</a> s a
--   </pre>
like :: (Profunctor p, Contravariant f, Functor f) => a -> Optic' p f s a

-- | <pre>
--   <a>ilike</a> :: i -&gt; a -&gt; <a>IndexedGetter</a> i s a
--   </pre>
ilike :: (Indexable i p, Contravariant f, Functor f) => i -> a -> Over' p f s 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>views</a> :: <a>MonadReader</a> s m             =&gt; <a>Getter</a> s a     -&gt; (a -&gt; r) -&gt; m r
--   <a>views</a> :: (<a>MonadReader</a> s m, <a>Monoid</a> r) =&gt; <a>Fold</a> s a       -&gt; (a -&gt; r) -&gt; m r
--   <a>views</a> :: <a>MonadReader</a> s m             =&gt; <a>Iso'</a> s a       -&gt; (a -&gt; r) -&gt; m r
--   <a>views</a> :: <a>MonadReader</a> s m             =&gt; <a>Lens'</a> s a      -&gt; (a -&gt; r) -&gt; m r
--   <a>views</a> :: (<a>MonadReader</a> s m, <a>Monoid</a> r) =&gt; <a>Traversal'</a> s a -&gt; (a -&gt; r) -&gt; m r
--   </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 :: MonadReader s m => LensLike' (Const r :: Type -> Type) s a -> (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 (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 :: MonadState s m => LensLike' (Const r :: Type -> Type) s a -> (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>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>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)

-- | 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)

-- | 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

-- | View the index and value of an <a>IndexedGetter</a> or
--   <a>IndexedLens</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>
--   (<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)
infixl 8 ^@.

-- | Coerce a <a>Getter</a>-compatible <a>Optical</a> to an
--   <a>Optical'</a>. This is useful when using a <a>Traversal</a> that is
--   not simple as a <a>Getter</a> or a <a>Fold</a>.
--   
--   <pre>
--   <a>getting</a> :: <a>Traversal</a> s t a b          -&gt; <a>Fold</a> s a
--   <a>getting</a> :: <a>Lens</a> s t a b               -&gt; <a>Getter</a> s a
--   <a>getting</a> :: <a>IndexedTraversal</a> i s t a b -&gt; <a>IndexedFold</a> i s a
--   <a>getting</a> :: <a>IndexedLens</a> i s t a b      -&gt; <a>IndexedGetter</a> i s a
--   </pre>
getting :: (Profunctor p, Profunctor q, Functor f, Contravariant f) => Optical p q f s t a b -> Optical' p q f s a

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

-- | Turn a <a>Getter</a> around to get a <a>Review</a>
--   
--   <pre>
--   <a>un</a> = <a>unto</a> . <a>view</a>
--   <a>unto</a> = <a>un</a> . <a>to</a>
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; un (to length) # [1,2,3]
--   3
--   </pre>
un :: (Profunctor p, Bifunctor p, Functor f) => Getting a s a -> Optic' p f a s

-- | 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 it may be beneficial to think of it as having one of
--   these slightly more liberal type signatures:
--   
--   <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 t 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 t 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 t b -> (t -> r) -> m r

-- | Coerce a polymorphic <a>Prism</a> to a <a>Review</a>.
--   
--   <pre>
--   <a>reviewing</a> :: <a>Iso</a> s t a b -&gt; <a>Review</a> t b
--   <a>reviewing</a> :: <a>Prism</a> s t a b -&gt; <a>Review</a> t b
--   </pre>
reviewing :: (Bifunctor p, Functor f) => Optic (Tagged :: Type -> Type -> Type) Identity s t a b -> Optic' p f t b
class Suffixed t

-- | A <a>Prism</a> stripping a suffix from a sequence when used as a
--   <a>Traversal</a>, or appending that suffix 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 :: Suffixed t => t -> Prism' t t
class Prefixed t

-- | A <a>Prism</a> stripping a prefix from a sequence 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 :: Prefixed t => t -> Prism' t t

-- | <pre>
--   type APrism' = <a>Simple</a> <a>APrism</a>
--   </pre>
type APrism' s a = APrism 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 Identity b -> Market a b s Identity t

-- | Convert <a>APrism</a> to the pair of functions that characterize it.
withPrism :: APrism s t a b -> ((b -> t) -> (s -> Either t a) -> r) -> r

-- | 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

-- | 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

-- | 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)

-- | <tt>lift</tt> a <a>Prism</a> through a <a>Traversable</a> functor,
--   giving a Prism that matches only if all the elements of the container
--   match the <a>Prism</a>.
--   
--   <pre>
--   &gt;&gt;&gt; [Left 1, Right "foo", Left 4, Right "woot"]^..below _Right
--   []
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [Right "hail hydra!", Right "foo", Right "blah", Right "woot"]^..below _Right
--   [["hail hydra!","foo","blah","woot"]]
--   </pre>
below :: forall (f :: Type -> Type) s a. Traversable f => APrism' s a -> Prism' (f s) (f a)

-- | 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>
--   
--   <pre>
--   &gt;&gt;&gt; isn't _Empty []
--   False
--   </pre>
--   
--   <pre>
--   <a>isn't</a> = <a>not</a> . <a>is</a>
--   <a>isn't</a> = <tt>hasn't</tt>
--   </pre>
isn't :: APrism s t a b -> s -> Bool

-- | Like <a>matching</a>, but also works for combinations of <a>Lens</a>
--   and <a>Prism</a>s, and also <a>Traversal</a>s.
--   
--   <pre>
--   &gt;&gt;&gt; matching' (_2 . _Just) ('x', Just True)
--   Right True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; matching' (_2 . _Just) ('x', Nothing :: Maybe Int) :: Either (Char, Maybe Bool) Int
--   Left ('x',Nothing)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; matching' traverse "" :: Either [Int] Char
--   Left []
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; matching' traverse "xyz" :: Either [Int] Char
--   Right 'x'
--   </pre>
matching' :: LensLike (Either a) s t a b -> s -> Either t a

-- | 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 :: forall c a b p f. (Choice p, Applicative f) => p a (f b) -> p (Either c a) (f (Either c 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 :: forall a b p f. (Choice p, Applicative f) => p a (f b) -> p (Maybe a) (f (Maybe 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 :: forall a p f. (Choice p, Applicative f) => p () (f ()) -> p (Maybe a) (f (Maybe a))

-- | <a>Void</a> is a logically uninhabited data type.
--   
--   This is a <a>Prism</a> that will always fail to match.
_Void :: forall s a p f. (Choice p, Applicative f) => p a (f Void) -> p s (f s)

-- | 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 ()

-- | This <a>Prism</a> compares for approximate equality with a given value
--   and a predicate for testing, an example where the value is the empty
--   list and the predicate checks that a list is empty (same as
--   <a>_Empty</a> with the <a>AsEmpty</a> list instance):
--   
--   <pre>
--   &gt;&gt;&gt; nearly [] null # ()
--   []
--   
--   &gt;&gt;&gt; [1,2,3,4] ^? nearly [] null
--   Nothing
--   </pre>
--   
--   <pre>
--   <a>nearly</a> [] <a>null</a> :: <a>Prism'</a> [a] ()
--   </pre>
--   
--   To comply with the <a>Prism</a> laws the arguments you supply to
--   <tt>nearly a p</tt> are somewhat constrained.
--   
--   We assume <tt>p x</tt> holds iff <tt>x ≡ a</tt>. Under that assumption
--   then this is a valid <a>Prism</a>.
--   
--   This is useful when working with a type where you can test equality
--   for only a subset of its values, and the prism selects such a value.
nearly :: a -> (a -> Bool) -> Prism' a ()

-- | This is an improper prism for text formatting based on <a>Read</a> and
--   <a>Show</a>.
--   
--   This <a>Prism</a> is "improper" in the sense that it normalizes the
--   text formatting, but round tripping is idempotent given sane
--   <a>Read</a>/<a>Show</a> instances.
--   
--   <pre>
--   &gt;&gt;&gt; _Show # 2
--   "2"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "EQ" ^? _Show :: Maybe Ordering
--   Just EQ
--   </pre>
--   
--   <pre>
--   <a>_Show</a> ≡ <a>prism'</a> <a>show</a> <tt>readMaybe</tt>
--   </pre>
_Show :: (Read a, Show a) => Prism' String a

-- | 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 reverse
--   [4,3,2,1]
--   </pre>
folding :: Foldable f => (s -> f a) -> Fold s a
ifolding :: (Foldable f, Indexable i p, Contravariant g, Applicative g) => (s -> f (i, a)) -> Over p g s t a b

-- | Obtain a <a>Fold</a> by lifting <a>foldr</a> like function.
--   
--   <pre>
--   &gt;&gt;&gt; [1,2,3,4]^..foldring foldr
--   [1,2,3,4]
--   </pre>
foldring :: (Contravariant f, Applicative f) => ((a -> f a -> f a) -> f a -> s -> f a) -> LensLike f s t a b

-- | Obtain <tt>FoldWithIndex</tt> by lifting <a>ifoldr</a> like function.
ifoldring :: (Indexable i p, Contravariant f, Applicative f) => ((i -> a -> f a -> f a) -> f a -> s -> f a) -> Over p f s t a b

-- | Obtain a <a>Fold</a> from any <a>Foldable</a> indexed by ordinal
--   position.
folded64 :: forall (f :: Type -> Type) a. Foldable f => IndexedFold Int64 (f a) a

-- | Form a <a>Fold1</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>
--   
--   <pre>
--   <a>repeated</a> :: <a>Fold1</a> a a
--   </pre>
repeated :: Apply f => LensLike' f 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 non-empty <a>Fold</a> into a <a>Fold1</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>
--   
--   <pre>
--   <a>cycled</a> :: <a>Fold1</a> s a -&gt; <a>Fold1</a> s a
--   </pre>
cycled :: Apply f => LensLike f s t a b -> LensLike f s t a b

-- | 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>Fold1</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>
--   
--   <pre>
--   <a>iterated</a> :: (a -&gt; a) -&gt; <a>Fold1</a> a a
--   </pre>
iterated :: Apply f => (a -> a) -> LensLike' f 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 fails 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) -> Optic' p f a a

-- | Obtain a potentially empty <a>IndexedTraversal</a> by taking the first
--   element from another, potentially empty <a>Fold</a> and using it as an
--   index.
--   
--   The resulting optic can be composed with to filter another
--   <a>Lens</a>, <a>Iso</a>, <a>Getter</a>, <a>Fold</a> (or
--   <a>Traversal</a>).
--   
--   <pre>
--   &gt;&gt;&gt; [(Just 2, 3), (Nothing, 4)] &amp; mapped . filteredBy (_1 . _Just) &lt;. _2 %@~ (*) :: [(Maybe Int, Int)]
--   [(Just 2,6),(Nothing,4)]
--   </pre>
--   
--   <pre>
--   <a>filteredBy</a> :: <a>Fold</a> a i -&gt; <a>IndexedTraversal'</a> i a a
--   </pre>
--   
--   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!
filteredBy :: (Indexable i p, Applicative f) => Getting (First i) a i -> p a (f a) -> a -> f a

-- | 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>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
--   </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
--   </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
--   </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 to the first target also does not pass the predicate! Otherwise
--   subsequent traversals will visit fewer elements and <a>Traversal</a>
--   fusion is not sound.
--   
--   So for any traversal <tt>t</tt> and predicate <tt>p</tt>,
--   <tt><a>droppingWhile</a> p t</tt> may not be lawful, but
--   <tt>(<a>dropping</a> 1 . <a>droppingWhile</a> p) t</tt> is. For
--   example:
--   
--   <pre>
--   &gt;&gt;&gt; let l  :: Traversal' [Int] Int; l  = droppingWhile (&lt;= 1) traverse
--   
--   &gt;&gt;&gt; let l' :: Traversal' [Int] Int; l' = dropping 1 l
--   </pre>
--   
--   <tt>l</tt> is not a lawful setter because <tt><a>over</a> l f .
--   <a>over</a> l g ≢ <a>over</a> l (f . g)</tt>:
--   
--   <pre>
--   &gt;&gt;&gt; [1,2,3] &amp; l .~ 0 &amp; l .~ 4
--   [1,0,0]
--   
--   &gt;&gt;&gt; [1,2,3] &amp; l .~ 4
--   [1,4,4]
--   </pre>
--   
--   <tt>l'</tt> on the other hand behaves lawfully:
--   
--   <pre>
--   &gt;&gt;&gt; [1,2,3] &amp; l' .~ 0 &amp; l' .~ 4
--   [1,2,4]
--   
--   &gt;&gt;&gt; [1,2,3] &amp; l' .~ 4
--   [1,2,4]
--   </pre>
droppingWhile :: (Conjoined p, Profunctor q, Applicative f) => (a -> Bool) -> Optical p q (Compose (State Bool) f) s t a a -> Optical p q f s t a a

-- | A <a>Fold</a> over the individual <a>words</a> of a <a>String</a>.
--   
--   <pre>
--   <a>worded</a> :: <a>Fold</a> <a>String</a> <a>String</a>
--   <a>worded</a> :: <a>Traversal'</a> <a>String</a> <a>String</a>
--   </pre>
--   
--   <pre>
--   <a>worded</a> :: <a>IndexedFold</a> <a>Int</a> <a>String</a> <a>String</a>
--   <a>worded</a> :: <a>IndexedTraversal'</a> <a>Int</a> <a>String</a> <a>String</a>
--   </pre>
--   
--   Note: This function type-checks as a <a>Traversal</a> but it doesn't
--   satisfy the laws. It's only valid to use it when you don't insert any
--   whitespace characters while traversing, and if your original
--   <a>String</a> contains only isolated space characters (and no other
--   characters that count as space, such as non-breaking spaces).
worded :: forall (f :: Type -> Type). Applicative f => IndexedLensLike' Int f String String

-- | A <a>Fold</a> over the individual <a>lines</a> of a <a>String</a>.
--   
--   <pre>
--   <a>lined</a> :: <a>Fold</a> <a>String</a> <a>String</a>
--   <a>lined</a> :: <a>Traversal'</a> <a>String</a> <a>String</a>
--   </pre>
--   
--   <pre>
--   <a>lined</a> :: <a>IndexedFold</a> <a>Int</a> <a>String</a> <a>String</a>
--   <a>lined</a> :: <a>IndexedTraversal'</a> <a>Int</a> <a>String</a> <a>String</a>
--   </pre>
--   
--   Note: This function type-checks as a <a>Traversal</a> but it doesn't
--   satisfy the laws. It's only valid to use it when you don't insert any
--   newline characters while traversing, and if your original
--   <a>String</a> contains only isolated newline characters.
lined :: forall (f :: Type -> Type). Applicative f => IndexedLensLike' Int f String String

-- | Combine the elements of a structure viewed through a <a>Lens</a>,
--   <a>Getter</a>, <a>Fold</a> or <a>Traversal</a> using a monoid.
--   
--   <pre>
--   &gt;&gt;&gt; foldOf (folded.folded) [[Sum 1,Sum 4],[Sum 8, Sum 8],[Sum 21]]
--   Sum {getSum = 42}
--   </pre>
--   
--   <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 :: Getting (Endo r) s a -> (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]

-- | Extract a <a>NonEmpty</a> of the targets of <a>Fold1</a>.
--   
--   <pre>
--   &gt;&gt;&gt; toNonEmptyOf both1 ("hello", "world")
--   "hello" :| ["world"]
--   </pre>
--   
--   <pre>
--   <a>toNonEmptyOf</a> :: <a>Getter</a> s a      -&gt; s -&gt; NonEmpty a
--   <a>toNonEmptyOf</a> :: <a>Fold1</a> s a       -&gt; s -&gt; NonEmpty a
--   <a>toNonEmptyOf</a> :: <a>Lens'</a> s a       -&gt; s -&gt; NonEmpty a
--   <a>toNonEmptyOf</a> :: <a>Iso'</a> s a        -&gt; s -&gt; NonEmpty a
--   <a>toNonEmptyOf</a> :: <a>Traversal1'</a> s a -&gt; s -&gt; NonEmpty a
--   </pre>
toNonEmptyOf :: Getting (NonEmptyDList a) s a -> s -> NonEmpty a

-- | Calls <a>pure</a> on the target of a <a>Lens</a>, <a>Getter</a>, or
--   <a>Iso</a>.
--   
--   Calls <a>pure</a> on the targets of a <a>Traversal</a>, <a>Fold</a>,
--   or <a>Prism</a>, and combines them with <a>&lt;|&gt;</a> (or
--   <a>empty</a> if none). Intuitively, it collects targets into an
--   <a>Alternative</a> until the container fills up or it runs out of
--   targets, whichever comes first.
--   
--   Generalizes <a>toListOf</a> and <a>(^?)</a>.
--   
--   <pre>
--   &gt;&gt;&gt; altOf both ("hello", "world") :: [String]
--   ["hello","world"]
--   
--   &gt;&gt;&gt; altOf both ("hello", "world") :: Maybe String
--   Just "hello"
--   </pre>
--   
--   <pre>
--   <a>altOf</a> :: Applicative f =&gt; <a>Lens'</a> s a      -&gt; s -&gt; f a
--   <a>altOf</a> :: Applicative f =&gt; <a>Getter</a> s a     -&gt; s -&gt; f a
--   <a>altOf</a> :: Applicative f =&gt; <a>Iso'</a> s a       -&gt; s -&gt; f a
--   
--   <a>altOf</a> :: Alternative f =&gt; <a>Traversal'</a> s a -&gt; s -&gt; f a
--   <a>altOf</a> :: Alternative f =&gt; <a>Fold</a> s a       -&gt; s -&gt; f a
--   <a>altOf</a> :: Alternative f =&gt; <a>Prism'</a> s a     -&gt; s -&gt; f a
--   </pre>
altOf :: Applicative f => Getting (Alt f a) s a -> s -> f a

-- | A convenient infix (flipped) version of <a>toListOf</a>.
--   
--   <pre>
--   &gt;&gt;&gt; [[1,2],[3]]^..id
--   [[[1,2],[3]]]
--   
--   &gt;&gt;&gt; [[1,2],[3]]^..traverse
--   [[1,2],[3]]
--   
--   &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]
infixl 8 ^..

-- | 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

-- | 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 :: Getting All s a -> (a -> Bool) -> s -> Bool

-- | Returns <a>True</a> only if no targets of a <a>Fold</a> satisfy a
--   predicate.
--   
--   <pre>
--   &gt;&gt;&gt; noneOf each (is _Nothing) (Just 3, Just 4, Just 5)
--   True
--   
--   &gt;&gt;&gt; noneOf (folded.folded) (&lt;10) [[13,99,20],[3,71,42]]
--   False
--   </pre>
--   
--   <pre>
--   <a>inoneOf</a> l = <a>noneOf</a> l <a>.</a> <a>Indexed</a>
--   </pre>
--   
--   <pre>
--   <a>noneOf</a> :: <a>Getter</a> s a     -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>noneOf</a> :: <a>Fold</a> s a       -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>noneOf</a> :: <a>Lens'</a> s a      -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>noneOf</a> :: <a>Iso'</a> s a       -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>noneOf</a> :: <a>Traversal'</a> s a -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>noneOf</a> :: <a>Prism'</a> s a     -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   </pre>
noneOf :: Getting Any s a -> (a -> Bool) -> s -> Bool

-- | Calculate the <tt>Product</tt> 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>
--   
--   This operation may be more strict than you would expect. If you want a
--   lazier version use <tt><tt>ala</tt> <tt>Product</tt> <a>.</a>
--   <a>foldMapOf</a></tt>
--   
--   <pre>
--   <a>productOf</a> :: <a>Num</a> a =&gt; <a>Getter</a> s a     -&gt; s -&gt; a
--   <a>productOf</a> :: <a>Num</a> a =&gt; <a>Fold</a> s a       -&gt; s -&gt; a
--   <a>productOf</a> :: <a>Num</a> a =&gt; <a>Lens'</a> s a      -&gt; s -&gt; a
--   <a>productOf</a> :: <a>Num</a> a =&gt; <a>Iso'</a> s a       -&gt; s -&gt; a
--   <a>productOf</a> :: <a>Num</a> a =&gt; <a>Traversal'</a> s a -&gt; s -&gt; a
--   <a>productOf</a> :: <a>Num</a> a =&gt; <a>Prism'</a> s a     -&gt; s -&gt; a
--   </pre>
productOf :: Num a => Getting (Endo (Endo a)) s a -> s -> a

-- | Calculate the <tt>Sum</tt> 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> <tt>Sum</tt> <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>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>
--   <tt>for_</tt> ≡ <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_ :: Functor f => Getting (Traversed r f) s a -> s -> (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>
--   <tt>sequenceA_</tt> ≡ <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 ()

-- | See <a>forOf_</a> and <a>traverse1Of_</a>.
--   
--   <pre>
--   &gt;&gt;&gt; for1Of_ both1 ("abc", "bcd") (\ks -&gt; Map.fromList [ (k, ()) | k &lt;- ks ])
--   fromList [('b',()),('c',())]
--   </pre>
--   
--   <pre>
--   <a>for1Of_</a> :: <a>Apply</a> f =&gt; <a>Fold1</a> s a -&gt; s -&gt; (a -&gt; f r) -&gt; f ()
--   </pre>
for1Of_ :: Functor f => Getting (TraversedF r f) s a -> s -> (a -> f r) -> f ()

-- | See <a>sequenceAOf_</a> and <a>traverse1Of_</a>.
--   
--   <pre>
--   <a>sequence1Of_</a> :: <a>Apply</a> f =&gt; <a>Fold1</a> s (f a) -&gt; s -&gt; f ()
--   </pre>
sequence1Of_ :: Functor f => Getting (TraversedF 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_ :: Monad m => Getting (Sequenced r m) s a -> (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_ :: Monad m => Getting (Sequenced r m) s a -> s -> (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>
--   <tt>asum</tt> ≡ <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

-- | 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

-- | 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 :: Getting [r] s a -> (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]

-- | 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>
(^?!) :: HasCallStack => s -> Getting (Endo a) s a -> a
infixl 8 ^?!

-- | Retrieve the <a>First</a> entry of a <a>Fold1</a> or <a>Traversal1</a>
--   or the result from a <a>Getter</a> or <a>Lens</a>.
--   
--   <pre>
--   &gt;&gt;&gt; first1Of traverse1 (1 :| [2..10])
--   1
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; first1Of both1 (1,2)
--   1
--   </pre>
--   
--   <i>Note:</i> this is different from <a>^.</a>.
--   
--   <pre>
--   &gt;&gt;&gt; first1Of traverse1 ([1,2] :| [[3,4],[5,6]])
--   [1,2]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ([1,2] :| [[3,4],[5,6]]) ^. traverse1
--   [1,2,3,4,5,6]
--   </pre>
--   
--   <pre>
--   <a>first1Of</a> :: <a>Getter</a> s a      -&gt; s -&gt; a
--   <a>first1Of</a> :: <a>Fold1</a> s a       -&gt; s -&gt; a
--   <a>first1Of</a> :: <a>Lens'</a> s a       -&gt; s -&gt; a
--   <a>first1Of</a> :: <a>Iso'</a> s a        -&gt; s -&gt; a
--   <a>first1Of</a> :: <a>Traversal1'</a> s a -&gt; s -&gt; a
--   </pre>
first1Of :: Getting (First a) s a -> s -> a

-- | Retrieve the <a>Last</a> entry of a <a>Fold1</a> or <a>Traversal1</a>
--   or retrieve the result from a <a>Getter</a> or <a>Lens</a>.o
--   
--   <pre>
--   &gt;&gt;&gt; last1Of traverse1 (1 :| [2..10])
--   10
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; last1Of both1 (1,2)
--   2
--   </pre>
--   
--   <pre>
--   <a>last1Of</a> :: <a>Getter</a> s a      -&gt; s -&gt; <a>Maybe</a> a
--   <a>last1Of</a> :: <a>Fold1</a> s a       -&gt; s -&gt; <a>Maybe</a> a
--   <a>last1Of</a> :: <a>Lens'</a> s a       -&gt; s -&gt; <a>Maybe</a> a
--   <a>last1Of</a> :: <a>Iso'</a> s a        -&gt; s -&gt; <a>Maybe</a> a
--   <a>last1Of</a> :: <a>Traversal1'</a> s a -&gt; s -&gt; <a>Maybe</a> a
--   </pre>
last1Of :: Getting (Last a) s a -> s -> a

-- | 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>not</a> <a>.</a> <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

-- | 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>
--   <tt>maximum</tt> ≡ <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> <tt>getMax</tt>
--   (<a>foldMapOf</a> l <tt>Max</tt>)</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 maximum element targeted by a <a>Fold1</a> or
--   <a>Traversal1</a>.
--   
--   <pre>
--   &gt;&gt;&gt; maximum1Of traverse1 (1 :| [2..10])
--   10
--   </pre>
--   
--   <pre>
--   <a>maximum1Of</a> :: <a>Ord</a> a =&gt; <a>Getter</a> s a      -&gt; s -&gt; a
--   <a>maximum1Of</a> :: <a>Ord</a> a =&gt; <a>Fold1</a> s a       -&gt; s -&gt; a
--   <a>maximum1Of</a> :: <a>Ord</a> a =&gt; <a>Iso'</a> s a        -&gt; s -&gt; a
--   <a>maximum1Of</a> :: <a>Ord</a> a =&gt; <a>Lens'</a> s a       -&gt; s -&gt; a
--   <a>maximum1Of</a> :: <a>Ord</a> a =&gt; <a>Traversal1'</a> s a -&gt; s -&gt; a
--   </pre>
maximum1Of :: Ord a => Getting (Max a) s a -> s -> 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>
--   <tt>minimum</tt> ≡ <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> <tt>getMin</tt>
--   (<a>foldMapOf</a> l <tt>Min</tt>)</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 minimum element targeted by a <a>Fold1</a> or
--   <a>Traversal1</a>.
--   
--   <pre>
--   &gt;&gt;&gt; minimum1Of traverse1 (1 :| [2..10])
--   1
--   </pre>
--   
--   <pre>
--   <a>minimum1Of</a> :: <a>Ord</a> a =&gt; <a>Getter</a> s a      -&gt; s -&gt; a
--   <a>minimum1Of</a> :: <a>Ord</a> a =&gt; <a>Fold1</a> s a       -&gt; s -&gt; a
--   <a>minimum1Of</a> :: <a>Ord</a> a =&gt; <a>Iso'</a> s a        -&gt; s -&gt; a
--   <a>minimum1Of</a> :: <a>Ord</a> a =&gt; <a>Lens'</a> s a       -&gt; s -&gt; a
--   <a>minimum1Of</a> :: <a>Ord</a> a =&gt; <a>Traversal1'</a> s a -&gt; s -&gt; a
--   </pre>
minimum1Of :: Ord a => Getting (Min a) s a -> s -> 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>
--   <tt>minimumBy</tt> 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 :: Getting (Endo (Maybe a)) s a -> (a -> Bool) -> s -> Maybe a

-- | The <a>findMOf</a> function takes a <a>Lens</a> (or <a>Getter</a>,
--   <a>Iso</a>, <a>Fold</a>, or <a>Traversal</a>), a monadic predicate and
--   a structure and returns in the monad the leftmost element of the
--   structure matching the predicate, or <a>Nothing</a> if there is no
--   such element.
--   
--   <pre>
--   &gt;&gt;&gt; findMOf each ( \x -&gt; print ("Checking " ++ show x) &gt;&gt; return (even x)) (1,3,4,6)
--   "Checking 1"
--   "Checking 3"
--   "Checking 4"
--   Just 4
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; findMOf each ( \x -&gt; print ("Checking " ++ show x) &gt;&gt; return (even x)) (1,3,5,7)
--   "Checking 1"
--   "Checking 3"
--   "Checking 5"
--   "Checking 7"
--   Nothing
--   </pre>
--   
--   <pre>
--   <a>findMOf</a> :: (<a>Monad</a> m, <a>Getter</a> s a)     -&gt; (a -&gt; m <a>Bool</a>) -&gt; s -&gt; m (<a>Maybe</a> a)
--   <a>findMOf</a> :: (<a>Monad</a> m, <a>Fold</a> s a)       -&gt; (a -&gt; m <a>Bool</a>) -&gt; s -&gt; m (<a>Maybe</a> a)
--   <a>findMOf</a> :: (<a>Monad</a> m, <a>Iso'</a> s a)       -&gt; (a -&gt; m <a>Bool</a>) -&gt; s -&gt; m (<a>Maybe</a> a)
--   <a>findMOf</a> :: (<a>Monad</a> m, <a>Lens'</a> s a)      -&gt; (a -&gt; m <a>Bool</a>) -&gt; s -&gt; m (<a>Maybe</a> a)
--   <a>findMOf</a> :: (<a>Monad</a> m, <a>Traversal'</a> s a) -&gt; (a -&gt; m <a>Bool</a>) -&gt; s -&gt; m (<a>Maybe</a> a)
--   </pre>
--   
--   <pre>
--   <a>findMOf</a> <a>folded</a> :: (Monad m, Foldable f) =&gt; (a -&gt; m Bool) -&gt; f a -&gt; m (Maybe a)
--   <a>ifindMOf</a> l ≡ <a>findMOf</a> l <a>.</a> <a>Indexed</a>
--   </pre>
--   
--   A simpler version that didn't permit indexing, would be:
--   
--   <pre>
--   <a>findMOf</a> :: Monad m =&gt; <a>Getting</a> (<a>Endo</a> (m (<a>Maybe</a> a))) s a -&gt; (a -&gt; m <a>Bool</a>) -&gt; s -&gt; m (<a>Maybe</a> a)
--   <a>findMOf</a> l p = <a>foldrOf</a> l (a y -&gt; p a &gt;&gt;= x -&gt; if x then return (<a>Just</a> a) else y) $ return <a>Nothing</a>
--   </pre>
findMOf :: Monad m => Getting (Endo (m (Maybe a))) s a -> (a -> m Bool) -> s -> m (Maybe a)

-- | The <a>lookupOf</a> function takes a <a>Fold</a> (or <a>Getter</a>,
--   <a>Traversal</a>, <a>Lens</a>, <a>Iso</a>, etc.), a key, and a
--   structure containing key/value pairs. It returns the first value
--   corresponding to the given key. This function generalizes
--   <a>lookup</a> to work on an arbitrary <a>Fold</a> instead of lists.
--   
--   <pre>
--   &gt;&gt;&gt; lookupOf folded 4 [(2, 'a'), (4, 'b'), (4, 'c')]
--   Just 'b'
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; lookupOf each 2 [(2, 'a'), (4, 'b'), (4, 'c')]
--   Just 'a'
--   </pre>
--   
--   <pre>
--   <a>lookupOf</a> :: <a>Eq</a> k =&gt; <a>Fold</a> s (k,v) -&gt; k -&gt; s -&gt; <a>Maybe</a> v
--   </pre>
lookupOf :: Eq k => Getting (Endo (Maybe v)) s (k, v) -> k -> s -> Maybe v

-- | 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 :: HasCallStack => 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 :: HasCallStack => Getting (Dual (Endo (Maybe a))) s a -> (a -> a -> a) -> s -> 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 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' :: HasCallStack => 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' :: HasCallStack => 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

-- | 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

-- | 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>Traversal'</a> s a -&gt; <a>IndexPreservingGetter</a> s (<a>Maybe</a> a)
--   <a>pre</a> :: <a>Lens'</a> s a      -&gt; <a>IndexPreservingGetter</a> s (<a>Maybe</a> a)
--   <a>pre</a> :: <a>Iso'</a> s a       -&gt; <a>IndexPreservingGetter</a> s (<a>Maybe</a> a)
--   <a>pre</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>IndexedTraversal'</a> i s a -&gt; <a>IndexPreservingGetter</a> s (<a>Maybe</a> (i, a))
--   <a>ipre</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 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 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 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 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 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 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)

-- | 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

-- | Return whether or not none of the 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>noneOf</a> is more
--   flexible in what it accepts.
--   
--   <pre>
--   <a>noneOf</a> l ≡ <a>inoneOf</a> l <a>.</a> <a>const</a>
--   </pre>
--   
--   <pre>
--   <a>inoneOf</a> :: <a>IndexedGetter</a> i s a     -&gt; (i -&gt; a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>inoneOf</a> :: <a>IndexedFold</a> i s a       -&gt; (i -&gt; a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>inoneOf</a> :: <a>IndexedLens'</a> i s a      -&gt; (i -&gt; a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   <a>inoneOf</a> :: <a>IndexedTraversal'</a> i s a -&gt; (i -&gt; a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Bool</a>
--   </pre>
inoneOf :: IndexedGetting i Any 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>ifindOf</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

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

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

-- | 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)
infixl 8 ^@?

-- | 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>
(^@?!) :: HasCallStack => s -> IndexedGetting i (Endo (i, a)) s a -> (i, a)
infixl 8 ^@?!

-- | Retrieve the index of the first value targeted by a <a>IndexedFold</a>
--   or <a>IndexedTraversal</a> which is equal to a given value.
--   
--   <pre>
--   <a>elemIndex</a> ≡ <a>elemIndexOf</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>elemIndexOf</a> :: <a>Eq</a> a =&gt; <a>IndexedFold</a> i s a       -&gt; a -&gt; s -&gt; <a>Maybe</a> i
--   <a>elemIndexOf</a> :: <a>Eq</a> a =&gt; <a>IndexedTraversal'</a> i s a -&gt; a -&gt; s -&gt; <a>Maybe</a> i
--   </pre>
elemIndexOf :: Eq a => IndexedGetting i (First i) s a -> a -> s -> Maybe i

-- | Retrieve the indices of the values targeted by a <a>IndexedFold</a> or
--   <a>IndexedTraversal</a> which are equal to a given value.
--   
--   <pre>
--   <a>elemIndices</a> ≡ <a>elemIndicesOf</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>elemIndicesOf</a> :: <a>Eq</a> a =&gt; <a>IndexedFold</a> i s a       -&gt; a -&gt; s -&gt; [i]
--   <a>elemIndicesOf</a> :: <a>Eq</a> a =&gt; <a>IndexedTraversal'</a> i s a -&gt; a -&gt; s -&gt; [i]
--   </pre>
elemIndicesOf :: Eq a => IndexedGetting i (Endo [i]) s a -> a -> s -> [i]

-- | Retrieve the index of the first value targeted by a <a>IndexedFold</a>
--   or <a>IndexedTraversal</a> which satisfies a predicate.
--   
--   <pre>
--   <a>findIndex</a> ≡ <a>findIndexOf</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>findIndexOf</a> :: <a>IndexedFold</a> i s a       -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Maybe</a> i
--   <a>findIndexOf</a> :: <a>IndexedTraversal'</a> i s a -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; <a>Maybe</a> i
--   </pre>
findIndexOf :: IndexedGetting i (First i) s a -> (a -> Bool) -> s -> Maybe i

-- | Retrieve the indices of the values targeted by a <a>IndexedFold</a> or
--   <a>IndexedTraversal</a> which satisfy a predicate.
--   
--   <pre>
--   <a>findIndices</a> ≡ <a>findIndicesOf</a> <a>folded</a>
--   </pre>
--   
--   <pre>
--   <a>findIndicesOf</a> :: <a>IndexedFold</a> i s a       -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; [i]
--   <a>findIndicesOf</a> :: <a>IndexedTraversal'</a> i s a -&gt; (a -&gt; <a>Bool</a>) -&gt; s -&gt; [i]
--   </pre>
findIndicesOf :: IndexedGetting i (Endo [i]) s a -> (a -> Bool) -> s -> [i]

-- | 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>ifiltered</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) -> Optical' 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
--   </pre>
--   
--   Note: Applying <a>itakingWhile</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 any
--   target to one where the predicate returns <a>False</a>, then you will
--   break the <a>Traversal</a> laws and <a>Traversal</a> fusion will no
--   longer be sound.
itakingWhile :: (Indexable i p, Profunctor q, Contravariant f, Applicative f) => (i -> a -> Bool) -> Optical' (Indexed i) q (Const (Endo (f s)) :: Type -> Type) s a -> Optical' p q f s 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
--   </pre>
--   
--   Note: As with <a>droppingWhile</a> 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 first target to one 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) -> Optical (Indexed i) q (Compose (State Bool) f) s t a a -> Optical p q f s t a a

-- | Fold a value using a specified <a>Fold</a> and <a>Monoid</a>
--   operations. This is like <a>foldBy</a> where the <a>Foldable</a>
--   instance can be manually specified.
--   
--   <pre>
--   <a>foldByOf</a> <a>folded</a> ≡ <a>foldBy</a>
--   </pre>
--   
--   <pre>
--   <a>foldByOf</a> :: <a>Getter</a> s a     -&gt; (a -&gt; a -&gt; a) -&gt; a -&gt; s -&gt; a
--   <a>foldByOf</a> :: <a>Fold</a> s a       -&gt; (a -&gt; a -&gt; a) -&gt; a -&gt; s -&gt; a
--   <a>foldByOf</a> :: <a>Lens'</a> s a      -&gt; (a -&gt; a -&gt; a) -&gt; a -&gt; s -&gt; a
--   <a>foldByOf</a> :: <a>Traversal'</a> s a -&gt; (a -&gt; a -&gt; a) -&gt; a -&gt; s -&gt; a
--   <a>foldByOf</a> :: <a>Iso'</a> s a       -&gt; (a -&gt; a -&gt; a) -&gt; a -&gt; s -&gt; a
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; foldByOf both (++) [] ("hello","world")
--   "helloworld"
--   </pre>
foldByOf :: Fold s a -> (a -> a -> a) -> a -> s -> a

-- | Fold a value using a specified <a>Fold</a> and <a>Monoid</a>
--   operations. This is like <a>foldMapBy</a> where the <a>Foldable</a>
--   instance can be manually specified.
--   
--   <pre>
--   <a>foldMapByOf</a> <a>folded</a> ≡ <a>foldMapBy</a>
--   </pre>
--   
--   <pre>
--   <a>foldMapByOf</a> :: <a>Getter</a> s a     -&gt; (r -&gt; r -&gt; r) -&gt; r -&gt; (a -&gt; r) -&gt; s -&gt; r
--   <a>foldMapByOf</a> :: <a>Fold</a> s a       -&gt; (r -&gt; r -&gt; r) -&gt; r -&gt; (a -&gt; r) -&gt; s -&gt; r
--   <a>foldMapByOf</a> :: <a>Traversal'</a> s a -&gt; (r -&gt; r -&gt; r) -&gt; r -&gt; (a -&gt; r) -&gt; s -&gt; r
--   <a>foldMapByOf</a> :: <a>Lens'</a> s a      -&gt; (r -&gt; r -&gt; r) -&gt; r -&gt; (a -&gt; r) -&gt; s -&gt; r
--   <a>foldMapByOf</a> :: <a>Iso'</a> s a       -&gt; (r -&gt; r -&gt; r) -&gt; r -&gt; (a -&gt; r) -&gt; s -&gt; r
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; foldMapByOf both (+) 0 length ("hello","world")
--   10
--   </pre>
foldMapByOf :: Fold s a -> (r -> r -> r) -> r -> (a -> r) -> s -> r

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

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

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

-- | <a>IndexedTraversal</a> of the element with the smallest index.
traverseMin :: TraverseMin k m => IndexedTraversal' k (m v) v
type Traversing1' (p :: Type -> Type -> Type) (f :: Type -> Type) s a = Traversing1 p f s s a a

-- | <pre>
--   type <a>Traversing'</a> f = <a>Simple</a> (<a>Traversing</a> f)
--   </pre>
type Traversing' (p :: Type -> Type -> Type) (f :: Type -> Type) s a = Traversing p f s s a a
type Traversing1 (p :: Type -> Type -> Type) (f :: Type -> Type) s t a b = Over p BazaarT1 p f a b s t a b

-- | 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 a <a>Functor</a> and
--   <a>Contravariant</a>,</li>
--   <li>a <a>Lens</a> if <tt>f</tt> is only a <a>Functor</a>,</li>
--   <li>a <a>Fold</a> if <tt>f</tt> is <a>Applicative</a> and
--   <a>Contravariant</a>.</li>
--   </ul>
type Traversing (p :: Type -> Type -> Type) (f :: Type -> Type) s t a b = Over p BazaarT p f a b s t a b

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

-- | <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 an
--   <a>IndexedTraversal1</a>.
type AnIndexedTraversal1 i s t a b = Over Indexed i Bazaar1 Indexed i a b s t a b

-- | 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>ATraversal1'</a> = <a>Simple</a> <a>ATraversal1</a>
--   </pre>
type ATraversal1' s a = ATraversal1 s s a a

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

-- | Build a <a>Traversal</a> by providing a function which specifies the
--   elements you wish to focus.
--   
--   The caller provides a function of type:
--   
--   <pre>
--   Applicative f =&gt; (a -&gt; f b) -&gt; s -&gt; f t
--   </pre>
--   
--   Which is a higher order function which accepts a "focusing function"
--   and applies it to all desired focuses within <tt>s</tt>, then
--   constructs a <tt>t</tt> using the Applicative instance of <tt>f</tt>.
--   
--   Only elements which are "focused" using the focusing function will be
--   targeted by the resulting traversal.
--   
--   For example, we can explicitly write a traversal which targets the
--   first and third elements of a tuple like this:
--   
--   <pre>
--   firstAndThird :: Traversal (a, x, a) (b, x, b) a b
--   firstAndThird = traversal go
--     where
--       go :: Applicative f =&gt; (a -&gt; f b) -&gt; (a, x, a) -&gt; f (b, x, b)
--       go focus (a, x, a') = liftA3 (,,) (focus a) (pure x) (focus a')
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (1,"two",3) &amp; firstAndThird *~ 10
--   (10,"two",30)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; over firstAndThird length ("one",2,"three")
--   (3,2,5)
--   </pre>
--   
--   We can re-use existing <a>Traversal</a>s when writing new ones by
--   passing our focusing function along to them. This example re-uses
--   <a>traverse</a> to focus all elements in a list which is embedded in a
--   tuple. This traversal could also be written simply as <tt>_2 .
--   traverse</tt>.
--   
--   <pre>
--   selectNested :: Traversal (x, [a]) (x, [b]) a b
--   selectNested = traversal go
--     where
--       go :: Applicative f =&gt; (a -&gt; f b) -&gt; (x, [a]) -&gt; f (x, [b])
--       go focus (x, as) = liftA2 (,) (pure x) (traverse focus as)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; selectNested .~ "hello" $ (1,[2,3,4,5])
--   (1,["hello","hello","hello","hello"])
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (1,[2,3,4,5]) &amp; selectNested *~ 3
--   (1,[6,9,12,15])
--   </pre>
--   
--   Note that the <a>traversal</a> function actually just returns the same
--   function you pass to it. The function it accepts is in fact a valid
--   traversal all on its own! The use of <a>traversal</a> does nothing
--   except verify that the function it is passed matches the signature of
--   a valid traversal. One could remove the <tt>traversal</tt> combinator
--   from either of the last two examples and use the definition of
--   <tt>go</tt> directly with no change in behaviour.
--   
--   This function exists for consistency with the <a>lens</a>,
--   <tt>prism</tt> and <tt>iso</tt> constructors as well as to serve as a
--   touchpoint for beginners who wish to construct their own traversals
--   but are uncertain how to do so.
traversal :: ((a -> f b) -> s -> f t) -> LensLike f s t a b

-- | 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

-- | 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 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

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

-- | This <a>IndexedTraversal</a> allows you to <a>traverse</a> the
--   individual stores in a <a>Bazaar</a> with access to their indices.
iloci :: forall i a c s b p f. (Indexable i p, Applicative f) => p a (f b) -> Bazaar (Indexed i) a c s -> f (Bazaar (Indexed i) b c s)

-- | <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.
--   
--   <pre>
--   &gt;&gt;&gt; (a,b,c) &amp; partsOf each .~ [x,y,z]
--   (x,y,z)
--   </pre>
--   
--   Any extras will be lost. If you do not supply enough, then the
--   remainder will come from the original structure.
--   
--   <pre>
--   &gt;&gt;&gt; (a,b,c) &amp; partsOf each .~ [w,x,y,z]
--   (w,x,y)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (a,b,c) &amp; partsOf each .~ [x,y]
--   (x,y,c)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ('b', 'a', 'd', 'c') &amp; partsOf each %~ sort
--   ('a','b','c','d')
--   </pre>
--   
--   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]

-- | 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>partsOf</a> that can only be used with
--   a <a>Traversal</a>.
partsOf' :: ATraversal s t a a -> Lens s t [a] [a]

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

-- | 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]
unsafePartsOf' :: ATraversal s t a b -> Lens s t [a] [b]
iunsafePartsOf' :: forall i s t a b. Over (Indexed i) (Bazaar (Indexed i) a b) s t a b -> IndexedLens [i] s t [a] [b]

-- | 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>.
--   
--   The resulting <a>Lens</a> or <a>Getter</a> will be partial if the
--   <a>Traversal</a> targets nothing or more than one element.
--   
--   <pre>
--   &gt;&gt;&gt; Left (ErrorCall "unsafeSingular: empty traversal") &lt;- try (evaluate ([] &amp; unsafeSingular traverse .~ 0)) :: IO (Either ErrorCall [Integer])
--   </pre>
--   
--   <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>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
--   </pre>
unsafeSingular :: (HasCallStack, Conjoined p, Functor f) => Traversing p f s t a b -> Over p f 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 = <a>toListOf</a> 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]

-- | The non-empty version of <a>holesOf</a>. This extract a non-empty list
--   of immediate children according to a given <a>Traversal1</a> as
--   editable contexts.
--   
--   <pre>
--   &gt;&gt;&gt; let head1 f s = runPretext (NonEmpty.head $ holes1Of traversed1 s) f
--   
--   &gt;&gt;&gt; ('a' :| "bc") ^. head1
--   'a'
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ('a' :| "bc") &amp; head1 %~ toUpper
--   'A' :| "bc"
--   </pre>
--   
--   <pre>
--   <a>holes1Of</a> :: <a>Iso'</a> s a                 -&gt; s -&gt; <a>NonEmpty</a> (<a>Pretext'</a> (-&gt;) a s)
--   <a>holes1Of</a> :: <a>Lens'</a> s a                -&gt; s -&gt; <a>NonEmpty</a> (<a>Pretext'</a> (-&gt;) a s)
--   <a>holes1Of</a> :: <a>Traversal1'</a> s a          -&gt; s -&gt; <a>NonEmpty</a> (<a>Pretext'</a> (-&gt;) a s)
--   <a>holes1Of</a> :: <a>IndexedLens'</a> i s a       -&gt; s -&gt; <a>NonEmpty</a> (<a>Pretext'</a> (<a>Indexed</a> i) a s)
--   <a>holes1Of</a> :: <a>IndexedTraversal1'</a> i s a -&gt; s -&gt; <a>NonEmpty</a> (<a>Pretext'</a> (<a>Indexed</a> i) a s)
--   </pre>
holes1Of :: Conjoined p => Over p (Bazaar1 p a a) s t a a -> s -> NonEmpty (Pretext p a a t)

-- | Traverse both parts of a <a>Bitraversable1</a> container with matching
--   types.
--   
--   Usually that type will be a pair.
--   
--   <pre>
--   <a>both1</a> :: <a>Traversal1</a> (a, a)       (b, b)       a b
--   <a>both1</a> :: <a>Traversal1</a> (<a>Either</a> a a) (<a>Either</a> b b) a b
--   </pre>
both1 :: forall (r :: Type -> Type -> Type) a b. Bitraversable1 r => Traversal1 (r a a) (r b b) 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 <a>Traversal1</a> is completely characterized by its behavior on a
--   <a>Bazaar1</a>.
cloneTraversal1 :: ATraversal1 s t a b -> Traversal1 s t a b

-- | Clone a <a>Traversal1</a> yielding an <a>IndexPreservingTraversal1</a>
--   that passes through whatever index it is composed with.
cloneIndexPreservingTraversal1 :: ATraversal1 s t a b -> IndexPreservingTraversal1 s t a b

-- | Clone an <a>IndexedTraversal1</a> yielding an <a>IndexedTraversal1</a>
--   with the same index.
cloneIndexedTraversal1 :: AnIndexedTraversal1 i s t a b -> IndexedTraversal1 i s t a b

-- | 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
--   <a>iforOf</a> :: <a>Apply</a> f       =&gt; <a>IndexedTraversal1</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

-- | 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)

-- | Traverse any <a>Traversable1</a> container. This is an
--   <a>IndexedTraversal1</a> that is indexed by ordinal position.
traversed1 :: forall (f :: Type -> Type) a b. Traversable1 f => IndexedTraversal1 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 :: forall (f :: Type -> Type) a b. Traversable f => IndexedTraversal Int64 (f a) (f b) a b

-- | 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

-- | Traverse the <i>nth</i> <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 :: forall (f :: Type -> Type) s t a. 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 :: forall (t :: Type -> Type) a. 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 :: forall (f :: Type -> Type) s t a. 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 match a predicate.
--   
--   <pre>
--   <a>elements</a> ≡ <a>elementsOf</a> <a>traverse</a>
--   </pre>
elements :: forall (t :: Type -> Type) a. Traversable t => (Int -> Bool) -> IndexedTraversal' Int (t a) a

-- | 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>
--   
--   <pre>
--   <a>failover</a> :: Alternative m =&gt; Traversal s t a b -&gt; (a -&gt; b) -&gt; s -&gt; m t
--   </pre>
failover :: Alternative m => LensLike ((,) Any) s t a b -> (a -> b) -> s -> m t

-- | Try to map a function which uses the index over this
--   <a>IndexedTraversal</a>, failing if the <a>IndexedTraversal</a> has no
--   targets.
--   
--   <pre>
--   <a>ifailover</a> :: Alternative m =&gt; IndexedTraversal i s t a b -&gt; (i -&gt; a -&gt; b) -&gt; s -&gt; m t
--   </pre>
ifailover :: Alternative m => Over (Indexed i) ((,) Any) s t a b -> (i -> a -> b) -> s -> m t

-- | Try the second traversal. If it returns no entries, try again with all
--   entries from the first traversal, recursively.
--   
--   <pre>
--   <a>deepOf</a> :: <a>Fold</a> s s          -&gt; <a>Fold</a> s a                   -&gt; <a>Fold</a> s a
--   <a>deepOf</a> :: <a>Traversal'</a> s s    -&gt; <a>Traversal'</a> s a             -&gt; <a>Traversal'</a> s a
--   <a>deepOf</a> :: <a>Traversal</a> s t s t -&gt; <a>Traversal</a> s t a b          -&gt; <a>Traversal</a> s t a b
--   <a>deepOf</a> :: <a>Fold</a> s s          -&gt; <a>IndexedFold</a> i s a          -&gt; <a>IndexedFold</a> i s a
--   <a>deepOf</a> :: <a>Traversal</a> s t s t -&gt; <a>IndexedTraversal</a> i s t a b -&gt; <a>IndexedTraversal</a> i s t a b
--   </pre>
deepOf :: (Conjoined p, Applicative f) => LensLike f s t s t -> Traversing p f s t a b -> Over p f s t a b

-- | <a>Fuse</a> a <a>Traversal</a> by reassociating all of the
--   <tt>(<a>&lt;*&gt;</a>)</tt> operations to the left and fusing all of
--   the <a>fmap</a> calls into one. This is particularly useful when
--   constructing a <a>Traversal</a> using operations from
--   <a>GHC.Generics</a>.
--   
--   Given a pair of <a>Traversal</a>s <tt>foo</tt> and <tt>bar</tt>,
--   
--   <pre>
--   <a>confusing</a> (foo.bar) = foo.bar
--   </pre>
--   
--   However, <tt>foo</tt> and <tt>bar</tt> are each going to use the
--   <a>Applicative</a> they are given.
--   
--   <a>confusing</a> exploits the <a>Yoneda</a> lemma to merge their
--   separate uses of <a>fmap</a> into a single <a>fmap</a>. and it further
--   exploits an interesting property of the right Kan lift (or
--   <a>Curried</a>) to left associate all of the uses of
--   <tt>(<a>&lt;*&gt;</a>)</tt> to make it possible to fuse together more
--   fmaps.
--   
--   This is particularly effective when the choice of functor <tt>f</tt>
--   is unknown at compile time or when the <a>Traversal</a>
--   <tt>foo.bar</tt> in the above description is recursive or complex
--   enough to prevent inlining.
--   
--   <a>fusing</a> is a version of this combinator suitable for fusing
--   lenses.
--   
--   <pre>
--   <a>confusing</a> :: <a>Traversal</a> s t a b -&gt; <a>Traversal</a> s t a b
--   </pre>
confusing :: Applicative f => LensLike (Curried (Yoneda f) (Yoneda f)) s t a b -> LensLike f s t a b

-- | Traverse a container using a specified <a>Applicative</a>.
--   
--   This is like <a>traverseBy</a> where the <a>Traversable</a> instance
--   can be specified by any <a>Traversal</a>
--   
--   <pre>
--   <a>traverseByOf</a> <a>traverse</a> ≡ <a>traverseBy</a>
--   </pre>
traverseByOf :: Traversal s t a b -> (forall x. () => x -> f x) -> (forall x y. () => f (x -> y) -> f x -> f y) -> (a -> f b) -> s -> f t

-- | Sequence a container using a specified <a>Applicative</a>.
--   
--   This is like <a>traverseBy</a> where the <a>Traversable</a> instance
--   can be specified by any <a>Traversal</a>
--   
--   <pre>
--   <a>sequenceByOf</a> <a>traverse</a> ≡ <a>sequenceBy</a>
--   </pre>
sequenceByOf :: Traversal s t (f b) b -> (forall x. () => x -> f x) -> (forall x y. () => f (x -> y) -> f x -> f y) -> s -> f t

-- | This provides a breadth-first <a>Traversal</a> or <a>Fold</a> of the
--   individual levels of any other <a>Traversal</a> or <a>Fold</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>
--   
--   <pre>
--   <a>ilevels</a> :: <a>IndexedTraversal</a> i s t a b      -&gt; <a>IndexedTraversal</a> <a>Int</a> s t (<a>Level</a> i a) (<a>Level</a> i b)
--   <a>ilevels</a> :: <a>IndexedFold</a> i s a               -&gt; <a>IndexedFold</a> <a>Int</a> s (<a>Level</a> i a)
--   </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 :: forall (f :: Type -> Type) i s t a b j. Applicative f => Traversing (Indexed i) f s t a b -> IndexedLensLike Int f s t (Level i a) (Level j b)

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

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

-- | <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

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

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

-- | <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

-- | <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

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

-- | Compose an <a>Indexed</a> function with a non-indexed function.
--   
--   Mnemonically, the <tt>&lt;</tt> points to the indexing we want to
--   preserve.
--   
--   <pre>
--   &gt;&gt;&gt; let nestedMap = (fmap Map.fromList . Map.fromList) [(1, [(10, "one,ten"), (20, "one,twenty")]), (2, [(30, "two,thirty"), (40,"two,forty")])]
--   
--   &gt;&gt;&gt; nestedMap^..(itraversed&lt;.itraversed).withIndex
--   [(1,"one,ten"),(1,"one,twenty"),(2,"two,thirty"),(2,"two,forty")]
--   </pre>
(<.) :: Indexable i p => (Indexed i s t -> r) -> ((a -> b) -> s -> t) -> p a b -> r
infixr 9 <.

-- | Use a value itself as its own index. This is essentially an indexed
--   version of <a>id</a>.
--   
--   Note: When used to modify the value, this can break the index
--   requirements assumed by <a>indices</a> and similar, so this is only
--   properly an <a>IndexedGetter</a>, but it can be used as more.
--   
--   <pre>
--   <a>selfIndex</a> :: <a>IndexedGetter</a> a a b
--   </pre>
selfIndex :: Indexable a p => p a fb -> a -> fb

-- | 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

-- | The <a>IndexedSetter</a> for a <a>FunctorWithIndex</a>.
--   
--   If you don't need access to the index, then <a>mapped</a> is more
--   flexible in what it accepts.
imapped :: forall i (f :: Type -> Type) a b. FunctorWithIndex i f => IndexedSetter i (f a) (f b) a b

-- | The <a>IndexedFold</a> of a <a>FoldableWithIndex</a> container.
--   
--   <tt><a>ifolded</a> <a>.</a> <a>asIndex</a></tt> is a fold over the
--   keys of a <a>FoldableWithIndex</a>.
--   
--   <pre>
--   &gt;&gt;&gt; Data.Map.fromList [(2, "hello"), (1, "world")]^..ifolded.asIndex
--   [1,2]
--   </pre>
ifolded :: forall i (f :: Type -> Type) a. FoldableWithIndex i f => IndexedFold i (f a) a

-- | The <a>IndexedTraversal</a> of a <a>TraversableWithIndex</a>
--   container.
itraversed :: forall i (t :: Type -> Type) a b. TraversableWithIndex i t => IndexedTraversal i (t a) (t b) a b
ifoldMapBy :: FoldableWithIndex i t => (r -> r -> r) -> r -> (i -> a -> r) -> t a -> r
ifoldMapByOf :: IndexedFold i t a -> (r -> r -> r) -> r -> (i -> a -> r) -> t -> r
itraverseBy :: TraversableWithIndex i t => (forall x. () => x -> f x) -> (forall x y. () => f (x -> y) -> f x -> f y) -> (i -> a -> f b) -> t a -> f (t b)
itraverseByOf :: IndexedTraversal i s t a b -> (forall x. () => x -> f x) -> (forall x y. () => f (x -> y) -> f x -> f y) -> (i -> a -> f b) -> s -> f t

-- | A <a>Simple</a> <a>AnEquality</a>.
type AnEquality' (s :: k) (a :: k) = AnEquality s s a a

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

-- | Provides witness that <tt>(s ~ a, b ~ t)</tt> holds.
data Identical (a :: k) (b :: k1) (s :: k) (t :: k1)
[Identical] :: forall {k} {k1} (a :: k) (b :: k1). Identical a b a b

-- | Extract a witness of type <a>Equality</a>.
runEq :: forall {k1} {k2} (s :: k1) (t :: k2) (a :: k1) (b :: k2). AnEquality s t a b -> Identical s t a b

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

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

-- | <a>Equality</a> is symmetric.
fromEq :: forall {k2} {k1} (s :: k2) (t :: k1) (a :: k2) (b :: k1). 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 :: forall {k} {k1} p (f :: k -> k1) (s :: k) (a :: k) r. (Optic' p f s a -> r) -> Optic' p f s a -> r

-- | 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 :: forall {k2} (a :: k2) k3 p (f :: k2 -> k3). p a (f a) -> p a (f a)
cloneEquality :: forall {k1} {k2} (s :: k1) (t :: k2) (a :: k1) (b :: k2). AnEquality s t a b -> Equality s t a b

-- | Construct an <a>Equality</a> from explicit equality evidence.
equality :: forall {k1} {k2} (s :: k1) (a :: k1) (b :: k2) (t :: k2). (s :~: a) -> (b :~: t) -> Equality s t a b

-- | A <a>Simple</a> version of <a>equality</a>
equality' :: forall {k2} (a :: k2) (b :: k2). (a :~: b) -> Equality' a b

-- | Recover a "profunctor lens" form of equality. Reverses
--   <a>fromLeibniz</a>.
overEquality :: forall {k1} {k2} (s :: k1) (t :: k2) (a :: k1) (b :: k2) p. AnEquality s t a b -> p a b -> p s t

-- | The opposite of working <a>overEquality</a> is working
--   <a>underEquality</a>.
underEquality :: forall {k1} {k2} (s :: k1) (t :: k2) (a :: k1) (b :: k2) p. AnEquality s t a b -> p t s -> p b a

-- | Convert a "profunctor lens" form of equality to an equality. Reverses
--   <a>overEquality</a>.
--   
--   The type should be understood as
--   
--   <pre>
--   fromLeibniz :: (forall p. p a b -&gt; p s t) -&gt; Equality s t a b
--   </pre>
fromLeibniz :: forall {k1} {k2} (a :: k1) (b :: k2) (s :: k1) (t :: k2). (Identical a b a b -> Identical a b s t) -> Equality s t a b

-- | Convert Leibniz equality to equality. Reverses <a>mapEq</a> in
--   <a>Simple</a> cases.
--   
--   The type should be understood as
--   
--   <pre>
--   fromLeibniz' :: (forall f. f s -&gt; f a) -&gt; Equality' s a
--   </pre>
fromLeibniz' :: forall {k2} (s :: k2) (a :: k2). ((s :~: s) -> s :~: a) -> Equality' s a

-- | A version of <a>substEq</a> that provides explicit, rather than
--   implicit, equality evidence.
withEquality :: forall {k1} {k2} (s :: k1) (t :: k2) (a :: k1) (b :: k2) r. AnEquality s t a b -> ((s :~: a) -> (b :~: t) -> r) -> r

-- | A <a>Simple</a> <a>AnIso</a>.
type AnIso' s a = AnIso 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 Identity b -> Exchange a b s Identity t
pattern Reversed :: Reversing t => t -> t
pattern Swapped :: Swap p => p b a -> p a b

-- | 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>over</a> (<a>iso</a> f g) h ≡ g <a>.</a> h <a>.</a> f
--   <a>over</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

-- | 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

-- | 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

-- | 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>
--   
--   You may want to think of this combinator as having the following,
--   simpler type:
--   
--   <pre>
--   au :: AnIso s t a b -&gt; ((b -&gt; t) -&gt; e -&gt; s) -&gt; e -&gt; a
--   </pre>
--   
--   <pre>
--   au = xplat . from
--   </pre>
au :: Functor f => AnIso s t a b -> ((b -> t) -> f s) -> f a

-- | 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>.
--   
--   <pre>
--   &gt;&gt;&gt; auf (_Wrapping Sum) (foldMapOf both) Prelude.length ("hello","world")
--   10
--   </pre>
--   
--   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>
--   <a>auf</a> :: <a>Iso</a> s t a b -&gt; ((r -&gt; t) -&gt; e -&gt; s) -&gt; (r -&gt; b) -&gt; e -&gt; a
--   </pre>
--   
--   but the signature is general.
--   
--   Note: The direction of the <a>Iso</a> required for this function
--   changed in <tt>lens</tt> 4.18 to match up with the behavior of
--   <a>au</a>. For the old behavior use <a>xplatf</a> or for a version
--   that is compatible across both old and new versions of <tt>lens</tt>
--   you can just use <a>coerce</a>!
auf :: (Functor f, Functor g) => AnIso s t a b -> (f t -> g s) -> f b -> g a

-- | <tt><a>xplat</a> = <a>au</a> . <a>from</a></tt> but with a nicer
--   signature.
xplat :: forall {k2} s g (t :: k2) a (b :: k2). Optic (Costar ((->) s)) g s t a b -> ((s -> a) -> g b) -> g t

-- | <tt><a>xplatf</a> = <a>auf</a> . <a>from</a></tt> but with a nicer
--   signature.
--   
--   <pre>
--   &gt;&gt;&gt; xplatf (_Unwrapping Sum) (foldMapOf both) Prelude.length ("hello","world")
--   10
--   </pre>
--   
--   <pre>
--   <a>xplatf</a> :: <a>Iso</a> s t a b -&gt; ((r -&gt; a) -&gt; e -&gt; b) -&gt; (r -&gt; s) -&gt; e -&gt; t
--   </pre>
xplatf :: forall {k} {k2} f g (s :: k) (t :: k2) (a :: k) (b :: k2). Optic (Costar f) g s t a b -> (f a -> g b) -> f s -> g 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 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

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

-- | 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>.
--   
--   <pre>
--   <a>non</a> ≡ <a>non'</a> <a>.</a> <a>only</a>
--   </pre>
--   
--   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; Map.fromList [("hello",Map.fromList [("world","!!!")])] &amp; at "hello" . non Map.empty . at "world" .~ Nothing
--   fromList []
--   </pre>
--   
--   It can also be used in reverse to exclude a given value:
--   
--   <pre>
--   &gt;&gt;&gt; non 0 # rem 10 4
--   Just 2
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; non 0 # rem 10 5
--   Nothing
--   </pre>
non :: Eq a => a -> Iso' (Maybe a) a

-- | <tt><a>non'</a> p</tt> generalizes <tt><a>non</a> (p # ())</tt> to
--   take any unit <a>Prism</a>
--   
--   This function generates an isomorphism between <tt><a>Maybe</a> (a |
--   <a>isn't</a> p a)</tt> and <tt>a</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; Map.singleton "hello" Map.empty &amp; at "hello" . non' _Empty . at "world" ?~ "!!!"
--   fromList [("hello",fromList [("world","!!!")])]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Map.fromList [("hello",Map.fromList [("world","!!!")])] &amp; at "hello" . non' _Empty . at "world" .~ Nothing
--   fromList []
--   </pre>
non' :: APrism' 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; Map.fromList [("hello",Map.fromList [("world","!!!")])] &amp; at "hello" . anon Map.empty Map.null . at "world" .~ Nothing
--   fromList []
--   </pre>
anon :: a -> (a -> Bool) -> Iso' (Maybe a) 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 :: forall a b c d e f1 p f2. (Profunctor p, Functor f2) => p (a -> b -> c) (f2 (d -> e -> f1)) -> p ((a, b) -> c) (f2 ((d, e) -> f1))

-- | 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 :: forall a b c d e f1 p f2. (Profunctor p, Functor f2) => p ((a, b) -> c) (f2 ((d, e) -> f1)) -> p (a -> b -> c) (f2 (d -> e -> f1))

-- | The isomorphism for flipping a function.
--   
--   <pre>
--   &gt;&gt;&gt; ((,)^.flipped) 1 2
--   (2,1)
--   </pre>
flipped :: forall a b c a' b' c' p f. (Profunctor p, Functor f) => p (b -> a -> c) (f (b' -> a' -> c')) -> p (a -> b -> c) (f (a' -> b' -> c'))

-- | <pre>
--   <a>swapped</a> <a>.</a> <a>swapped</a> ≡ <a>id</a>
--   <a>first</a> f <a>.</a> <a>swapped</a> = <a>swapped</a> <a>.</a> <a>second</a> f
--   <a>second</a> g <a>.</a> <a>swapped</a> = <a>swapped</a> <a>.</a> <a>first</a> g
--   <a>bimap</a> f g <a>.</a> <a>swapped</a> = <a>swapped</a> <a>.</a> <a>bimap</a> g f
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (1,2)^.swapped
--   (2,1)
--   </pre>
swapped :: forall (p :: Type -> Type -> Type) a b c d. Swap p => Iso (p a b) (p c d) (p b a) (p d c)

-- | An <a>Iso</a> between a list, <tt>ByteString</tt>, <tt>Text</tt>
--   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 :: Over (Indexed i) (Molten i a b) s t a b -> Iso s t' (Magma i t b a) (Magma j t' c c)

-- | 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 :: forall (f :: Type -> Type) s t a b. Contravariant f => AnIso s t a b -> Iso (f a) (f b) (f s) (f t)

-- | 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 :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) s t a b s' t' a' b'. (Profunctor p, Profunctor q) => AnIso s t a b -> AnIso s' t' a' b' -> Iso (p a s') (q b t') (p s a') (q 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 :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) s t a b x y. (Profunctor p, Profunctor q) => AnIso s t a b -> Iso (p a x) (q b y) (p s x) (q 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 :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) s t a b x y. (Profunctor p, Profunctor q) => AnIso s t a b -> Iso (p x s) (q y t) (p x a) (q y b)

-- | Lift two <a>Iso</a>s into both arguments of a <a>Bifunctor</a>.
--   
--   <pre>
--   bimapping :: <a>Bifunctor</a> p =&gt; <a>Iso</a> s t a b -&gt; <a>Iso</a> s' t' a' b' -&gt; <a>Iso</a> (p s s') (p t t') (p a a') (p b b')
--   bimapping :: <a>Bifunctor</a> p =&gt; <a>Iso'</a> s a -&gt; <a>Iso'</a> s' a' -&gt; <a>Iso'</a> (p s s') (p a a')
--   </pre>
bimapping :: forall (f :: Type -> Type -> Type) (g :: Type -> Type -> Type) s t a b s' t' a' b'. (Bifunctor f, Bifunctor g) => AnIso s t a b -> AnIso s' t' a' b' -> Iso (f s s') (g t t') (f a a') (g b b')

-- | Lift an <a>Iso</a> into the first argument of a <a>Bifunctor</a>.
--   
--   <pre>
--   firsting :: <a>Bifunctor</a> p =&gt; <a>Iso</a> s t a b -&gt; <a>Iso</a> (p s x) (p t y) (p a x) (p b y)
--   firsting :: <a>Bifunctor</a> p =&gt; <a>Iso'</a> s a -&gt; <a>Iso'</a> (p s x) (p a x)
--   </pre>
firsting :: forall (f :: Type -> Type -> Type) (g :: Type -> Type -> Type) s t a b x y. (Bifunctor f, Bifunctor g) => AnIso s t a b -> Iso (f s x) (g t y) (f a x) (g b y)

-- | Lift an <a>Iso</a> into the second argument of a <a>Bifunctor</a>.
--   This is essentially the same as <a>mapping</a>, but it takes a
--   'Bifunctor p' constraint instead of a 'Functor (p a)' one.
--   
--   <pre>
--   seconding :: <a>Bifunctor</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)
--   seconding :: <a>Bifunctor</a> p =&gt; <a>Iso'</a> s a -&gt; <a>Iso'</a> (p x s) (p x a)
--   </pre>
seconding :: forall (f :: Type -> Type -> Type) (g :: Type -> Type -> Type) s t a b x y. (Bifunctor f, Bifunctor g) => AnIso s t a b -> Iso (f x s) (g y t) (f x a) (g y b)

-- | Data types that are representationally equal are isomorphic.
--   
--   This is only available on GHC 7.8+
coerced :: forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b

-- | This class provides a way to attach or detach elements on the right
--   side of a structure in a flexible manner.
class Snoc s t a b | s -> a, t -> b, s b -> t, t a -> s

-- | <pre>
--   <a>_Snoc</a> :: <a>Prism</a> [a] [b] ([a], a) ([b], b)
--   <a>_Snoc</a> :: <a>Prism</a> (<a>Seq</a> a) (<a>Seq</a> b) (<a>Seq</a> a, a) (<a>Seq</a> b, b)
--   <a>_Snoc</a> :: <a>Prism</a> (<a>Vector</a> a) (<a>Vector</a> b) (<a>Vector</a> a, a) (<a>Vector</a> b, b)
--   <a>_Snoc</a> :: <a>Prism'</a> <a>String</a> (<a>String</a>, <a>Char</a>)
--   <a>_Snoc</a> :: <a>Prism'</a> <a>Text</a> (<a>Text</a>, <a>Char</a>)
--   <a>_Snoc</a> :: <a>Prism'</a> <a>ByteString</a> (<a>ByteString</a>, <a>Word8</a>)
--   </pre>
_Snoc :: Snoc s t a b => Prism s t (s, a) (t, b)

-- | This class provides a way to attach or detach elements on the left
--   side of a structure in a flexible manner.
class Cons s t a b | s -> a, t -> b, s b -> t, t a -> s

-- | <pre>
--   <a>_Cons</a> :: <a>Prism</a> [a] [b] (a, [a]) (b, [b])
--   <a>_Cons</a> :: <a>Prism</a> (<a>Seq</a> a) (<a>Seq</a> b) (a, <a>Seq</a> a) (b, <a>Seq</a> b)
--   <a>_Cons</a> :: <a>Prism</a> (<a>Vector</a> a) (<a>Vector</a> b) (a, <a>Vector</a> a) (b, <a>Vector</a> b)
--   <a>_Cons</a> :: <a>Prism'</a> <a>String</a> (<a>Char</a>, <a>String</a>)
--   <a>_Cons</a> :: <a>Prism'</a> <a>Text</a> (<a>Char</a>, <a>Text</a>)
--   <a>_Cons</a> :: <a>Prism'</a> <a>ByteString</a> (<a>Word8</a>, <a>ByteString</a>)
--   </pre>
_Cons :: Cons s t a b => Prism s t (a, s) (b, t)

-- | 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 s s a a => Traversal' 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 s s a a => Traversal' s s

-- | (<a>&lt;|</a>) a value onto the target of a <a>Lens</a> and return the
--   result.
--   
--   When you do not need the result of the operation, (<a>&lt;|~</a>) is
--   more flexible.
(<<|~) :: Cons b b a a => LensLike ((,) b) s t b b -> a -> s -> (b, t)
infixr 4 <<|~

-- | (<a>&lt;|</a>) a value onto the target of a <a>Lens</a> and return the
--   <i>old</i> result.
--   
--   When you do not need the result of the operation, (<a>&lt;|~</a>) is
--   more flexible.
(<<<|~) :: Cons b b a a => LensLike' ((,) b) s b -> a -> s -> (b, s)
infixr 4 <<<|~

-- | (<a>&lt;|</a>) a value onto the target of a <a>Lens</a> into your
--   <a>Monad</a>'s state and return the result.
--   
--   When you do not need the result of the operation, (<a>&lt;|=</a>) is
--   more flexible.
(<<|=) :: (MonadState s m, Cons b b a a) => LensLike ((,) b) s s b b -> a -> m b
infix 4 <<|=

-- | (<a>&lt;|</a>) a value onto the target of a <a>Lens</a> into your
--   <a>Monad</a>'s state and return the <i>old</i> result.
--   
--   When you do not need the result of the operation, (<a>&lt;|=</a>) is
--   more flexible.
(<<<|=) :: (MonadState s m, Cons b b a a) => LensLike ((,) b) s s b b -> a -> m b
infix 4 <<<|=

-- | 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 s s a a => Traversal' 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') == Vector.fromList "abcdQ"
--   True
--   </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 s s a a => Traversal' s a

-- | (<a>|&gt;</a>) a value onto the target of a <a>Lens</a> and return the
--   result.
--   
--   When you do not need the result of the operation, (<a>|&gt;~</a>) is
--   more flexible.
(<|>~) :: Snoc b b p p => LensLike ((,) b) s t b b -> p -> s -> (b, t)
infixr 4 <|>~

-- | (<a>|&gt;</a>) a value onto the target of a <a>Lens</a> and return the
--   <i>old</i> result.
--   
--   When you do not need the result of the operation, (<a>|&gt;~</a>) is
--   more flexible.
(<<|>~) :: Snoc b b p p => LensLike' ((,) b) s b -> p -> s -> (b, s)
infixr 4 <<|>~

-- | (<a>|&gt;</a>) a value onto the target of a <a>Lens</a> into your
--   <a>Monad</a>'s state and return the result.
--   
--   When you do not need the result of the operation, (<a>|&gt;=</a>) is
--   more flexible.
(<|>=) :: (MonadState s m, Snoc b b p p) => LensLike ((,) b) s s b b -> p -> m b
infix 4 <|>=

-- | (<a>|&gt;</a>) a value onto the target of a <a>Lens</a> into your
--   <a>Monad</a>'s state and return the <i>old</i> result.
--   
--   When you do not need the result of the operation, (<a>|&gt;=</a>) is
--   more flexible.
(<<|>=) :: (MonadState s m, Snoc b b p p) => LensLike ((,) b) s s b b -> p -> m b
infix 4 <<|>=
class (Rewrapped s t, Rewrapped t s) => Rewrapping s t
class Wrapped s => Rewrapped s t
type family Unwrapped s
pattern Unwrapped :: Rewrapped t t => t -> Unwrapped t

-- | Implement the <a>_Wrapped</a> operation for a type using its
--   <a>Generic</a> instance.
_GWrapped' :: forall s (d :: Meta) (c :: Meta) (s' :: Meta) a. (Generic s, D1 d (C1 c (S1 s' (Rec0 a))) ~ Rep s, Unwrapped s ~ GUnwrapped (Rep s)) => Iso' s (Unwrapped s)
_Unwrapped' :: Wrapped s => Iso' (Unwrapped s) s

-- | Work under a newtype wrapper.
--   
--   <pre>
--   &gt;&gt;&gt; Const "hello" &amp; _Wrapped %~ Prelude.length &amp; getConst
--   5
--   </pre>
--   
--   <pre>
--   <a>_Wrapped</a>   ≡ <a>from</a> <a>_Unwrapped</a>
--   <a>_Unwrapped</a> ≡ <a>from</a> <a>_Wrapped</a>
--   </pre>
_Wrapped :: Rewrapping s t => Iso s t (Unwrapped s) (Unwrapped t)
_Unwrapped :: Rewrapping s t => Iso (Unwrapped t) (Unwrapped s) t s

-- | 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 => (Unwrapped s -> s) -> s -> Unwrapped s

-- | This is a convenient version of <a>_Wrapped</a> with an argument
--   that's ignored.
--   
--   The user supplied function is <i>ignored</i>, merely its type is used.
_Wrapping' :: Wrapped s => (Unwrapped s -> s) -> Iso' s (Unwrapped s)

-- | This is a convenient version of <a>_Wrapped</a> with an argument
--   that's ignored.
--   
--   The user supplied function is <i>ignored</i>, merely its type is used.
_Unwrapping' :: Wrapped s => (Unwrapped s -> s) -> Iso' (Unwrapped s) s

-- | This is a convenient version of <a>_Wrapped</a> with an argument
--   that's ignored.
--   
--   The user supplied function is <i>ignored</i>, merely its types are
--   used.
_Wrapping :: Rewrapping s t => (Unwrapped s -> s) -> Iso s t (Unwrapped s) (Unwrapped t)

-- | This is a convenient version of <a>_Unwrapped</a> with an argument
--   that's ignored.
--   
--   The user supplied function is <i>ignored</i>, merely its types are
--   used.
_Unwrapping :: Rewrapping s t => (Unwrapped s -> s) -> Iso (Unwrapped t) (Unwrapped s) t s

-- | This type family is used by <a>Magnify</a> to describe the common
--   effect type.
type family Magnified (m :: Type -> Type) :: Type -> Type -> Type

-- | This type family is used by <a>Zoom</a> to describe the common effect
--   type.
type family Zoomed (m :: Type -> Type) :: Type -> Type -> Type
class GPlated1 (f :: k -> Type) (g :: k -> Type)
class GPlated a (g :: k -> Type)

-- | Try to apply a traversal to all transitive descendants of a
--   <a>Plated</a> container, but do not recurse through matching
--   descendants.
--   
--   <pre>
--   <a>deep</a> :: <a>Plated</a> s =&gt; <a>Fold</a> s a                 -&gt; <a>Fold</a> s a
--   <a>deep</a> :: <a>Plated</a> s =&gt; <a>IndexedFold</a> s a          -&gt; <a>IndexedFold</a> s a
--   <a>deep</a> :: <a>Plated</a> s =&gt; <a>Traversal</a> s s a b        -&gt; <a>Traversal</a> s s a b
--   <a>deep</a> :: <a>Plated</a> s =&gt; <a>IndexedTraversal</a> s s a b -&gt; <a>IndexedTraversal</a> s s a b
--   </pre>
deep :: (Conjoined p, Applicative f, Plated s) => Traversing p f s s a b -> Over p f s s a b

-- | 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
--   <a>&lt;|&gt;</a> 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
--   <a>&lt;|&gt;</a> 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 b a b -> (b -> Maybe a) -> a -> b

-- | 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>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>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>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>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 b -> ASetter a b a b -> (b -> 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 b a b -> (b -> m (Maybe a)) -> a -> m b

-- | 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 b -> LensLike (WrappedMonad m) a b a b -> (b -> 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 (Endo [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 (Endo [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 (Endo [a]) s a -> Getting (Endo [a]) a a -> s -> [a]

-- | Fold over all transitive descendants of a <a>Plated</a> container,
--   including itself.
cosmos :: Plated a => Fold a a

-- | Given a <a>Fold</a> that knows how to locate immediate children, fold
--   all of the transitive descendants of a node, including itself.
--   
--   <pre>
--   <a>cosmosOf</a> :: <a>Fold</a> a a -&gt; <a>Fold</a> a a
--   </pre>
cosmosOf :: (Applicative f, Contravariant f) => LensLike' f a a -> LensLike' f a a

-- | Given a <a>Fold</a> that knows how to find <a>Plated</a> parts of a
--   container fold them and all of their descendants, recursively.
--   
--   <pre>
--   <a>cosmosOn</a> :: <a>Plated</a> a =&gt; <a>Fold</a> s a -&gt; <a>Fold</a> s a
--   </pre>
cosmosOn :: (Applicative f, Contravariant f, Plated a) => LensLike' f s a -> LensLike' f s a

-- | Given a <a>Fold</a> that knows how to locate immediate children, fold
--   all of the transitive descendants of a node, including itself that lie
--   in a region indicated by another <a>Fold</a>.
--   
--   <pre>
--   <a>cosmosOnOf</a> :: <a>Fold</a> s a -&gt; <a>Fold</a> a a -&gt; <a>Fold</a> s a
--   </pre>
cosmosOnOf :: (Applicative f, Contravariant f) => LensLike' f s a -> LensLike' f a a -> LensLike' f s 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 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 b a b -> (b -> b) -> a -> b

-- | 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 b -> ASetter a b a b -> (b -> b) -> 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 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 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 b a b -> (b -> m b) -> a -> m b

-- | 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 b -> LensLike (WrappedMonad m) a b a b -> (b -> m b) -> 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 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 => Over 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 -> Over 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>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

-- | 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

-- | 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]

-- | Implement <a>plate</a> operation for a type using its <a>Generic</a>
--   instance.
--   
--   Note: the behavior may be different than with <a>uniplate</a> in some
--   special cases. <a>gplate</a> doesn't look through other types in a
--   group of mutually recursive types.
--   
--   For example consider mutually recursive even and odd natural numbers:
--   
--   <pre>
--   &gt;&gt;&gt; data Even = Z | E Odd deriving (Show, Generic, Data); data Odd = O Even deriving (Show, Generic, Data)
--   </pre>
--   
--   Then <a>uniplate</a>, which is based on <a>Data</a>, finds all even
--   numbers less or equal than four:
--   
--   <pre>
--   &gt;&gt;&gt; import Data.Data.Lens (uniplate)
--   
--   &gt;&gt;&gt; universeOf uniplate (E (O (E (O Z))))
--   [E (O (E (O Z))),E (O Z),Z]
--   </pre>
--   
--   but <a>gplate</a> doesn't see through <tt>Odd</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; universeOf gplate (E (O (E (O Z))))
--   [E (O (E (O Z)))]
--   </pre>
--   
--   If using <a>Data</a> is not an option, you can still write the
--   traversal manually. It is sometimes useful to use helper traversals
--   
--   <pre>
--   &gt;&gt;&gt; :{
--   let oddeven :: Traversal' Odd Even
--       oddeven f (O n) = O &lt;$&gt; f n
--       evenplate :: Traversal' Even Even
--       evenplate f Z     = pure Z
--       evenplate f (E n) = E &lt;$&gt; oddeven f n
--   :}
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; universeOf evenplate (E (O (E (O Z))))
--   [E (O (E (O Z))),E (O Z),Z]
--   </pre>
gplate :: (Generic a, GPlated a (Rep a)) => Traversal' a a

-- | Implement <a>plate</a> operation for a type using its <a>Generic1</a>
--   instance.
gplate1 :: forall {k} (f :: k -> Type) (a :: k). (Generic1 f, GPlated1 f (Rep1 f)) => Traversal' (f a) (f a)

-- | <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>.</a> <a>traverse</a>
--   </pre>
class Ixed m => At m

-- | Provides a simple <a>Traversal</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 Ixed m

-- | <i>NB:</i> Setting the value of this <a>Traversal</a> will only set
--   the value in <a>at</a> if it is already present.
--   
--   If you want to be able to insert <i>missing</i> values, you want
--   <a>at</a>.
--   
--   <pre>
--   &gt;&gt;&gt; Seq.fromList [a,b,c,d] &amp; ix 2 %~ f
--   fromList [a,b,f c,d]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Seq.fromList [a,b,c,d] &amp; ix 2 .~ e
--   fromList [a,b,e,d]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Seq.fromList [a,b,c,d] ^? ix 2
--   Just c
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Seq.fromList [] ^? ix 2
--   Nothing
--   </pre>
ix :: Ixed m => Index m -> Traversal' m (IxValue m)
($dmix) :: (Ixed m, At m) => Index m -> Traversal' m (IxValue m)

-- | This provides a common notion of a value at an index that is shared by
--   both <a>Ixed</a> and <a>At</a>.
type family IxValue m

-- | This class provides a simple <a>Lens</a> that lets you view (and
--   modify) information about whether or not a container contains a given
--   <a>Index</a>.
class Contains m
type family Index s

-- | An indexed version of <a>contains</a>.
--   
--   <pre>
--   &gt;&gt;&gt; IntSet.fromList [1,2,3,4] ^@. icontains 3
--   (3,True)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; IntSet.fromList [1,2,3,4] ^@. icontains 5
--   (5,False)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; IntSet.fromList [1,2,3,4] &amp; icontains 3 %@~ \i x -&gt; if odd i then not x else x
--   fromList [1,2,4]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; IntSet.fromList [1,2,3,4] &amp; icontains 3 %@~ \i x -&gt; if even i then not x else x
--   fromList [1,2,3,4]
--   </pre>
icontains :: Contains m => Index m -> IndexedLens' (Index m) m Bool

-- | An indexed version of <a>ix</a>.
--   
--   <pre>
--   &gt;&gt;&gt; Seq.fromList [a,b,c,d] &amp; iix 2 %@~ f'
--   fromList [a,b,f' 2 c,d]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Seq.fromList [a,b,c,d] &amp; iix 2 .@~ h
--   fromList [a,b,h 2,d]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Seq.fromList [a,b,c,d] ^@? iix 2
--   Just (2,c)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Seq.fromList [] ^@? iix 2
--   Nothing
--   </pre>
iix :: Ixed m => Index m -> IndexedTraversal' (Index m) 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 :: At m => Index m -> Traversal' m (IxValue m)

-- | Delete the value associated with a key in a <a>Map</a>-like container
--   
--   <pre>
--   <a>sans</a> k = <a>at</a> k .~ Nothing
--   </pre>
sans :: At m => Index m -> m -> m

-- | An indexed version of <a>at</a>.
--   
--   <pre>
--   &gt;&gt;&gt; Map.fromList [(1,"world")] ^@. iat 1
--   (1,Just "world")
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; iat 1 %@~ (\i x -&gt; if odd i then Just "hello" else Nothing) $ Map.empty
--   fromList [(1,"hello")]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; iat 2 %@~ (\i x -&gt; if odd i then Just "hello" else Nothing) $ Map.empty
--   fromList []
--   </pre>
iat :: At m => Index m -> IndexedLens' (Index m) m (Maybe (IxValue m))

-- | Generate a <tt>Prism</tt> for each constructor of a data type. Isos
--   generated when possible. Reviews are created for constructors with
--   existentially quantified constructors and GADTs.
--   
--   <i>e.g.</i>
--   
--   <pre>
--   data FooBarBaz a
--     = Foo Int
--     | Bar a
--     | Baz Int Char
--   makePrisms ''FooBarBaz
--   </pre>
--   
--   will create
--   
--   <pre>
--   _Foo :: Prism' (FooBarBaz a) Int
--   _Bar :: Prism (FooBarBaz a) (FooBarBaz b) a b
--   _Baz :: Prism' (FooBarBaz a) (Int, Char)
--   </pre>
makePrisms :: Name -> DecsQ

-- | Generate a <tt>Prism</tt> for each constructor of a data type and
--   combine them into a single class. No Isos are created. Reviews are
--   created for constructors with existentially quantified constructors
--   and GADTs.
--   
--   <i>e.g.</i>
--   
--   <pre>
--   data FooBarBaz a
--     = Foo Int
--     | Bar a
--     | Baz Int Char
--   makeClassyPrisms ''FooBarBaz
--   </pre>
--   
--   will create
--   
--   <pre>
--   class AsFooBarBaz s a | s -&gt; a where
--     _FooBarBaz :: Prism' s (FooBarBaz a)
--     _Foo :: Prism' s Int
--     _Bar :: Prism' s a
--     _Baz :: Prism' s (Int,Char)
--   
--     _Foo = _FooBarBaz . _Foo
--     _Bar = _FooBarBaz . _Bar
--     _Baz = _FooBarBaz . _Baz
--   
--   instance AsFooBarBaz (FooBarBaz a) a
--   </pre>
--   
--   Generate an <a>As</a> class of prisms. Names are selected by prefixing
--   the constructor name with an underscore. Constructors with multiple
--   fields will construct Prisms to tuples of those fields.
--   
--   In the event that the name of a data type is also the name of one of
--   its constructors, the name of the <tt>Prism</tt> generated for the
--   data type will be prefixed with an extra <tt>_</tt> (if the data type
--   name is prefix) or <tt>.</tt> (if the name is infix) to disambiguate
--   it from the <tt>Prism</tt> for the corresponding constructor. For
--   example, this code:
--   
--   <pre>
--   data Quux = Quux Int | Fred Bool
--   makeClassyPrisms ''Quux
--   </pre>
--   
--   will create:
--   
--   <pre>
--   class AsQuux s where
--     __Quux :: Prism' s Quux -- Data type prism
--     _Quux :: Prism' s Int   -- Constructor prism
--     _Fred :: Prism' s Bool
--   
--     _Quux = __Quux . _Quux
--     _Fred = __Quux . _Fred
--   
--   instance AsQuux Quux
--   </pre>
makeClassyPrisms :: Name -> DecsQ

-- | The optional rule to create a class and method around a monomorphic
--   data type. If this naming convention is provided, it generates a
--   "classy" lens.
type ClassyNamer = Name -> Maybe (Name, Name)

-- | Name to give to generated field optics.
data DefName

-- | Simple top-level definition name
TopName :: Name -> DefName

-- | makeFields-style class name and method name
MethodName :: Name -> Name -> DefName

-- | The rule to create function names of lenses for data fields.
--   
--   Although it's sometimes useful, you won't need the first two arguments
--   most of the time.
type FieldNamer = Name -> [Name] -> Name -> [DefName]

-- | Rules to construct lenses for data fields.
data LensRules

-- | Generate "simple" optics even when type-changing optics are possible.
--   (e.g. <a>Lens'</a> instead of <a>Lens</a>)
simpleLenses :: 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

-- | Generate "updateable" optics when <a>True</a>. When <a>False</a>,
--   <a>Fold</a>s will be generated instead of <a>Traversal</a>s and
--   <a>Getter</a>s will be generated instead of <a>Lens</a>es. This mode
--   is intended to be used for types with invariants which must be
--   maintained by "smart" constructors.
generateUpdateableOptics :: Lens' LensRules Bool

-- | Generate optics using lazy pattern matches. This can allow fields of
--   an undefined value to be initialized with lenses:
--   
--   <pre>
--   data Foo = Foo {_x :: Int, _y :: Bool}
--     deriving Show
--   
--   <a>makeLensesWith</a> (<a>lensRules</a> &amp; <a>generateLazyPatterns</a> .~ True) ''Foo
--   </pre>
--   
--   <pre>
--   &gt; undefined &amp; x .~ 8 &amp; y .~ True
--   Foo {_x = 8, _y = True}
--   </pre>
--   
--   The downside of this flag is that it can lead to space-leaks and
--   code-size/compile-time increases when generated for large records. By
--   default this flag is turned off, and strict optics are generated.
--   
--   When using lazy optics the strict optic can be recovered by composing
--   with <a>$!</a>:
--   
--   <pre>
--   strictOptic = ($!) . lazyOptic
--   </pre>
generateLazyPatterns :: Lens' LensRules Bool
generateRecordSyntax :: Lens' LensRules Bool

-- | Create the class if the constructor is <a>Simple</a> and the
--   <a>lensClass</a> rule matches.
createClass :: Lens' LensRules Bool

-- | <a>Lens'</a> to access the convention for naming fields in our
--   <a>LensRules</a>.
lensField :: Lens' LensRules FieldNamer

-- | <a>Lens'</a> to access the option for naming "classy" lenses.
lensClass :: Lens' LensRules ClassyNamer

-- | Rules for making fairly simple partial lenses, ignoring the special
--   cases for isomorphisms and traversals, and not making any classes. It
--   uses <a>underscoreNoPrefixNamer</a>.
lensRules :: LensRules

-- | A <a>FieldNamer</a> that strips the _ off of the field name,
--   lowercases the name, and skips the field if it doesn't start with an
--   '_'.
underscoreNoPrefixNamer :: FieldNamer

-- | Construct a <a>LensRules</a> value for generating top-level
--   definitions using the given map from field names to definition names.
lensRulesFor :: [(String, String)] -> LensRules

-- | Create a <a>FieldNamer</a> from explicit pairings of <tt>(fieldName,
--   lensName)</tt>.
lookingupNamer :: [(String, String)] -> FieldNamer

-- | Create a <a>FieldNamer</a> from a mapping function. If the function
--   returns <tt>[]</tt>, it creates no lens for the field.
mappingNamer :: (String -> [String]) -> FieldNamer

-- | Rules for making lenses and traversals that precompose another
--   <a>Lens</a>.
classyRules :: LensRules

-- | A <a>LensRules</a> used by <a>makeClassy_</a>.
classyRules_ :: LensRules

-- | Build lenses (and traversals) with a sensible default configuration.
--   
--   <i>e.g.</i>
--   
--   <pre>
--   data FooBar
--     = Foo { _x, _y :: <a>Int</a> }
--     | Bar { _x :: <a>Int</a> }
--   <a>makeLenses</a> ''FooBar
--   </pre>
--   
--   will create
--   
--   <pre>
--   x :: <a>Lens'</a> FooBar <a>Int</a>
--   x f (Foo a b) = (\a' -&gt; Foo a' b) &lt;$&gt; f a
--   x f (Bar a)   = Bar &lt;$&gt; f a
--   y :: <a>Traversal'</a> FooBar <a>Int</a>
--   y f (Foo a b) = (\b' -&gt; Foo a  b') &lt;$&gt; f b
--   y _ c@(Bar _) = pure c
--   </pre>
--   
--   <pre>
--   <a>makeLenses</a> = <a>makeLensesWith</a> <a>lensRules</a>
--   </pre>
makeLenses :: Name -> DecsQ

-- | 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>Lens'</a> t Foo
--     fooX :: <a>Lens'</a> t <a>Int</a>
--     fooX = foo . go where go f (Foo x y) = (\x' -&gt; Foo x' y) &lt;$&gt; f x
--     fooY :: <a>Lens'</a> t <a>Int</a>
--     fooY = foo . go where go f (Foo x y) = (\y' -&gt; Foo x y') &lt;$&gt; f y
--   instance HasFoo Foo where
--     foo = id
--   </pre>
--   
--   <pre>
--   <a>makeClassy</a> = <a>makeLensesWith</a> <a>classyRules</a>
--   </pre>
makeClassy :: Name -> DecsQ

-- | Make lenses and traversals for a type, and create a class when the
--   type has no arguments. Works the same as <a>makeClassy</a> except that
--   (a) it expects that record field names do not begin with an
--   underscore, (b) all record fields are made into lenses, and (c) the
--   resulting lens is prefixed with an underscore.
makeClassy_ :: Name -> DecsQ

-- | 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 -> DecsQ

-- | 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 -> DecsQ

-- | Build lenses with a custom configuration.
makeLensesWith :: LensRules -> Name -> DecsQ

-- | Make lenses for all records in the given declaration quote. All record
--   syntax in the input will be stripped off.
--   
--   <i>e.g.</i>
--   
--   <pre>
--   declareLenses [d|
--     data Foo = Foo { fooX, fooY :: <a>Int</a> }
--       deriving <a>Show</a>
--     |]
--   </pre>
--   
--   will create
--   
--   <pre>
--   data Foo = Foo <a>Int</a> <a>Int</a> deriving <a>Show</a>
--   fooX, fooY :: <a>Lens'</a> Foo Int
--   </pre>
declareLenses :: DecsQ -> DecsQ

-- | Similar to <a>makeLensesFor</a>, but takes a declaration quote.
declareLensesFor :: [(String, String)] -> DecsQ -> DecsQ

-- | For each record in the declaration quote, make lenses and traversals
--   for it, and create a class when the type has no arguments. All record
--   syntax in the input will be stripped off.
--   
--   <i>e.g.</i>
--   
--   <pre>
--   declareClassy [d|
--     data Foo = Foo { fooX, fooY :: <a>Int</a> }
--       deriving <a>Show</a>
--     |]
--   </pre>
--   
--   will create
--   
--   <pre>
--   data Foo = Foo <a>Int</a> <a>Int</a> deriving <a>Show</a>
--   class HasFoo t where
--     foo :: <a>Lens'</a> t Foo
--   instance HasFoo Foo where foo = <a>id</a>
--   fooX, fooY :: HasFoo t =&gt; <a>Lens'</a> t <a>Int</a>
--   </pre>
declareClassy :: DecsQ -> DecsQ

-- | Similar to <a>makeClassyFor</a>, but takes a declaration quote.
declareClassyFor :: [(String, (String, String))] -> [(String, String)] -> DecsQ -> DecsQ

-- | Generate a <a>Prism</a> for each constructor of each data type.
--   
--   <i>e.g.</i>
--   
--   <pre>
--   declarePrisms [d|
--     data Exp = Lit Int | Var String | Lambda{ bound::String, body::Exp }
--     |]
--   </pre>
--   
--   will create
--   
--   <pre>
--   data Exp = Lit Int | Var String | Lambda { bound::String, body::Exp }
--   _Lit :: <tt>Prism'</tt> Exp Int
--   _Var :: <tt>Prism'</tt> Exp String
--   _Lambda :: <tt>Prism'</tt> Exp (String, Exp)
--   </pre>
declarePrisms :: DecsQ -> DecsQ

-- | Build <a>Wrapped</a> instance for each newtype.
declareWrapped :: DecsQ -> DecsQ

-- | <pre>
--   declareFields = <a>declareLensesWith</a> <a>defaultFieldRules</a>
--   </pre>
declareFields :: DecsQ -> DecsQ

-- | Declare lenses for each records in the given declarations, using the
--   specified <a>LensRules</a>. Any record syntax in the input will be
--   stripped off.
declareLensesWith :: LensRules -> DecsQ -> DecsQ

-- | Build <tt>Wrapped</tt> instance for a given newtype
makeWrapped :: Name -> DecsQ

-- | Field rules for fields in the form <tt> _prefix_fieldname </tt>
underscoreFields :: LensRules

-- | A <a>FieldNamer</a> for <a>underscoreFields</a>.
underscoreNamer :: FieldNamer

-- | Field rules for fields in the form <tt> prefixFieldname or
--   _prefixFieldname </tt> If you want all fields to be lensed, then there
--   is no reason to use an <tt>_</tt> before the prefix. If any of the
--   record fields leads with an <tt>_</tt> then it is assume a field
--   without an <tt>_</tt> should not have a lens created.
--   
--   <b>Note</b>: The <tt>prefix</tt> must be the same as the typename
--   (with the first letter lowercased). This is a change from lens
--   versions before lens 4.5. If you want the old behaviour, use
--   <a>makeLensesWith</a> <a>abbreviatedFields</a>
camelCaseFields :: LensRules

-- | A <a>FieldNamer</a> for <a>camelCaseFields</a>.
camelCaseNamer :: FieldNamer

-- | Field rules for fields in the form <tt> _fieldname </tt> (the leading
--   underscore is mandatory).
--   
--   <b>Note</b>: The primary difference to <a>camelCaseFields</a> is that
--   for <tt>classUnderscoreNoPrefixFields</tt> the field names are not
--   expected to be prefixed with the type name. This might be the desired
--   behaviour when the <tt>DuplicateRecordFields</tt> extension is
--   enabled.
classUnderscoreNoPrefixFields :: LensRules

-- | A <a>FieldNamer</a> for <a>classUnderscoreNoPrefixFields</a>.
classUnderscoreNoPrefixNamer :: FieldNamer

-- | Field rules for fields whose names are to be used verbatim, with no
--   prefixes, no underscores, no transformations of any kind.
classIdFields :: LensRules

-- | A <a>FieldNamer</a> for <a>classIdFields</a>.
classIdNamer :: FieldNamer

-- | Field rules fields in the form <tt> prefixFieldname or
--   _prefixFieldname </tt> If you want all fields to be lensed, then there
--   is no reason to use an <tt>_</tt> before the prefix. If any of the
--   record fields leads with an <tt>_</tt> then it is assume a field
--   without an <tt>_</tt> should not have a lens created.
--   
--   Note that <tt>prefix</tt> may be any string of characters that are not
--   uppercase letters. (In particular, it may be arbitrary string of
--   lowercase letters and numbers) This is the behavior that
--   <a>defaultFieldRules</a> had in lens 4.4 and earlier.
abbreviatedFields :: LensRules

-- | A <a>FieldNamer</a> for <a>abbreviatedFields</a>.
abbreviatedNamer :: FieldNamer

-- | Generate overloaded field accessors.
--   
--   <i>e.g</i>
--   
--   <pre>
--   data Foo a = Foo { _fooX :: <a>Int</a>, _fooY :: a }
--   newtype Bar = Bar { _barX :: <a>Char</a> }
--   makeFields ''Foo
--   makeFields ''Bar
--   </pre>
--   
--   will create
--   
--   <pre>
--   _fooXLens :: Lens' (Foo a) Int
--   _fooYLens :: Lens (Foo a) (Foo b) a b
--   class HasX s a | s -&gt; a where
--     x :: Lens' s a
--   instance HasX (Foo a) Int where
--     x = _fooXLens
--   class HasY s a | s -&gt; a where
--     y :: Lens' s a
--   instance HasY (Foo a) a where
--     y = _fooYLens
--   _barXLens :: Iso' Bar Char
--   instance HasX Bar Char where
--     x = _barXLens
--   </pre>
--   
--   For details, see <a>camelCaseFields</a>.
--   
--   <pre>
--   makeFields = <a>makeLensesWith</a> <a>defaultFieldRules</a>
--   </pre>
makeFields :: Name -> DecsQ

-- | Generate overloaded field accessors based on field names which are
--   only prefixed with an underscore (e.g. <tt>_name</tt>), not
--   additionally with the type name (e.g. <tt>_fooName</tt>).
--   
--   This might be the desired behaviour in case the
--   <tt>DuplicateRecordFields</tt> language extension is used in order to
--   get rid of the necessity to prefix each field name with the type name.
--   
--   As an example:
--   
--   <pre>
--   data Foo a  = Foo { _x :: <a>Int</a>, _y :: a }
--   newtype Bar = Bar { _x :: <a>Char</a> }
--   makeFieldsNoPrefix ''Foo
--   makeFieldsNoPrefix ''Bar
--   </pre>
--   
--   will create classes
--   
--   <pre>
--   class HasX s a | s -&gt; a where
--     x :: Lens' s a
--   class HasY s a | s -&gt; a where
--     y :: Lens' s a
--   </pre>
--   
--   together with instances
--   
--   <pre>
--   instance HasX (Foo a) Int
--   instance HasY (Foo a) a where
--   instance HasX Bar Char where
--   </pre>
--   
--   For details, see <a>classUnderscoreNoPrefixFields</a>.
--   
--   <pre>
--   makeFieldsNoPrefix = <a>makeLensesWith</a> <a>classUnderscoreNoPrefixFields</a>
--   </pre>
makeFieldsNoPrefix :: Name -> DecsQ

-- | Generate overloaded field accessors, using exactly the same names as
--   the underlying fields. Intended for use with the
--   <tt>NoFieldSelectors</tt> and <tt>DuplicateRecordFields</tt> language
--   extensions.
--   
--   As an example:
--   
--   <pre>
--   data Foo a  = Foo { x :: <a>Int</a>, y :: a }
--   newtype Bar = Bar { x :: <a>Char</a> }
--   makeFieldsId ''Foo
--   makeFieldsId ''Bar
--   </pre>
--   
--   will create classes
--   
--   <pre>
--   class HasX s a | s -&gt; a where
--     x :: Lens' s a
--   class HasY s a | s -&gt; a where
--     y :: Lens' s a
--   </pre>
--   
--   together with instances
--   
--   <pre>
--   instance HasX (Foo a) Int
--   instance HasY (Foo a) a where
--   instance HasX Bar Char where
--   </pre>
--   
--   <pre>
--   makeFieldsId = <a>makeLensesWith</a> <a>classIdFields</a>
--   </pre>
makeFieldsId :: Name -> DecsQ
defaultFieldRules :: LensRules

-- | A functor with application, providing operations to
--   
--   <ul>
--   <li>embed pure expressions (<a>pure</a>), and</li>
--   <li>sequence computations and combine their results (<a>&lt;*&gt;</a>
--   and <a>liftA2</a>).</li>
--   </ul>
--   
--   A minimal complete definition must include implementations of
--   <a>pure</a> and of either <a>&lt;*&gt;</a> or <a>liftA2</a>. If it
--   defines both, then they must behave the same as their default
--   definitions:
--   
--   <pre>
--   (<a>&lt;*&gt;</a>) = <a>liftA2</a> <a>id</a>
--   </pre>
--   
--   <pre>
--   <a>liftA2</a> f x y = f <a>&lt;$&gt;</a> x <a>&lt;*&gt;</a> y
--   </pre>
--   
--   Further, any definition must satisfy the following:
--   
--   <ul>
--   <li><i>Identity</i> <pre><a>pure</a> <a>id</a> <a>&lt;*&gt;</a> v =
--   v</pre></li>
--   <li><i>Composition</i> <pre><a>pure</a> (.) <a>&lt;*&gt;</a> u
--   <a>&lt;*&gt;</a> v <a>&lt;*&gt;</a> w = u <a>&lt;*&gt;</a> (v
--   <a>&lt;*&gt;</a> w)</pre></li>
--   <li><i>Homomorphism</i> <pre><a>pure</a> f <a>&lt;*&gt;</a>
--   <a>pure</a> x = <a>pure</a> (f x)</pre></li>
--   <li><i>Interchange</i> <pre>u <a>&lt;*&gt;</a> <a>pure</a> y =
--   <a>pure</a> (<a>$</a> y) <a>&lt;*&gt;</a> u</pre></li>
--   </ul>
--   
--   The other methods have the following default definitions, which may be
--   overridden with equivalent specialized implementations:
--   
--   <ul>
--   <li><pre>u <a>*&gt;</a> v = (<a>id</a> <a>&lt;$</a> u)
--   <a>&lt;*&gt;</a> v</pre></li>
--   <li><pre>u <a>&lt;*</a> v = <a>liftA2</a> <a>const</a> u v</pre></li>
--   </ul>
--   
--   As a consequence of these laws, the <a>Functor</a> instance for
--   <tt>f</tt> will satisfy
--   
--   <ul>
--   <li><pre><a>fmap</a> f x = <a>pure</a> f <a>&lt;*&gt;</a> x</pre></li>
--   </ul>
--   
--   It may be useful to note that supposing
--   
--   <pre>
--   forall x y. p (q x y) = f x . g y
--   </pre>
--   
--   it follows from the above that
--   
--   <pre>
--   <a>liftA2</a> p (<a>liftA2</a> q u v) = <a>liftA2</a> f u . <a>liftA2</a> g v
--   </pre>
--   
--   If <tt>f</tt> is also a <a>Monad</a>, it should satisfy
--   
--   <ul>
--   <li><pre><a>pure</a> = <a>return</a></pre></li>
--   <li><pre>m1 <a>&lt;*&gt;</a> m2 = m1 <a>&gt;&gt;=</a> (\x1 -&gt; m2
--   <a>&gt;&gt;=</a> (\x2 -&gt; <a>return</a> (x1 x2)))</pre></li>
--   <li><pre>(<a>*&gt;</a>) = (<a>&gt;&gt;</a>)</pre></li>
--   </ul>
--   
--   (which implies that <a>pure</a> and <a>&lt;*&gt;</a> satisfy the
--   applicative functor laws).
class Functor f => Applicative (f :: Type -> Type)

-- | Lift a value into the Structure.
--   
--   <h4><b>Examples</b></h4>
--   
--   <pre>
--   &gt;&gt;&gt; pure 1 :: Maybe Int
--   Just 1
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; pure 'z' :: [Char]
--   "z"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; pure (pure ":D") :: Maybe [String]
--   Just [":D"]
--   </pre>
pure :: Applicative f => a -> f a

-- | Sequential application.
--   
--   A few functors support an implementation of <a>&lt;*&gt;</a> that is
--   more efficient than the default one.
--   
--   <h4><b>Example</b></h4>
--   
--   Used in combination with <tt><a>(&lt;$&gt;)</a></tt>,
--   <tt><a>(&lt;*&gt;)</a></tt> can be used to build a record.
--   
--   <pre>
--   &gt;&gt;&gt; data MyState = MyState {arg1 :: Foo, arg2 :: Bar, arg3 :: Baz}
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; produceFoo :: Applicative f =&gt; f Foo
--   
--   &gt;&gt;&gt; produceBar :: Applicative f =&gt; f Bar
--   
--   &gt;&gt;&gt; produceBaz :: Applicative f =&gt; f Baz
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; mkState :: Applicative f =&gt; f MyState
--   
--   &gt;&gt;&gt; mkState = MyState &lt;$&gt; produceFoo &lt;*&gt; produceBar &lt;*&gt; produceBaz
--   </pre>
(<*>) :: Applicative f => f (a -> b) -> f a -> f b

-- | Lift a binary function to actions.
--   
--   Some functors support an implementation of <a>liftA2</a> that is more
--   efficient than the default one. In particular, if <a>fmap</a> is an
--   expensive operation, it is likely better to use <a>liftA2</a> than to
--   <a>fmap</a> over the structure and then use <a>&lt;*&gt;</a>.
--   
--   This became a typeclass method in 4.10.0.0. Prior to that, it was a
--   function defined in terms of <a>&lt;*&gt;</a> and <a>fmap</a>.
--   
--   <h4><b>Example</b></h4>
--   
--   <pre>
--   &gt;&gt;&gt; liftA2 (,) (Just 3) (Just 5)
--   Just (3,5)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; liftA2 (+) [1, 2, 3] [4, 5, 6]
--   [5,6,7,6,7,8,7,8,9]
--   </pre>
liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c

-- | Sequence actions, discarding the value of the first argument.
--   
--   <h4><b>Examples</b></h4>
--   
--   If used in conjunction with the Applicative instance for <a>Maybe</a>,
--   you can chain Maybe computations, with a possible "early return" in
--   case of <a>Nothing</a>.
--   
--   <pre>
--   &gt;&gt;&gt; Just 2 *&gt; Just 3
--   Just 3
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Nothing *&gt; Just 3
--   Nothing
--   </pre>
--   
--   Of course a more interesting use case would be to have effectful
--   computations instead of just returning pure values.
--   
--   <pre>
--   &gt;&gt;&gt; import Data.Char
--   
--   &gt;&gt;&gt; import GHC.Internal.Text.ParserCombinators.ReadP
--   
--   &gt;&gt;&gt; let p = string "my name is " *&gt; munch1 isAlpha &lt;* eof
--   
--   &gt;&gt;&gt; readP_to_S p "my name is Simon"
--   [("Simon","")]
--   </pre>
(*>) :: Applicative f => f a -> f b -> f b

-- | Sequence actions, discarding the value of the second argument.
(<*) :: Applicative f => f a -> f b -> f a
infixl 4 <*>
infixl 4 *>
infixl 4 <*

-- | Sequence actions, discarding the value of the first argument.
--   
--   <h4><b>Examples</b></h4>
--   
--   If used in conjunction with the Applicative instance for <a>Maybe</a>,
--   you can chain Maybe computations, with a possible "early return" in
--   case of <a>Nothing</a>.
--   
--   <pre>
--   &gt;&gt;&gt; Just 2 *&gt; Just 3
--   Just 3
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Nothing *&gt; Just 3
--   Nothing
--   </pre>
--   
--   Of course a more interesting use case would be to have effectful
--   computations instead of just returning pure values.
--   
--   <pre>
--   &gt;&gt;&gt; import Data.Char
--   
--   &gt;&gt;&gt; import GHC.Internal.Text.ParserCombinators.ReadP
--   
--   &gt;&gt;&gt; let p = string "my name is " *&gt; munch1 isAlpha &lt;* eof
--   
--   &gt;&gt;&gt; readP_to_S p "my name is Simon"
--   [("Simon","")]
--   </pre>
(*>) :: Applicative f => f a -> f b -> f b
infixl 4 *>

-- | Sequence actions, discarding the value of the second argument.
(<*) :: Applicative f => f a -> f b -> f a
infixl 4 <*

-- | An infix synonym for <a>fmap</a>.
--   
--   The name of this operator is an allusion to <a>$</a>. Note the
--   similarities between their types:
--   
--   <pre>
--    ($)  ::              (a -&gt; b) -&gt;   a -&gt;   b
--   (&lt;$&gt;) :: Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
--   </pre>
--   
--   Whereas <a>$</a> is function application, <a>&lt;$&gt;</a> is function
--   application lifted over a <a>Functor</a>.
--   
--   <h4><b>Examples</b></h4>
--   
--   Convert from a <tt><a>Maybe</a> <a>Int</a></tt> to a <tt><a>Maybe</a>
--   <a>String</a></tt> using <a>show</a>:
--   
--   <pre>
--   &gt;&gt;&gt; show &lt;$&gt; Nothing
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; show &lt;$&gt; Just 3
--   Just "3"
--   </pre>
--   
--   Convert from an <tt><a>Either</a> <a>Int</a> <a>Int</a></tt> to an
--   <tt><a>Either</a> <a>Int</a></tt> <a>String</a> using <a>show</a>:
--   
--   <pre>
--   &gt;&gt;&gt; show &lt;$&gt; Left 17
--   Left 17
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; show &lt;$&gt; Right 17
--   Right "17"
--   </pre>
--   
--   Double each element of a list:
--   
--   <pre>
--   &gt;&gt;&gt; (*2) &lt;$&gt; [1,2,3]
--   [2,4,6]
--   </pre>
--   
--   Apply <a>even</a> to the second element of a pair:
--   
--   <pre>
--   &gt;&gt;&gt; even &lt;$&gt; (2,2)
--   (2,True)
--   </pre>
(<$>) :: Functor f => (a -> b) -> f a -> f b
infixl 4 <$>

-- | Replace all locations in the input with the same value. The default
--   definition is <tt><a>fmap</a> . <a>const</a></tt>, but this may be
--   overridden with a more efficient version.
--   
--   <h4><b>Examples</b></h4>
--   
--   Perform a computation with <a>Maybe</a> and replace the result with a
--   constant value if it is <a>Just</a>:
--   
--   <pre>
--   &gt;&gt;&gt; 'a' &lt;$ Just 2
--   Just 'a'
--   
--   &gt;&gt;&gt; 'a' &lt;$ Nothing
--   Nothing
--   </pre>
(<$) :: Functor f => a -> f b -> f a
infixl 4 <$

-- | Lift a function to actions. Equivalent to Functor's <a>fmap</a> but
--   implemented using only <a>Applicative</a>'s methods: <tt><a>liftA</a>
--   f a = <a>pure</a> f <a>&lt;*&gt;</a> a</tt>
--   
--   As such this function may be used to implement a <a>Functor</a>
--   instance from an <a>Applicative</a> one.
--   
--   <h4><b>Examples</b></h4>
--   
--   Using the Applicative instance for Lists:
--   
--   <pre>
--   &gt;&gt;&gt; liftA (+1) [1, 2]
--   [2,3]
--   </pre>
--   
--   Or the Applicative instance for <a>Maybe</a>
--   
--   <pre>
--   &gt;&gt;&gt; liftA (+1) (Just 3)
--   Just 4
--   </pre>
liftA :: Applicative f => (a -> b) -> f a -> f b

-- | Lift a binary function to actions.
--   
--   Some functors support an implementation of <a>liftA2</a> that is more
--   efficient than the default one. In particular, if <a>fmap</a> is an
--   expensive operation, it is likely better to use <a>liftA2</a> than to
--   <a>fmap</a> over the structure and then use <a>&lt;*&gt;</a>.
--   
--   This became a typeclass method in 4.10.0.0. Prior to that, it was a
--   function defined in terms of <a>&lt;*&gt;</a> and <a>fmap</a>.
--   
--   <h4><b>Example</b></h4>
--   
--   <pre>
--   &gt;&gt;&gt; liftA2 (,) (Just 3) (Just 5)
--   Just (3,5)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; liftA2 (+) [1, 2, 3] [4, 5, 6]
--   [5,6,7,6,7,8,7,8,9]
--   </pre>
liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c

-- | Lift a ternary function to actions.
liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
