-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Optics as an abstract interface: core definitions -- -- This package makes it possible to define and use Lenses, Traversals, -- Prisms and other optics, using an abstract interface. -- -- This variant provides core definitions with a minimal dependency -- footprint. See the optics package (and its -- dependencies) for documentation and the "batteries-included" variant. @package optics-core @version 0.4 -- | Classes for co- and contravariant bifunctors. -- -- This module is intended for internal use only, and may change without -- warning in subsequent releases. module Optics.Internal.Bi -- | Class for (covariant) bifunctors. class Bifunctor p bimap :: Bifunctor p => (a -> b) -> (c -> d) -> p i a c -> p i b d first :: Bifunctor p => (a -> b) -> p i a c -> p i b c second :: Bifunctor p => (c -> d) -> p i a c -> p i a d -- | Class for contravariant bifunctors. class Bicontravariant p contrabimap :: Bicontravariant p => (b -> a) -> (d -> c) -> p i a c -> p i b d contrafirst :: Bicontravariant p => (b -> a) -> p i a c -> p i b c contrasecond :: Bicontravariant p => (c -> b) -> p i a b -> p i a c -- | If p is a Profunctor and a Bifunctor then its -- left parameter must be phantom. lphantom :: (Profunctor p, Bifunctor p) => p i a c -> p i b c -- | If p is a Profunctor and Bicontravariant then -- its right parameter must be phantom. rphantom :: (Profunctor p, Bicontravariant p) => p i c a -> p i c b instance Optics.Internal.Bi.Bicontravariant (Data.Profunctor.Indexed.Forget r) instance Optics.Internal.Bi.Bicontravariant (Data.Profunctor.Indexed.ForgetM r) instance Optics.Internal.Bi.Bicontravariant (Data.Profunctor.Indexed.IxForget r) instance Optics.Internal.Bi.Bicontravariant (Data.Profunctor.Indexed.IxForgetM r) instance Optics.Internal.Bi.Bifunctor Data.Profunctor.Indexed.Tagged -- | Internal implementation details of indexed optics. -- -- This module is intended for internal use only, and may change without -- warning in subsequent releases. module Optics.Internal.Indexed.Classes -- | This module is intended for internal use only, and may change without -- warning in subsequent releases. module Optics.Internal.Magic -- | How about a magic trick? I'm gonna make the coverage condition -- disappear. class Dysfunctional field k s t a b | field s -> k t a b, field t -> k s a b class TypeInferenceLoop msg1 msg2 msg3 field k s t a b | field s -> k t a b, field t -> k s a b instance forall k1 k2 k3 k4 k5 k6 (field :: k1) (k7 :: k2) (s :: k3) (t :: k4) (a :: k5) (b :: k6). Optics.Internal.Magic.TypeInferenceLoop "Type inference for the local binding failed. Write the type" "signature yourself or disable monomorphism restriction with" "NoMonomorphismRestriction LANGUAGE pragma so GHC infers it." field k7 s t a b => Optics.Internal.Magic.Dysfunctional field k7 s t a b instance forall k1 k2 k3 k4 k5 k6 k7 k8 k9 (msg1 :: k1) (msg2 :: k2) (msg3 :: k3) (field :: k4) (k10 :: k5) (s :: k6) (t :: k7) (a :: k8) (b :: k9). Optics.Internal.Magic.TypeInferenceLoop msg1 msg2 msg3 field k10 s t a b => Optics.Internal.Magic.TypeInferenceLoop msg1 msg2 msg3 field k10 s t a b -- | This module is intended for internal use only, and may change without -- warning in subsequent releases. module Optics.Internal.Optic.TypeLevel -- | A list of index types, used for indexed optics. type IxList = [Type] -- | An alias for an empty index-list type NoIx = ('[] :: IxList) -- | Singleton index list type WithIx i = ('[i] :: IxList) type family ShowSymbolWithOrigin symbol origin :: ErrorMessage type family ShowSymbolsWithOrigin (fs :: [(Symbol, Symbol)]) :: ErrorMessage type family ShowOperators (ops :: [Symbol]) :: ErrorMessage type family AppendEliminations a b type family ShowEliminations forms :: ErrorMessage -- | Reverse a type-level list. type family Reverse (xs :: [k]) (acc :: [k]) :: [k] -- | Curry a type-level list. -- -- In pseudo (dependent-)Haskell: -- --
--   Curry xs y = foldr (->) y xs
--   
type family Curry (xs :: IxList) (y :: Type) :: Type -- | Append two type-level lists together. type family Append (xs :: [k]) (ys :: [k]) :: [k] -- | Class that is inhabited by all type-level lists xs, providing -- the ability to compose a function under Curry xs. class CurryCompose xs -- | Compose a function under Curry xs. This generalises -- (.) (aka fmap for (->)) to work for -- curried functions with one argument for each type in the list. composeN :: CurryCompose xs => (i -> j) -> Curry xs i -> Curry xs j -- | Tagged version of 'Data.Type.Equality.(:~:)' for carrying evidence -- that two index lists in a curried form are equal. data IxEq i is js [IxEq] :: IxEq i is is -- | In pseudo (dependent-)Haskell, provide a witness -- --
--   foldr f (foldr f init xs) ys = foldr f init (ys ++ xs)
--      where f = (->)
--   
class AppendIndices xs ys ks | xs ys -> ks appendIndices :: AppendIndices xs ys ks => IxEq i (Curry xs (Curry ys i)) (Curry ks i) -- | If lhs is Right, return it. Otherwise check rhs. type family FirstRight (m1 :: Either e a) (m2 :: Either e a) :: Either e a type family FromRight (def :: b) (e :: Either a b) :: b type family IsLeft (e :: Either a b) :: Bool -- | Show a custom type error if p is true. type family When (p :: Bool) (err :: Constraint) :: Constraint -- | Show a custom type error if p is false (or stuck). type family Unless (p :: Bool) (err :: Constraint) :: Constraint -- | Use with Unless to detect stuck (undefined) type families. type family Defined (f :: k) :: Bool -- | Show a type surrounded by quote marks. type family QuoteType (x :: t) :: ErrorMessage -- | Show a symbol surrounded by quote marks. type family QuoteSymbol (x :: Symbol) :: ErrorMessage type family ToOrdinal (n :: Nat) :: ErrorMessage -- | Derive the shape of a from the shape of b. class HasShapeOf (a :: k) (b :: k) instance forall k1 k2 (fa :: k1) (f :: k2 -> k1) (a :: k2) (g :: k2 -> k1) (b :: k2). (fa GHC.Types.~ f a, Optics.Internal.Optic.TypeLevel.HasShapeOf f g) => Optics.Internal.Optic.TypeLevel.HasShapeOf fa (g b) instance forall k (a :: k) (b :: k). (a GHC.Types.~ b) => Optics.Internal.Optic.TypeLevel.HasShapeOf a b instance Optics.Internal.Optic.TypeLevel.AppendIndices xs '[] xs instance Optics.Internal.Optic.TypeLevel.AppendIndices '[] ys ys instance Optics.Internal.Optic.TypeLevel.AppendIndices xs ys ks => Optics.Internal.Optic.TypeLevel.AppendIndices (x : xs) ys (x : ks) instance Optics.Internal.Optic.TypeLevel.CurryCompose '[] instance Optics.Internal.Optic.TypeLevel.CurryCompose xs => Optics.Internal.Optic.TypeLevel.CurryCompose (x : xs) -- | This module is intended for internal use only, and may change without -- warning in subsequent releases. module Optics.Internal.Generic.TypeLevel -- | A map that allows reaching a specific field in a generic -- representation of a data type. Computed up front by generic optics for -- early error reporting and efficient data traversal. data PathTree e PathTree :: PathTree e -> PathTree e -> PathTree e PathLeaf :: Either e [Path] -> PathTree e data Path PathLeft :: Path PathRight :: Path -- | Compute paths to a field with a specific name. type family GetFieldPaths s (name :: Symbol) g :: PathTree Symbol -- | Compute path to a constructor in a sum or a field in a product with a -- specific name. type family GetNamePath (name :: Symbol) g (acc :: [Path]) :: Either Symbol [Path] -- | Compute paths to a field at a specific position. type family GetPositionPaths s (pos :: Nat) g :: PathTree (Nat, Nat) -- | Compute path to a constructor in a sum or a field in a product at a -- specific position. type family GetPositionPath (pos :: Nat) g (k :: Nat) (acc :: [Path]) :: Either (Nat, Nat) [Path] -- | Generate bogus equality constraints that attempt to unify generic -- representations with this type in case there is an error such as -- missing field, constructor etc. so these huge types don't leak into -- error messages. type family HideReps (g :: Type -> Type) (h :: Type -> Type) :: Constraint -- | Check if any leaf in the tree has a '[Path]'. type family AnyHasPath (path :: PathTree e) :: Bool type family NoGenericError t -- | This module is intended for internal use only, and may change without -- warning in subsequent releases. module Optics.Internal.Optic.Types -- | Kind for types used as optic tags, such as A_Lens. type OpticKind = Type -- | Tag for an iso. data An_Iso :: OpticKind -- | Tag for a lens. data A_Lens :: OpticKind -- | Tag for a prism. data A_Prism :: OpticKind -- | Tag for an affine traversal. data An_AffineTraversal :: OpticKind -- | Tag for a traversal. data A_Traversal :: OpticKind -- | Tag for a setter. data A_Setter :: OpticKind -- | Tag for a reversed prism. data A_ReversedPrism :: OpticKind -- | Tag for a getter. data A_Getter :: OpticKind -- | Tag for an affine fold. data An_AffineFold :: OpticKind -- | Tag for a fold. data A_Fold :: OpticKind -- | Tag for a reversed lens. data A_ReversedLens :: OpticKind -- | Tag for a review. data A_Review :: OpticKind -- | Mapping tag types k to constraints on p. -- -- Using this type family we define the constraints that the various -- flavours of optics have to fulfill. type family Constraints (k :: OpticKind) (p :: Type -> Type -> Type -> Type) :: Constraint -- | Instances to implement the subtyping hierarchy between optics. -- -- This module is intended for internal use only, and may change without -- warning in subsequent releases. module Optics.Internal.Optic.Subtyping -- | Subtyping relationship between kinds of optics. -- -- An instance of Is k l means that any Optic -- k can be used as an Optic l. For example, we have -- an Is A_Lens A_Traversal instance, but -- not Is A_Traversal A_Lens. -- -- This class needs instances for all possible combinations of tags. class Is k l -- | Witness of the subtyping relationship. implies :: Is k l => (Constraints k p => r) -> Constraints l p => r type family EliminationForms (k :: OpticKind) type AffineFoldEliminations = '( '[ '("preview", "Optics.AffineFold")], '["(^?)"]) type AffineTraversalEliminations = AffineFoldEliminations `AppendEliminations` SetterEliminations type FoldEliminations = '( '[ '("traverseOf_", "Optics.Fold"), '("foldMapOf", "Optics.Fold"), '("toListOf", "Optics.Fold")], '["(^..)"]) type GetterEliminations = '( '[ '("view", "Optics.Getter")], '["(^.)"]) type IsoEliminations = GetterEliminations `AppendEliminations` ReviewEliminations `AppendEliminations` SetterEliminations type LensEliminations = GetterEliminations `AppendEliminations` SetterEliminations type PrismEliminations = AffineFoldEliminations `AppendEliminations` ReviewEliminations `AppendEliminations` SetterEliminations type ReviewEliminations = '( '[ '("review", "Optics.Review")], '["(#)"]) type SetterEliminations = '( '[ '("over", "Optics.Setter"), '("set", "Optics.Setter")], '["(%~)", "(.~)"]) type TraversalEliminations = '( '[ '("traverseOf", "Optics.Traversal")], '[]) `AppendEliminations` FoldEliminations `AppendEliminations` SetterEliminations -- | Computes the least upper bound of two optics kinds. -- -- In presence of a JoinKinds k l m constraint Optic m -- represents the least upper bound of an Optic k and an -- Optic l. This means in particular that composition of an -- Optic k and an Optic k will yield an Optic -- m. class JoinKinds k l m | k l -> m joinKinds :: JoinKinds k l m => ((Constraints k p, Constraints l p) => r) -> Constraints m p => r instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.An_Iso instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_ReversedLens Optics.Internal.Optic.Types.A_ReversedLens instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_ReversedPrism Optics.Internal.Optic.Types.A_ReversedPrism instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.A_Prism instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_Review Optics.Internal.Optic.Types.A_Review instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.A_Lens instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_Getter Optics.Internal.Optic.Types.A_Getter instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.An_AffineTraversal instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.An_AffineFold Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.A_Traversal instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_Fold Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_Setter Optics.Internal.Optic.Types.A_Setter instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_ReversedLens Optics.Internal.Optic.Types.A_ReversedLens Optics.Internal.Optic.Types.A_ReversedLens instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_ReversedLens Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_ReversedLens instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_ReversedLens Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.A_Review instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_ReversedLens Optics.Internal.Optic.Types.A_Review Optics.Internal.Optic.Types.A_Review instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_ReversedPrism Optics.Internal.Optic.Types.A_ReversedPrism Optics.Internal.Optic.Types.A_ReversedPrism instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_ReversedPrism Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_ReversedPrism instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_ReversedPrism Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_ReversedPrism Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.A_Getter instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_ReversedPrism Optics.Internal.Optic.Types.A_Getter Optics.Internal.Optic.Types.A_Getter instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_ReversedPrism Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_ReversedPrism Optics.Internal.Optic.Types.An_AffineFold Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_ReversedPrism Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_ReversedPrism Optics.Internal.Optic.Types.A_Fold Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.A_Prism instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_Prism instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.A_ReversedLens Optics.Internal.Optic.Types.A_Review instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.A_ReversedPrism Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.A_Review Optics.Internal.Optic.Types.A_Review instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.An_AffineTraversal instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.A_Getter Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.An_AffineTraversal instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.An_AffineFold Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.A_Traversal instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.A_Fold Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.A_Setter Optics.Internal.Optic.Types.A_Setter instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Review Optics.Internal.Optic.Types.A_Review Optics.Internal.Optic.Types.A_Review instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Review Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_Review instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Review Optics.Internal.Optic.Types.A_ReversedLens Optics.Internal.Optic.Types.A_Review instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Review Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.A_Review instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.A_Lens instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_Lens instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.A_ReversedPrism Optics.Internal.Optic.Types.A_Getter instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.An_AffineTraversal instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.A_Getter Optics.Internal.Optic.Types.A_Getter instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.An_AffineTraversal instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.An_AffineFold Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.A_Traversal instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.A_Fold Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.A_Setter Optics.Internal.Optic.Types.A_Setter instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Getter Optics.Internal.Optic.Types.A_Getter Optics.Internal.Optic.Types.A_Getter instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Getter Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_Getter instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Getter Optics.Internal.Optic.Types.A_ReversedPrism Optics.Internal.Optic.Types.A_Getter instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Getter Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Getter Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.A_Getter instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Getter Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Getter Optics.Internal.Optic.Types.An_AffineFold Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Getter Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Getter Optics.Internal.Optic.Types.A_Fold Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.An_AffineTraversal instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.An_AffineTraversal instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.A_ReversedPrism Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.An_AffineTraversal instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.An_AffineTraversal instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.A_Getter Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.An_AffineFold Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.A_Traversal instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.A_Fold Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.A_Setter Optics.Internal.Optic.Types.A_Setter instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_AffineFold Optics.Internal.Optic.Types.An_AffineFold Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_AffineFold Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_AffineFold Optics.Internal.Optic.Types.A_ReversedPrism Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_AffineFold Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_AffineFold Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_AffineFold Optics.Internal.Optic.Types.A_Getter Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_AffineFold Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_AffineFold Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.An_AffineFold Optics.Internal.Optic.Types.A_Fold Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.A_Traversal instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_Traversal instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.A_ReversedPrism Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.A_Traversal instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.A_Traversal instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.A_Getter Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.A_Traversal instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.An_AffineFold Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.A_Fold Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.A_Setter Optics.Internal.Optic.Types.A_Setter instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Fold Optics.Internal.Optic.Types.A_Fold Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Fold Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Fold Optics.Internal.Optic.Types.A_ReversedPrism Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Fold Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Fold Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Fold Optics.Internal.Optic.Types.A_Getter Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Fold Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Fold Optics.Internal.Optic.Types.An_AffineFold Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Fold Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Setter Optics.Internal.Optic.Types.A_Setter Optics.Internal.Optic.Types.A_Setter instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Setter Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_Setter instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Setter Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.A_Setter instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Setter Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.A_Setter instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Setter Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.A_Setter instance Optics.Internal.Optic.Subtyping.JoinKinds Optics.Internal.Optic.Types.A_Setter Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.A_Setter instance (Optics.Internal.Optic.Subtyping.JoinKinds k l m, (TypeError ...)) => Optics.Internal.Optic.Subtyping.JoinKinds k l m instance (TypeError ...) => Optics.Internal.Optic.Subtyping.Is k l instance Optics.Internal.Optic.Subtyping.Is k k instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_ReversedLens instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_ReversedPrism instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_Prism instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_Review instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_Lens instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_Getter instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.An_AffineTraversal instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_Traversal instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.An_Iso Optics.Internal.Optic.Types.A_Setter instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.A_ReversedLens Optics.Internal.Optic.Types.A_Review instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.A_ReversedPrism Optics.Internal.Optic.Types.A_Getter instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.A_ReversedPrism Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.A_ReversedPrism Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.A_Review instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.An_AffineTraversal instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.A_Traversal instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.A_Prism Optics.Internal.Optic.Types.A_Setter instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.A_Getter instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.An_AffineTraversal instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.A_Traversal instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.A_Lens Optics.Internal.Optic.Types.A_Setter instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.A_Getter Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.A_Getter Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.An_AffineFold instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.A_Traversal instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.An_AffineTraversal Optics.Internal.Optic.Types.A_Setter instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.An_AffineFold Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.A_Fold instance Optics.Internal.Optic.Subtyping.Is Optics.Internal.Optic.Types.A_Traversal Optics.Internal.Optic.Types.A_Setter -- | Core optic types and subtyping machinery. -- -- This module contains the core Optic types, and the underlying -- machinery that we need in order to implement the subtyping between -- various different flavours of optics. -- -- The composition operator for optics is also defined here. -- -- This module is intended for internal use only, and may change without -- warning in subsequent releases. module Optics.Internal.Optic -- | Wrapper newtype for the whole family of optics. -- -- The first parameter k identifies the particular optic kind -- (e.g. A_Lens or A_Traversal). -- -- The parameter is is a list of types available as indices. -- This will typically be NoIx for unindexed optics, or -- WithIx for optics with a single index. See the "Indexed optics" -- section of the overview documentation in the Optics module of -- the main optics package for more details. -- -- The parameters s and t represent the "big" -- structure, whereas a and b represent the "small" -- structure. newtype Optic (k :: OpticKind) (is :: IxList) s t a b Optic :: (forall p i. Profunctor p => Optic_ k p i (Curry is i) s t a b) -> Optic (k :: OpticKind) (is :: IxList) s t a b -- | Common special case of Optic where source and target types are -- equal. -- -- Here, we need only one "big" and one "small" type. For lenses, this -- means that in the restricted form we cannot do type-changing updates. type Optic' k is s a = Optic k is s s a a -- | Type representing the various kinds of optics. -- -- The tag parameter k is translated into constraints on -- p via the type family Constraints. type Optic_ k p i j s t a b = Constraints k p => Optic__ p i j s t a b -- | Optic internally as a profunctor transformation. type Optic__ p i j s t a b = p i a b -> p j s t -- | Strip the newtype wrapper off. getOptic :: Profunctor p => Optic k is s t a b -> Optic_ k p i (Curry is i) s t a b -- | Explicit cast from one optic flavour to another. -- -- The resulting optic kind is given in the first type argument, so you -- can use TypeApplications to set it. For example -- --
--   castOptic @A_Lens o
--   
-- -- turns o into a Lens. -- -- This is the identity function, modulo some constraint jiggery-pokery. castOptic :: forall destKind srcKind is s t a b. Is srcKind destKind => Optic srcKind is s t a b -> Optic destKind is s t a b -- | Compose two optics of compatible flavours. -- -- Returns an optic of the appropriate supertype. If either or both -- optics are indexed, the composition preserves all the indices. (%) :: forall k l m is js ks s t u v a b. (JoinKinds k l m, AppendIndices is js ks) => Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b infixl 9 % -- | Compose two optics of the same flavour. -- -- Normally you can simply use (%) instead, but this may be useful -- to help type inference if the type of one of the optics is otherwise -- under-constrained. (%%) :: forall k is js ks s t u v a b. AppendIndices is js ks => Optic k is s t u v -> Optic k js u v a b -> Optic k ks s t a b infixl 9 %% -- | Flipped function application, specialised to optics and binding -- tightly. -- -- Useful for post-composing optics transformations: -- --
--   >>> toListOf (ifolded %& ifiltered (\i s -> length s <= i)) ["", "a","abc"]
--   ["","a"]
--   
(%&) :: Optic k is s t a b -> (Optic k is s t a b -> Optic l js s' t' a' b') -> Optic l js s' t' a' b' infixl 9 %& -- | Internal implementation details of indexed setters. -- -- This module is intended for internal use only, and may change without -- warning in subsequent releases. module Optics.Internal.IxSetter -- | Internal implementation of imapped. imapped__ :: (Mapping p, FunctorWithIndex i f) => Optic__ p j (i -> j) (f a) (f b) a b -- | Internal implementation details of indexed optics. -- -- This module is intended for internal use only, and may change without -- warning in subsequent releases. module Optics.Internal.Indexed -- | Show useful error message when a function expects optics without -- indices. class is ~ NoIx => AcceptsEmptyIndices (f :: Symbol) (is :: IxList) -- | Check whether a list of indices is not empty and generate sensible -- error message if it's not. class NonEmptyIndices (is :: IxList) -- | Generate sensible error messages in case a user tries to pass either -- an unindexed optic or indexed optic with unflattened indices where -- indexed optic with a single index is expected. class is ~ '[i] => HasSingleIndex (is :: IxList) (i :: Type) type family ShowTypes (types :: [Type]) :: ErrorMessage data IntT f a IntT :: {-# UNPACK #-} !Int -> f a -> IntT f a unIntT :: IntT f a -> f a newtype Indexing f a Indexing :: (Int -> IntT f a) -> Indexing f a [runIndexing] :: Indexing f a -> Int -> IntT f a -- | Index a traversal by position of visited elements. indexing :: ((a -> Indexing f b) -> s -> Indexing f t) -> (Int -> a -> f b) -> s -> f t -- | Construct a conjoined indexed optic that provides a separate code path -- when used without indices. Useful for defining indexed optics that are -- as efficient as their unindexed equivalents when used without indices. -- -- Note: conjoined f g is well-defined if and only -- if f ≡ noIx g. conjoined :: is `HasSingleIndex` i => Optic k NoIx s t a b -> Optic k is s t a b -> Optic k is s t a b instance GHC.Base.Functor f => GHC.Base.Functor (Optics.Internal.Indexed.Indexing f) instance GHC.Base.Applicative f => GHC.Base.Applicative (Optics.Internal.Indexed.Indexing f) instance ((TypeError ...), is GHC.Types.~ '[i1, i2], is GHC.Types.~ '[i]) => Optics.Internal.Indexed.HasSingleIndex '[i1, i2] i instance ((TypeError ...), is GHC.Types.~ '[i1, i2, i3], is GHC.Types.~ '[i]) => Optics.Internal.Indexed.HasSingleIndex '[i1, i2, i3] i instance ((TypeError ...), is GHC.Types.~ '[i1, i2, i3, i4], is GHC.Types.~ '[i]) => Optics.Internal.Indexed.HasSingleIndex '[i1, i2, i3, i4] i instance ((TypeError ...), is GHC.Types.~ '[i1, i2, i3, i4, i5], is GHC.Types.~ '[i]) => Optics.Internal.Indexed.HasSingleIndex '[i1, i2, i3, i4, i5] i instance ((TypeError ...), is GHC.Types.~ (i1 : i2 : i3 : i4 : i5 : i6 : is'), is GHC.Types.~ '[i]) => Optics.Internal.Indexed.HasSingleIndex (i1 : i2 : i3 : i4 : i5 : i6 : is') i instance Optics.Internal.Indexed.HasSingleIndex '[i] i instance ((TypeError ...), '[] GHC.Types.~ '[i]) => Optics.Internal.Indexed.HasSingleIndex '[] i instance (TypeError ...) => Optics.Internal.Indexed.NonEmptyIndices '[] instance Optics.Internal.Indexed.NonEmptyIndices (x : xs) instance ((TypeError ...), (x : xs) GHC.Types.~ Optics.Internal.Optic.TypeLevel.NoIx) => Optics.Internal.Indexed.AcceptsEmptyIndices f (x : xs) instance Optics.Internal.Indexed.AcceptsEmptyIndices f '[] -- | Internal implementation details of folds. -- -- This module is intended for internal use only, and may change without -- warning in subsequent releases. module Optics.Internal.Fold -- | Internal implementation of foldVL. foldVL__ :: (Bicontravariant p, Traversing p) => (forall f. Applicative f => (a -> f u) -> s -> f v) -> Optic__ p i i s t a b -- | Internal implementation of folded. folded__ :: (Bicontravariant p, Traversing p, Foldable f) => Optic__ p i i (f a) (f b) a b -- | Internal implementation of foldring. foldring__ :: (Bicontravariant p, Traversing p) => (forall f. Applicative f => (a -> f u -> f u) -> f v -> s -> f w) -> Optic__ p i i s t a b -- | Used for headOf and iheadOf. data Leftmost a LPure :: Leftmost a LLeaf :: a -> Leftmost a LStep :: Leftmost a -> Leftmost a -- | Extract the Leftmost element. This will fairly eagerly -- determine that it can return Just the moment it sees any -- element at all. getLeftmost :: Leftmost a -> Maybe a -- | Used for lastOf and ilastOf. data Rightmost a RPure :: Rightmost a RLeaf :: a -> Rightmost a RStep :: Rightmost a -> Rightmost a -- | Extract the Rightmost element. This will fairly eagerly -- determine that it can return Just the moment it sees any -- element at all. getRightmost :: Rightmost a -> Maybe a instance GHC.Base.Semigroup (Optics.Internal.Fold.Rightmost a) instance GHC.Base.Monoid (Optics.Internal.Fold.Rightmost a) instance GHC.Base.Semigroup (Optics.Internal.Fold.Leftmost a) instance GHC.Base.Monoid (Optics.Internal.Fold.Leftmost a) -- | Internal implementation details of indexed folds. -- -- This module is intended for internal use only, and may change without -- warning in subsequent releases. module Optics.Internal.IxFold -- | Internal implementation of ifoldVL. ifoldVL__ :: (Bicontravariant p, Traversing p) => (forall f. Applicative f => (i -> a -> f u) -> s -> f v) -> Optic__ p j (i -> j) s t a b -- | Internal implementation of ifolded. ifolded__ :: (Bicontravariant p, Traversing p, FoldableWithIndex i f) => Optic__ p j (i -> j) (f a) t a b -- | Internal implementation of ifoldring. ifoldring__ :: (Bicontravariant p, Traversing p) => (forall f. Applicative f => (i -> a -> f u -> f u) -> f v -> s -> f w) -> Optic__ p j (i -> j) s t a b -- | A Getter is simply a function considered as an Optic. -- -- Given a function f :: S -> A, we can convert it into a -- Getter S A using to, and convert back to a -- function using view. -- -- This is typically useful not when you have functions/Getters -- alone, but when you are composing multiple Optics to produce a -- Getter. module Optics.Getter -- | Type synonym for a getter. type Getter s a = Optic' A_Getter NoIx s a -- | Build a getter from a function. to :: (s -> a) -> Getter s a -- | View the value pointed to by a getter. -- -- If you want to view a type-modifying optic that is -- insufficiently polymorphic to be type-preserving, use getting. view :: Is k A_Getter => Optic' k is s a -> s -> a -- | View the function of the value pointed to by a getter. views :: Is k A_Getter => Optic' k is s a -> (a -> r) -> s -> r -- | Tag for a getter. data A_Getter :: OpticKind -- | This module defines operations to coerce the type parameters of -- optics to a representationally equal type. For example, if we have -- --
--   newtype MkInt = MkInt Int
--   
-- -- and -- --
--   l :: Lens' S Int
--   
-- -- then -- --
--   coerceA @Int @MkInt l :: Lens' S MkInt
--   
module Optics.Coerce -- | Lift coerce to the s parameter of an optic. coerceS :: Coercible s s' => Optic k is s t a b -> Optic k is s' t a b -- | Lift coerce to the t parameter of an optic. coerceT :: Coercible t t' => Optic k is s t a b -> Optic k is s t' a b -- | Lift coerce to the a parameter of an optic. coerceA :: Coercible a a' => Optic k is s t a b -> Optic k is s t a' b -- | Lift coerce to the b parameter of an optic. coerceB :: Coercible b b' => Optic k is s t a b -> Optic k is s t a b' -- | An AffineTraversal is a Traversal that applies to at -- most one element. -- -- These arise most frequently as the composition of a Lens with a -- Prism. module Optics.AffineTraversal -- | Type synonym for a type-modifying affine traversal. type AffineTraversal s t a b = Optic An_AffineTraversal NoIx s t a b -- | Type synonym for a type-preserving affine traversal. type AffineTraversal' s a = Optic' An_AffineTraversal NoIx s a -- | Build an affine traversal from a matcher and an updater. -- -- If you want to build an AffineTraversal from the van Laarhoven -- representation, use atraversalVL. atraversal :: (s -> Either t a) -> (s -> b -> t) -> AffineTraversal s t a b -- | Retrieve the value targeted by an AffineTraversal or return the -- original value while allowing the type to change if it does not match. -- --
--   preview o ≡ either (const Nothing) id . matching o
--   
matching :: Is k An_AffineTraversal => Optic k is s t a b -> s -> Either t a -- | Filter result(s) of a traversal that don't satisfy a predicate. -- -- Note: This is not a legal Traversal, unless you -- are very careful not to invalidate the predicate on the target. -- -- As a counter example, consider that given evens = -- unsafeFiltered even the second Traversal law -- is violated: -- --
--   over evens succ . over evens succ /= over evens (succ . succ)
--   
-- -- So, in order for this to qualify as a legal Traversal you can -- only use it for actions that preserve the result of the predicate! -- -- For a safe variant see indices (or filtered for -- read-only optics). unsafeFiltered :: (a -> Bool) -> AffineTraversal' a a -- | Work with an affine traversal as a matcher and an updater. withAffineTraversal :: Is k An_AffineTraversal => Optic k is s t a b -> ((s -> Either t a) -> (s -> b -> t) -> r) -> r -- | Tag for an affine traversal. data An_AffineTraversal :: OpticKind -- | Type synonym for a type-modifying van Laarhoven affine traversal. -- -- Note: this isn't exactly van Laarhoven representation as there is no -- Pointed class (which would be a superclass of -- Applicative that contains pure but not -- <*>). You can interpret the first argument as a -- dictionary of Pointed that supplies the point -- function (i.e. the implementation of pure). -- -- A TraversalVL has Applicative available and hence can -- combine the effects arising from multiple elements using -- <*>. In contrast, an AffineTraversalVL has no way -- to combine effects from multiple elements, so it must act on at most -- one element. (It can act on none at all thanks to the availability of -- point.) type AffineTraversalVL s t a b = forall f. Functor f => (forall r. r -> f r) -> (a -> f b) -> s -> f t -- | Type synonym for a type-preserving van Laarhoven affine traversal. type AffineTraversalVL' s a = AffineTraversalVL s s a a -- | Build an affine traversal from the van Laarhoven representation. -- -- Example: -- --
--   >>> :{
--   azSnd = atraversalVL $ \point f ab@(a, b) ->
--     if a >= 'a' && a <= 'z'
--     then (a, ) <$> f b
--     else point ab
--   :}
--   
-- --
--   >>> preview azSnd ('a', "Hi")
--   Just "Hi"
--   
-- --
--   >>> preview azSnd ('@', "Hi")
--   Nothing
--   
-- --
--   >>> over azSnd (++ "!!!") ('f', "Hi")
--   ('f',"Hi!!!")
--   
-- --
--   >>> set azSnd "Bye" ('Y', "Hi")
--   ('Y',"Hi")
--   
atraversalVL :: AffineTraversalVL s t a b -> AffineTraversal s t a b -- | Traverse over the target of an AffineTraversal and compute a -- Functor-based answer. atraverseOf :: (Is k An_AffineTraversal, Functor f) => Optic k is s t a b -> (forall r. r -> f r) -> (a -> f b) -> s -> f t module Data.Typeable.Optics -- | An AffineTraversal' for working with a cast of a -- Typeable value. _cast :: (Typeable s, Typeable a) => AffineTraversal' s a -- | An AffineTraversal' for working with a gcast of a -- Typeable value. _gcast :: (Typeable s, Typeable a) => AffineTraversal' (c s) (c a) -- | An AffineFold is a Fold that contains at most one -- element, or a Getter where the function may be partial. module Optics.AffineFold -- | Type synonym for an affine fold. type AffineFold s a = Optic' An_AffineFold NoIx s a -- | Create an AffineFold from a partial function. -- --
--   >>> preview (afolding listToMaybe) "foo"
--   Just 'f'
--   
afolding :: (s -> Maybe a) -> AffineFold s a -- | Retrieve the value targeted by an AffineFold. -- --
--   >>> let _Right = prism Right $ either (Left . Left) Right
--   
-- --
--   >>> preview _Right (Right 'x')
--   Just 'x'
--   
-- --
--   >>> preview _Right (Left 'y')
--   Nothing
--   
preview :: Is k An_AffineFold => Optic' k is s a -> s -> Maybe a -- | Retrieve a function of the value targeted by an AffineFold. previews :: Is k An_AffineFold => Optic' k is s a -> (a -> r) -> s -> Maybe r -- | Obtain an AffineFold by lifting traverse_ like -- function. -- --
--   afoldVL . atraverseOf_id
--   atraverseOf_ . afoldVLid
--   
afoldVL :: (forall f. Functor f => (forall r. r -> f r) -> (a -> f u) -> s -> f v) -> AffineFold s a -- | Filter result(s) of a fold that don't satisfy a predicate. filtered :: (a -> Bool) -> AffineFold a a -- | Traverse over the target of an AffineFold, computing a -- Functor-based answer, but unlike atraverseOf do not -- construct a new structure. atraverseOf_ :: (Is k An_AffineFold, Functor f) => Optic' k is s a -> (forall r. r -> f r) -> (a -> f u) -> s -> f () -- | Check to see if this AffineFold doesn't match. -- --
--   >>> isn't _Just Nothing
--   True
--   
isn't :: Is k An_AffineFold => Optic' k is s a -> s -> Bool -- | Try the first AffineFold. If it returns no entry, try the -- second one. -- --
--   >>> preview (ix 1 % re _Left `afailing` ix 2 % re _Right) [0,1,2,3]
--   Just (Left 1)
--   
-- --
--   >>> preview (ix 42 % re _Left `afailing` ix 2 % re _Right) [0,1,2,3]
--   Just (Right 2)
--   
afailing :: (Is k An_AffineFold, Is l An_AffineFold) => Optic' k is s a -> Optic' l js s a -> AffineFold s a infixl 3 `afailing` -- | Tag for an affine fold. data An_AffineFold :: OpticKind -- | Internal implementation details of setters. -- -- This module is intended for internal use only, and may change without -- warning in subsequent releases. module Optics.Internal.Setter -- | Internal implementation of mapped. mapped__ :: (Mapping p, Functor f) => Optic__ p i i (f a) (f b) a b -- | Internal implementation details of indexed traversals. -- -- This module is intended for internal use only, and may change without -- warning in subsequent releases. module Optics.Internal.IxTraversal -- | Internal implementation of itraversed. itraversed__ :: (Traversing p, TraversableWithIndex i f) => Optic__ p j (i -> j) (f a) (f b) a b -- | Internal implementation details of traversals. -- -- This module is intended for internal use only, and may change without -- warning in subsequent releases. module Optics.Internal.Traversal -- | Internal implementation of traversed. traversed__ :: (Traversing p, Traversable f) => Optic__ p i i (f a) (f b) a b -- | This module is intended for internal use only, and may change without -- warning in subsequent releases. module Optics.Internal.Utils data Identity' a Identity' :: {-# UNPACK #-} !() -> a -> Identity' a -- | Mark a value for evaluation to whnf. -- -- This allows us to, when applying a setter to a structure, evaluate -- only the parts that we modify. If an optic focuses on multiple -- targets, Applicative instance of Identity' makes sure that we force -- evaluation of all of them, but we leave anything else alone. wrapIdentity' :: a -> Identity' a unwrapIdentity' :: Identity' a -> a -- | Helper for traverseOf_ and the like for better efficiency than -- the foldr-based version. -- -- Note that the argument a of the result should not be used. newtype Traversed f a Traversed :: f a -> Traversed f a runTraversed :: Functor f => Traversed f a -> f () -- | Helper for failing family to visit the first fold only once. data OrT f a OrT :: !Bool -> f a -> OrT f a -- | Wrap the applicative action in OrT so that we know later that -- it was executed. wrapOrT :: f a -> OrT f a -- | Composition operator where the first argument must be an identity -- function up to representational equivalence (e.g. a newtype wrapper or -- unwrapper), and will be ignored at runtime. (#.) :: Coercible b c => (b -> c) -> (a -> b) -> a -> c infixr 9 #. -- | Composition operator where the second argument must be an identity -- function up to representational equivalence (e.g. a newtype wrapper or -- unwrapper), and will be ignored at runtime. (.#) :: Coercible a b => (b -> c) -> (a -> b) -> a -> c infixl 8 .# -- | uncurry with no lazy pattern matching for more efficient code. uncurry' :: (a -> b -> c) -> (a, b) -> c instance GHC.Base.Functor Optics.Internal.Utils.Identity' instance GHC.Base.Functor f => GHC.Base.Functor (Optics.Internal.Utils.OrT f) instance GHC.Base.Applicative f => GHC.Base.Applicative (Optics.Internal.Utils.OrT f) instance GHC.Base.Applicative f => GHC.Base.Semigroup (Optics.Internal.Utils.Traversed f a) instance GHC.Base.Applicative f => GHC.Base.Monoid (Optics.Internal.Utils.Traversed f a) instance GHC.Base.Applicative Optics.Internal.Utils.Identity' instance Data.Profunctor.Indexed.Mapping (Data.Profunctor.Indexed.Star Optics.Internal.Utils.Identity') instance Data.Profunctor.Indexed.Mapping (Data.Profunctor.Indexed.IxStar Optics.Internal.Utils.Identity') -- | A Fold S A has the ability to extract some number of -- elements of type A from a container of type S. For -- example, toListOf can be used to obtain the contained elements -- as a list. Unlike a Traversal, there is no way to set or update -- elements. -- -- This can be seen as a generalisation of traverse_, where the -- type S does not need to be a type constructor with A -- as the last parameter. -- -- A close relative is the AffineFold, which is a Fold that -- contains at most one element. module Optics.Fold -- | Type synonym for a fold. type Fold s a = Optic' A_Fold NoIx s a -- | Obtain a Fold by lifting traverse_ like function. -- --
--   foldVL . traverseOf_id
--   traverseOf_ . foldVLid
--   
foldVL :: (forall f. Applicative f => (a -> f u) -> s -> f v) -> Fold s a -- | Combine the results of a fold using a monoid. foldOf :: (Is k A_Fold, Monoid a) => Optic' k is s a -> s -> a -- | Fold via embedding into a monoid. foldMapOf :: (Is k A_Fold, Monoid m) => Optic' k is s a -> (a -> m) -> s -> m -- | Fold right-associatively. foldrOf :: Is k A_Fold => Optic' k is s a -> (a -> r -> r) -> r -> s -> r -- | Fold left-associatively, and strictly. foldlOf' :: Is k A_Fold => Optic' k is s a -> (r -> a -> r) -> r -> s -> r -- | Fold to a list. -- --
--   >>> toListOf (_1 % folded % _Right) ([Right 'h', Left 5, Right 'i'], "bye")
--   "hi"
--   
toListOf :: Is k A_Fold => Optic' k is s a -> s -> [a] -- | Evaluate each action in a structure observed by a Fold from -- left to right, ignoring the results. -- --
--   sequenceA_sequenceOf_ folded
--   
-- --
--   >>> sequenceOf_ each (putStrLn "hello",putStrLn "world")
--   hello
--   world
--   
sequenceOf_ :: (Is k A_Fold, Applicative f) => Optic' k is s (f a) -> s -> f () -- | Traverse over all of the targets of a Fold, computing an -- Applicative-based answer, but unlike traverseOf do not -- construct a new structure. traverseOf_ generalizes -- traverse_ to work over any Fold. -- --
--   >>> traverseOf_ each putStrLn ("hello","world")
--   hello
--   world
--   
-- --
--   traverse_traverseOf_ folded
--   
traverseOf_ :: (Is k A_Fold, Applicative f) => Optic' k is s a -> (a -> f r) -> s -> f () -- | A version of traverseOf_ with the arguments flipped. forOf_ :: (Is k A_Fold, Applicative f) => Optic' k is s a -> s -> (a -> f r) -> f () -- | Fold via the Foldable class. folded :: Foldable f => Fold (f a) a -- | Obtain a Fold by lifting an operation that returns a -- Foldable result. -- -- This can be useful to lift operations from Data.List and -- elsewhere into a Fold. -- --
--   >>> toListOf (folding tail) [1,2,3,4]
--   [2,3,4]
--   
folding :: Foldable f => (s -> f a) -> Fold s a -- | Obtain a Fold by lifting foldr like function. -- --
--   >>> toListOf (foldring foldr) [1,2,3,4]
--   [1,2,3,4]
--   
foldring :: (forall f. Applicative f => (a -> f u -> f u) -> f v -> s -> f w) -> Fold s a -- | Build a Fold that unfolds its values from a seed. -- --
--   unfoldrtoListOf . unfolded
--   
-- --
--   >>> toListOf (unfolded $ \b -> if b == 0 then Nothing else Just (b, b - 1)) 10
--   [10,9,8,7,6,5,4,3,2,1]
--   
unfolded :: (s -> Maybe (a, s)) -> Fold s a -- | Check to see if this optic matches 1 or more entries. -- --
--   >>> has _Left (Left 12)
--   True
--   
-- --
--   >>> has _Right (Left 12)
--   False
--   
-- -- This will always return True for a Lens or -- Getter. -- --
--   >>> has _1 ("hello","world")
--   True
--   
has :: Is k A_Fold => Optic' k is s a -> s -> Bool -- | Check to see if this Fold or Traversal has no matches. -- --
--   >>> hasn't _Left (Right 12)
--   True
--   
-- --
--   >>> hasn't _Left (Left 12)
--   False
--   
hasn't :: Is k A_Fold => Optic' k is s a -> s -> Bool -- | Retrieve the first entry of a Fold. -- --
--   >>> headOf folded [1..10]
--   Just 1
--   
-- --
--   >>> headOf each (1,2)
--   Just 1
--   
headOf :: Is k A_Fold => Optic' k is s a -> s -> Maybe a -- | Retrieve the last entry of a Fold. -- --
--   >>> lastOf folded [1..10]
--   Just 10
--   
-- --
--   >>> lastOf each (1,2)
--   Just 2
--   
lastOf :: Is k A_Fold => Optic' k is s a -> s -> Maybe a -- | Returns True if every target of a Fold is True. -- --
--   >>> andOf each (True, False)
--   False
--   
--   >>> andOf each (True, True)
--   True
--   
-- --
--   andandOf folded
--   
andOf :: Is k A_Fold => Optic' k is s Bool -> s -> Bool -- | Returns True if any target of a Fold is True. -- --
--   >>> orOf each (True, False)
--   True
--   
--   >>> orOf each (False, False)
--   False
--   
-- --
--   ororOf folded
--   
orOf :: Is k A_Fold => Optic' k is s Bool -> s -> Bool -- | Returns True if every target of a Fold satisfies a -- predicate. -- --
--   >>> allOf each (>=3) (4,5)
--   True
--   
--   >>> allOf folded (>=2) [1..10]
--   False
--   
-- --
--   allallOf folded
--   
allOf :: Is k A_Fold => Optic' k is s a -> (a -> Bool) -> s -> Bool -- | Returns True if any target of a Fold satisfies a -- predicate. -- --
--   >>> anyOf each (=='x') ('x','y')
--   True
--   
anyOf :: Is k A_Fold => Optic' k is s a -> (a -> Bool) -> s -> Bool -- | Returns True only if no targets of a Fold satisfy a -- predicate. -- --
--   >>> noneOf each (not . isn't _Nothing) (Just 3, Just 4, Just 5)
--   True
--   
--   >>> noneOf (folded % folded) (<10) [[13,99,20],[3,71,42]]
--   False
--   
noneOf :: Is k A_Fold => Optic' k is s a -> (a -> Bool) -> s -> Bool -- | Calculate the Product of every number targeted by a -- Fold. -- --
--   >>> productOf each (4,5)
--   20
--   
--   >>> productOf folded [1,2,3,4,5]
--   120
--   
-- --
--   productproductOf folded
--   
-- -- This operation may be more strict than you would expect. If you want a -- lazier version use \o -> getProduct . -- foldMapOf o Product. productOf :: (Is k A_Fold, Num a) => Optic' k is s a -> s -> a -- | Calculate the Sum of every number targeted by a Fold. -- --
--   >>> sumOf each (5,6)
--   11
--   
--   >>> sumOf folded [1,2,3,4]
--   10
--   
--   >>> sumOf (folded % each) [(1,2),(3,4)]
--   10
--   
-- --
--   sumsumOf folded
--   
-- -- This operation may be more strict than you would expect. If you want a -- lazier version use \o -> getSum . -- foldMapOf o Sum sumOf :: (Is k A_Fold, Num a) => Optic' k is s a -> s -> a -- | The sum of a collection of actions. -- --
--   >>> asumOf each ("hello","world")
--   "helloworld"
--   
-- --
--   >>> asumOf each (Nothing, Just "hello", Nothing)
--   Just "hello"
--   
-- --
--   asumasumOf folded
--   
asumOf :: (Is k A_Fold, Alternative f) => Optic' k is s (f a) -> s -> f a -- | The sum of a collection of actions. -- --
--   >>> msumOf each ("hello","world")
--   "helloworld"
--   
-- --
--   >>> msumOf each (Nothing, Just "hello", Nothing)
--   Just "hello"
--   
-- --
--   msummsumOf folded
--   
msumOf :: (Is k A_Fold, MonadPlus m) => Optic' k is s (m a) -> s -> m a -- | Does the element occur anywhere within a given Fold of the -- structure? -- --
--   >>> elemOf each "hello" ("hello","world")
--   True
--   
-- --
--   elemelemOf folded
--   
elemOf :: (Is k A_Fold, Eq a) => Optic' k is s a -> a -> s -> Bool -- | Does the element not occur anywhere within a given Fold of the -- structure? -- --
--   >>> notElemOf each 'd' ('a','b','c')
--   True
--   
-- --
--   >>> notElemOf each 'a' ('a','b','c')
--   False
--   
-- --
--   notElemnotElemOf folded
--   
notElemOf :: (Is k A_Fold, Eq a) => Optic' k is s a -> a -> s -> Bool -- | Calculate the number of targets there are for a Fold in a given -- container. -- -- Note: This can be rather inefficient for large containers and -- just like length, this will not terminate for infinite folds. -- --
--   lengthlengthOf folded
--   
-- --
--   >>> lengthOf _1 ("hello",())
--   1
--   
-- --
--   >>> lengthOf folded [1..10]
--   10
--   
-- --
--   >>> lengthOf (folded % folded) [[1,2],[3,4],[5,6]]
--   6
--   
lengthOf :: Is k A_Fold => Optic' k is s a -> s -> Int -- | Obtain the maximum element (if any) targeted by a Fold safely. -- -- Note: maximumOf on a valid Iso, Lens or -- Getter will always return Just a value. -- --
--   >>> maximumOf folded [1..10]
--   Just 10
--   
-- --
--   >>> maximumOf folded []
--   Nothing
--   
-- --
--   >>> maximumOf (folded % filtered even) [1,4,3,6,7,9,2]
--   Just 6
--   
-- --
--   maximumfromMaybe (error "empty") . maximumOf folded
--   
-- -- In the interest of efficiency, This operation has semantics more -- strict than strictly necessary. \o -> getMax . -- foldMapOf o Max has lazier semantics but could leak -- memory. maximumOf :: (Is k A_Fold, Ord a) => Optic' k is s a -> s -> Maybe a -- | Obtain the minimum element (if any) targeted by a Fold safely. -- -- Note: minimumOf on a valid Iso, Lens or -- Getter will always return Just a value. -- --
--   >>> minimumOf folded [1..10]
--   Just 1
--   
-- --
--   >>> minimumOf folded []
--   Nothing
--   
-- --
--   >>> minimumOf (folded % filtered even) [1,4,3,6,7,9,2]
--   Just 2
--   
-- --
--   minimumfromMaybe (error "empty") . minimumOf folded
--   
-- -- In the interest of efficiency, This operation has semantics more -- strict than strictly necessary. \o -> getMin . -- foldMapOf o Min has lazier semantics but could leak -- memory. minimumOf :: (Is k A_Fold, Ord a) => Optic' k is s a -> s -> Maybe a -- | Obtain the maximum element (if any) targeted by a Fold -- according to a user supplied Ordering. -- --
--   >>> maximumByOf folded (compare `on` length) ["mustard","relish","ham"]
--   Just "mustard"
--   
-- -- In the interest of efficiency, This operation has semantics more -- strict than strictly necessary. -- --
--   maximumBy cmp ≡ fromMaybe (error "empty") . maximumByOf folded cmp
--   
maximumByOf :: Is k A_Fold => Optic' k is s a -> (a -> a -> Ordering) -> s -> Maybe a -- | Obtain the minimum element (if any) targeted by a Fold -- according to a user supplied Ordering. -- -- In the interest of efficiency, This operation has semantics more -- strict than strictly necessary. -- --
--   >>> minimumByOf folded (compare `on` length) ["mustard","relish","ham"]
--   Just "ham"
--   
-- --
--   minimumBy cmp ≡ fromMaybe (error "empty") . minimumByOf folded cmp
--   
minimumByOf :: Is k A_Fold => Optic' k is s a -> (a -> a -> Ordering) -> s -> Maybe a -- | The findOf function takes a Fold, a predicate and a -- structure and returns the leftmost element of the structure matching -- the predicate, or Nothing if there is no such element. -- --
--   >>> findOf each even (1,3,4,6)
--   Just 4
--   
-- --
--   >>> findOf folded even [1,3,5,7]
--   Nothing
--   
-- --
--   findfindOf folded
--   
findOf :: Is k A_Fold => Optic' k is s a -> (a -> Bool) -> s -> Maybe a -- | The findMOf function takes a Fold, a monadic predicate -- and a structure and returns in the monad the leftmost element of the -- structure matching the predicate, or Nothing if there is no -- such element. -- --
--   >>> findMOf each (\x -> print ("Checking " ++ show x) >> return (even x)) (1,3,4,6)
--   "Checking 1"
--   "Checking 3"
--   "Checking 4"
--   Just 4
--   
-- --
--   >>> findMOf each (\x -> print ("Checking " ++ show x) >> return (even x)) (1,3,5,7)
--   "Checking 1"
--   "Checking 3"
--   "Checking 5"
--   "Checking 7"
--   Nothing
--   
-- --
--   findMOf folded :: (Monad m, Foldable f) => (a -> m Bool) -> f a -> m (Maybe a)
--   
findMOf :: (Is k A_Fold, Monad m) => Optic' k is s a -> (a -> m Bool) -> s -> m (Maybe a) -- | The lookupOf function takes a Fold, a key, and a -- structure containing key/value pairs. It returns the first value -- corresponding to the given key. This function generalizes -- lookup to work on an arbitrary Fold instead of lists. -- --
--   >>> lookupOf folded 4 [(2, 'a'), (4, 'b'), (4, 'c')]
--   Just 'b'
--   
-- --
--   >>> lookupOf folded 2 [(2, 'a'), (4, 'b'), (4, 'c')]
--   Just 'a'
--   
lookupOf :: (Is k A_Fold, Eq a) => Optic' k is s (a, v) -> a -> s -> Maybe v -- | Convert a fold to an AffineFold that visits the first element -- of the original fold. -- -- For the traversal version see singular. pre :: Is k A_Fold => Optic' k is s a -> AffineFold s a -- | This allows you to traverse the elements of a Fold in the -- opposite order. backwards_ :: Is k A_Fold => Optic' k is s a -> Fold s a -- | Return entries of the first Fold, then the second one. -- --
--   >>> toListOf (_1 % ix 0 `summing` _2 % ix 1) ([1,2], [4,7,1])
--   [1,7]
--   
-- -- For the traversal version see adjoin. summing :: (Is k A_Fold, Is l A_Fold) => Optic' k is s a -> Optic' l js s a -> Fold s a infixr 6 `summing` -- | Try the first Fold. If it returns no entries, try the second -- one. -- --
--   >>> toListOf (ix 1 `failing` ix 0) [4,7]
--   [7]
--   
--   >>> toListOf (ix 1 `failing` ix 0) [4]
--   [4]
--   
failing :: (Is k A_Fold, Is l A_Fold) => Optic' k is s a -> Optic' l js s a -> Fold s a infixl 3 `failing` -- | Tag for a fold. data A_Fold :: OpticKind -- | An IxAffineFold is an indexed version of an AffineFold. -- See the "Indexed optics" section of the overview documentation in the -- Optics module of the main optics package for more -- details on indexed optics. module Optics.IxAffineFold -- | Type synonym for an indexed affine fold. type IxAffineFold i s a = Optic' An_AffineFold (WithIx i) s a -- | Create an IxAffineFold from a partial function. iafolding :: (s -> Maybe (i, a)) -> IxAffineFold i s a -- | Retrieve the value along with its index targeted by an -- IxAffineFold. ipreview :: (Is k An_AffineFold, is `HasSingleIndex` i) => Optic' k is s a -> s -> Maybe (i, a) -- | Retrieve a function of the value and its index targeted by an -- IxAffineFold. ipreviews :: (Is k An_AffineFold, is `HasSingleIndex` i) => Optic' k is s a -> (i -> a -> r) -> s -> Maybe r -- | Obtain an IxAffineFold by lifting itraverse_ like -- function. -- --
--   aifoldVL . iatraverseOf_id
--   aitraverseOf_ . iafoldVLid
--   
iafoldVL :: (forall f. Functor f => (forall r. r -> f r) -> (i -> a -> f u) -> s -> f v) -> IxAffineFold i s a -- | Traverse over the target of an IxAffineFold, computing a -- Functor-based answer, but unlike iatraverseOf do not -- construct a new structure. iatraverseOf_ :: (Is k An_AffineFold, Functor f, is `HasSingleIndex` i) => Optic' k is s a -> (forall r. r -> f r) -> (i -> a -> f u) -> s -> f () -- | Obtain a potentially empty IxAffineFold by taking the element -- from another AffineFold and using it as an index. filteredBy :: Is k An_AffineFold => Optic' k is a i -> IxAffineFold i a a -- | Try the first IxAffineFold. If it returns no entry, try the -- second one. iafailing :: (Is k An_AffineFold, Is l An_AffineFold, is1 `HasSingleIndex` i, is2 `HasSingleIndex` i) => Optic' k is1 s a -> Optic' l is2 s a -> IxAffineFold i s a infixl 3 `iafailing` -- | Tag for an affine fold. data An_AffineFold :: OpticKind -- | An IxAffineTraversal is an indexed version of an -- AffineTraversal. See the "Indexed optics" section of the -- overview documentation in the Optics module of the main -- optics package for more details on indexed optics. module Optics.IxAffineTraversal -- | Type synonym for a type-modifying indexed affine traversal. type IxAffineTraversal i s t a b = Optic An_AffineTraversal (WithIx i) s t a b -- | Type synonym for a type-preserving indexed affine traversal. type IxAffineTraversal' i s a = Optic' An_AffineTraversal (WithIx i) s a -- | Build an indexed affine traversal from a matcher and an updater. -- -- If you want to build an IxAffineTraversal from the van -- Laarhoven representation, use iatraversalVL. iatraversal :: (s -> Either t (i, a)) -> (s -> b -> t) -> IxAffineTraversal i s t a b -- | Obtain a potentially empty IxAffineTraversal by taking the -- element from another AffineFold and using it as an index. -- -- unsafeFilteredBy :: Is k An_AffineFold => Optic' k is a i -> IxAffineTraversal' i a a -- | This is the trivial empty IxAffineTraversal, i.e. the optic -- that targets no substructures. -- -- This is the identity element when a Fold, AffineFold, -- IxFold, IxAffineFold, Traversal or -- IxTraversal is viewed as a monoid. -- --
--   >>> 6 & ignored %~ absurd
--   6
--   
ignored :: IxAffineTraversal i s s a b -- | Tag for an affine traversal. data An_AffineTraversal :: OpticKind -- | Type synonym for a type-modifying van Laarhoven indexed affine -- traversal. -- -- Note: this isn't exactly van Laarhoven representation as there is no -- Pointed class (which would be a superclass of -- Applicative that contains pure but not -- <*>). You can interpret the first argument as a -- dictionary of Pointed that supplies the point -- function (i.e. the implementation of pure). type IxAffineTraversalVL i s t a b = forall f. Functor f => (forall r. r -> f r) -> (i -> a -> f b) -> s -> f t -- | Type synonym for a type-preserving van Laarhoven indexed affine -- traversal. type IxAffineTraversalVL' i s a = IxAffineTraversalVL i s s a a -- | Build an indexed affine traversal from the van Laarhoven -- representation. iatraversalVL :: IxAffineTraversalVL i s t a b -> IxAffineTraversal i s t a b -- | Traverse over the target of an IxAffineTraversal and compute a -- Functor-based answer. iatraverseOf :: (Is k An_AffineTraversal, Functor f, is `HasSingleIndex` i) => Optic k is s t a b -> (forall r. r -> f r) -> (i -> a -> f b) -> s -> f t -- | An IxFold is an indexed version of a Fold. See the -- "Indexed optics" section of the overview documentation in the -- Optics module of the main optics package for more -- details on indexed optics. module Optics.IxFold -- | Type synonym for an indexed fold. type IxFold i s a = Optic' A_Fold (WithIx i) s a -- | Obtain an indexed fold by lifting itraverse_ like function. -- --
--   ifoldVL . itraverseOf_id
--   itraverseOf_ . ifoldVLid
--   
ifoldVL :: (forall f. Applicative f => (i -> a -> f u) -> s -> f v) -> IxFold i s a -- | Fold with index via embedding into a monoid. ifoldMapOf :: (Is k A_Fold, Monoid m, is `HasSingleIndex` i) => Optic' k is s a -> (i -> a -> m) -> s -> m -- | Fold with index right-associatively. ifoldrOf :: (Is k A_Fold, is `HasSingleIndex` i) => Optic' k is s a -> (i -> a -> r -> r) -> r -> s -> r -- | Fold with index left-associatively, and strictly. ifoldlOf' :: (Is k A_Fold, is `HasSingleIndex` i) => Optic' k is s a -> (i -> r -> a -> r) -> r -> s -> r -- | Fold with index to a list. -- --
--   >>> itoListOf (folded % ifolded) ["abc", "def"]
--   [(0,'a'),(1,'b'),(2,'c'),(0,'d'),(1,'e'),(2,'f')]
--   
-- -- Note: currently indexed optics can be used as non-indexed. -- --
--   >>> toListOf (folded % ifolded) ["abc", "def"]
--   "abcdef"
--   
itoListOf :: (Is k A_Fold, is `HasSingleIndex` i) => Optic' k is s a -> s -> [(i, a)] -- | Traverse over all of the targets of an IxFold, computing an -- Applicative-based answer, but unlike itraverseOf do not -- construct a new structure. -- --
--   >>> itraverseOf_ each (curry print) ("hello","world")
--   (0,"hello")
--   (1,"world")
--   
itraverseOf_ :: (Is k A_Fold, Applicative f, is `HasSingleIndex` i) => Optic' k is s a -> (i -> a -> f r) -> s -> f () -- | A version of itraverseOf_ with the arguments flipped. iforOf_ :: (Is k A_Fold, Applicative f, is `HasSingleIndex` i) => Optic' k is s a -> s -> (i -> a -> f r) -> f () -- | Indexed fold via FoldableWithIndex class. ifolded :: FoldableWithIndex i f => IxFold i (f a) a -- | Obtain an IxFold by lifting an operation that returns a -- FoldableWithIndex result. -- -- This can be useful to lift operations from Data.List and -- elsewhere into an IxFold. -- --
--   >>> itoListOf (ifolding words) "how are you"
--   [(0,"how"),(1,"are"),(2,"you")]
--   
ifolding :: FoldableWithIndex i f => (s -> f a) -> IxFold i s a -- | Obtain an IxFold by lifting ifoldr like function. -- --
--   >>> itoListOf (ifoldring ifoldr) "hello"
--   [(0,'h'),(1,'e'),(2,'l'),(3,'l'),(4,'o')]
--   
ifoldring :: (forall f. Applicative f => (i -> a -> f u -> f u) -> f v -> s -> f w) -> IxFold i s a -- | Retrieve the first entry of an IxFold along with its index. -- --
--   >>> iheadOf ifolded [1..10]
--   Just (0,1)
--   
iheadOf :: (Is k A_Fold, is `HasSingleIndex` i) => Optic' k is s a -> s -> Maybe (i, a) -- | Retrieve the last entry of an IxFold along with its index. -- --
--   >>> ilastOf ifolded [1..10]
--   Just (9,10)
--   
ilastOf :: (Is k A_Fold, is `HasSingleIndex` i) => Optic' k is s a -> s -> Maybe (i, a) -- | Return whether or not any element viewed through an IxFold -- satisfies a predicate, with access to the i. -- -- When you don't need access to the index then anyOf is more -- flexible in what it accepts. -- --
--   anyOf o ≡ ianyOf o . const
--   
ianyOf :: (Is k A_Fold, is `HasSingleIndex` i) => Optic' k is s a -> (i -> a -> Bool) -> s -> Bool -- | Return whether or not all elements viewed through an IxFold -- satisfy a predicate, with access to the i. -- -- When you don't need access to the index then allOf is more -- flexible in what it accepts. -- --
--   allOf o ≡ iallOf o . const
--   
iallOf :: (Is k A_Fold, is `HasSingleIndex` i) => Optic' k is s a -> (i -> a -> Bool) -> s -> Bool -- | Return whether or not none of the elements viewed through an -- IxFold satisfy a predicate, with access to the i. -- -- When you don't need access to the index then noneOf is more -- flexible in what it accepts. -- --
--   noneOf o ≡ inoneOf o . const
--   
inoneOf :: (Is k A_Fold, is `HasSingleIndex` i) => Optic' k is s a -> (i -> a -> Bool) -> s -> Bool -- | The ifindOf function takes an IxFold, a predicate that -- is also supplied the index, a structure and returns the left-most -- element of the structure along with its index matching the predicate, -- or Nothing if there is no such element. -- -- When you don't need access to the index then findOf is more -- flexible in what it accepts. ifindOf :: (Is k A_Fold, is `HasSingleIndex` i) => Optic' k is s a -> (i -> a -> Bool) -> s -> Maybe (i, a) -- | The ifindMOf function takes an IxFold, 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 Nothing if there is no such element. -- -- When you don't need access to the index then findMOf is more -- flexible in what it accepts. ifindMOf :: (Is k A_Fold, Monad m, is `HasSingleIndex` i) => Optic' k is s a -> (i -> a -> m Bool) -> s -> m (Maybe (i, a)) -- | Convert an indexed fold to an IxAffineFold that visits the -- first element of the original fold. -- -- For the traversal version see isingular. ipre :: (Is k A_Fold, is `HasSingleIndex` i) => Optic' k is s a -> IxAffineFold i s a -- | Filter results of an IxFold that don't satisfy a predicate. -- --
--   >>> toListOf (ifolded %& ifiltered (>)) [3,2,1,0]
--   [1,0]
--   
ifiltered :: (Is k A_Fold, is `HasSingleIndex` i) => (i -> a -> Bool) -> Optic' k is s a -> IxFold i s a -- | This allows you to traverse the elements of an IxFold in the -- opposite order. ibackwards_ :: (Is k A_Fold, is `HasSingleIndex` i) => Optic' k is s a -> IxFold i s a -- | Return entries of the first IxFold, then the second one. -- --
--   >>> itoListOf (ifolded `isumming` ibackwards_ ifolded) ["a","b"]
--   [(0,"a"),(1,"b"),(1,"b"),(0,"a")]
--   
-- -- For the traversal version see iadjoin. isumming :: (Is k A_Fold, Is l A_Fold, is1 `HasSingleIndex` i, is2 `HasSingleIndex` i) => Optic' k is1 s a -> Optic' l is2 s a -> IxFold i s a infixr 6 `isumming` -- | Try the first IxFold. If it returns no entries, try the second -- one. -- --
--   >>> itoListOf (_1 % ifolded `ifailing` _2 % ifolded) (["a"], ["b","c"])
--   [(0,"a")]
--   
--   >>> itoListOf (_1 % ifolded `ifailing` _2 % ifolded) ([], ["b","c"])
--   [(0,"b"),(1,"c")]
--   
ifailing :: (Is k A_Fold, Is l A_Fold, is1 `HasSingleIndex` i, is2 `HasSingleIndex` i) => Optic' k is1 s a -> Optic' l is2 s a -> IxFold i s a infixl 3 `ifailing` -- | Tag for a fold. data A_Fold :: OpticKind -- | A container that supports folding with an additional index. class Foldable f => FoldableWithIndex i (f :: Type -> Type) | f -> i -- | Fold a container by mapping value to an arbitrary Monoid with -- access to the index i. -- -- When you don't need access to the index then foldMap is more -- flexible in what it accepts. -- --
--   foldMapifoldMap . const
--   
ifoldMap :: (FoldableWithIndex i f, Monoid m) => (i -> a -> m) -> f a -> m -- | A variant of ifoldMap that is strict in the accumulator. ifoldMap' :: (FoldableWithIndex i f, Monoid m) => (i -> a -> m) -> f a -> m -- | Right-associative fold of an indexed container with access to the -- index i. -- -- When you don't need access to the index then foldr is more -- flexible in what it accepts. -- --
--   foldrifoldr . const
--   
ifoldr :: FoldableWithIndex i f => (i -> a -> b -> b) -> b -> f a -> b -- | Left-associative fold of an indexed container with access to the index -- i. -- -- When you don't need access to the index then foldl is more -- flexible in what it accepts. -- --
--   foldlifoldl . const
--   
ifoldl :: FoldableWithIndex i f => (i -> b -> a -> b) -> b -> f a -> b -- | Strictly fold right over the elements of a structure with -- access to the index i. -- -- When you don't need access to the index then foldr' is more -- flexible in what it accepts. -- --
--   foldr'ifoldr' . const
--   
ifoldr' :: FoldableWithIndex i f => (i -> a -> b -> b) -> b -> f a -> b -- | Fold over the elements of a structure with an index, associating to -- the left, but strictly. -- -- When you don't need access to the index then foldlOf' is more -- flexible in what it accepts. -- --
--   foldlOf' l ≡ ifoldlOf' l . const
--   
ifoldl' :: FoldableWithIndex i f => (i -> b -> a -> b) -> b -> f a -> b -- | An IxGetter is an indexed version of a Getter. See the -- "Indexed optics" section of the overview documentation in the -- Optics module of the main optics package for more -- details on indexed optics. module Optics.IxGetter -- | Type synonym for an indexed getter. type IxGetter i s a = Optic' A_Getter (WithIx i) s a -- | Build an indexed getter from a function. -- --
--   >>> iview (ito id) ('i', 'x')
--   ('i','x')
--   
ito :: (s -> (i, a)) -> IxGetter i s a -- | Use a value itself as its own index. This is essentially an indexed -- version of equality. selfIndex :: IxGetter a a a -- | View the value pointed to by an indexed getter. iview :: (Is k A_Getter, is `HasSingleIndex` i) => Optic' k is s a -> s -> (i, a) -- | View the function of the value pointed to by an indexed getter. iviews :: (Is k A_Getter, is `HasSingleIndex` i) => Optic' k is s a -> (i -> a -> r) -> s -> r -- | Tag for a getter. data A_Getter :: OpticKind -- | An IxLens is an indexed version of a Lens. See the -- "Indexed optics" section of the overview documentation in the -- Optics module of the main optics package for more -- details on indexed optics. module Optics.IxLens -- | Type synonym for a type-modifying indexed lens. type IxLens i s t a b = Optic A_Lens (WithIx i) s t a b -- | Type synonym for a type-preserving indexed lens. type IxLens' i s a = Optic' A_Lens (WithIx i) s a -- | Build an indexed lens from a getter and a setter. -- -- If you want to build an IxLens from the van Laarhoven -- representation, use ilensVL. ilens :: (s -> (i, a)) -> (s -> b -> t) -> IxLens i s t a b -- | Focus on both sides of an Either. chosen :: IxLens (Either () ()) (Either a a) (Either b b) a b -- | There is an indexed field for every type in the Void. -- --
--   >>> set (mapped % devoid) 1 []
--   []
--   
-- --
--   >>> over (_Just % devoid) abs Nothing
--   Nothing
--   
devoid :: IxLens' i Void a -- | Indexed _1 with other half of a pair as an index. -- -- See isnd for examples. ifst :: IxLens i (a, i) (b, i) a b -- | Indexed _2 with other half of a pair as an index. Specialized -- version of itraversed to pairs, which can be IxLens. -- --
--   >>> iview isnd ('a', True)
--   ('a',True)
--   
-- -- That is not possible with itraversed, because it is an -- IxTraversal. -- --
--   >>> :t itraversed :: IxTraversal i (i, a) (i, b) a b
--   itraversed :: IxTraversal i (i, a) (i, b) a b
--     :: IxTraversal i (i, a) (i, b) a b
--   
isnd :: IxLens i (i, a) (i, b) a b -- | Tag for a lens. data A_Lens :: OpticKind -- | Type synonym for a type-modifying van Laarhoven indexed lens. type IxLensVL i s t a b = forall f. Functor f => (i -> a -> f b) -> s -> f t -- | Type synonym for a type-preserving van Laarhoven indexed lens. type IxLensVL' i s a = IxLensVL i s s a a -- | Build an indexed lens from the van Laarhoven representation. ilensVL :: IxLensVL i s t a b -> IxLens i s t a b -- | Convert an indexed lens to its van Laarhoven representation. toIxLensVL :: (Is k A_Lens, is `HasSingleIndex` i) => Optic k is s t a b -> IxLensVL i s t a b -- | Work with an indexed lens in the van Laarhoven representation. withIxLensVL :: (Is k A_Lens, is `HasSingleIndex` i) => Optic k is s t a b -> (IxLensVL i s t a b -> r) -> r -- | An IxSetter is an indexed version of a Setter. See the -- "Indexed optics" section of the overview documentation in the -- Optics module of the main optics package for more -- details on indexed optics. module Optics.IxSetter -- | Type synonym for a type-modifying indexed setter. type IxSetter i s t a b = Optic A_Setter (WithIx i) s t a b -- | Type synonym for a type-preserving indexed setter. type IxSetter' i s a = Optic' A_Setter (WithIx i) s a -- | Build an indexed setter from a function to modify the element(s). isets :: ((i -> a -> b) -> s -> t) -> IxSetter i s t a b -- | Apply an indexed setter as a modifier. iover :: (Is k A_Setter, is `HasSingleIndex` i) => Optic k is s t a b -> (i -> a -> b) -> s -> t -- | Indexed setter via the FunctorWithIndex class. -- --
--   iover imappedimap
--   
imapped :: FunctorWithIndex i f => IxSetter i (f a) (f b) a b -- | Apply an indexed setter. -- --
--   iset o f ≡ iover o (i _ -> f i)
--   
iset :: (Is k A_Setter, is `HasSingleIndex` i) => Optic k is s t a b -> (i -> b) -> s -> t -- | Apply an indexed setter, strictly. iset' :: (Is k A_Setter, is `HasSingleIndex` i) => Optic k is s t a b -> (i -> b) -> s -> t -- | Apply an indexed setter as a modifier, strictly. iover' :: (Is k A_Setter, is `HasSingleIndex` i) => Optic k is s t a b -> (i -> a -> b) -> s -> t -- | Tag for a setter. data A_Setter :: OpticKind -- | A Functor with an additional index. -- -- Instances must satisfy a modified form of the Functor laws: -- --
--   imap f . imap g ≡ imap (\i -> f i . g i)
--   imap (\_ a -> a) ≡ id
--   
class Functor f => FunctorWithIndex i (f :: Type -> Type) | f -> i -- | Map with access to the index. imap :: FunctorWithIndex i f => (i -> a -> b) -> f a -> f b -- | A Lens is a generalised or first-class field. -- -- If we have a value s :: S, and a l :: Lens' S -- A, we can get the "field value" of type A using -- view l s. We can also update (or put or -- set) the value using over (or set). -- -- For example, given the following definitions: -- --
--   >>> data Human = Human { _name :: String, _location :: String } deriving Show
--   
--   >>> let human = Human "Bob" "London"
--   
-- -- we can make a Lens for _name field: -- --
--   >>> let name = lens _name $ \s x -> s { _name = x }
--   
-- -- which we can use as a Getter: -- --
--   >>> view name human
--   "Bob"
--   
-- -- or a Setter: -- --
--   >>> set name "Robert" human
--   Human {_name = "Robert", _location = "London"}
--   
module Optics.Lens -- | Type synonym for a type-modifying lens. type Lens s t a b = Optic A_Lens NoIx s t a b -- | Type synonym for a type-preserving lens. type Lens' s a = Optic' A_Lens NoIx s a -- | Build a lens from a getter and a setter, which must respect the -- well-formedness laws. -- -- If you want to build a Lens from the van Laarhoven -- representation, use lensVL. lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b -- | Strict version of equality. -- -- Useful for strictifying optics with lazy (irrefutable) pattern -- matching by precomposition, e.g. -- --
--   _1' = equality' % _1
--   
equality' :: Lens a b a b -- | Make a Lens from two other lenses by executing them on their -- respective halves of a product. -- --
--   >>> (Left 'a', Right 'b') ^. alongside chosen chosen
--   ('a','b')
--   
-- --
--   >>> (Left 'a', Right 'b') & alongside chosen chosen .~ ('c','d')
--   (Left 'c',Right 'd')
--   
alongside :: (Is k A_Lens, Is l A_Lens) => Optic k is s t a b -> Optic l js s' t' a' b' -> Lens (s, s') (t, t') (a, a') (b, b') -- | We can always retrieve a () from any type. -- --
--   >>> view united "hello"
--   ()
--   
-- --
--   >>> set united () "hello"
--   "hello"
--   
united :: Lens' a () -- | Work with a lens as a getter and a setter. -- --
--   withLens (lens f g) k ≡ k f g
--   
withLens :: Is k A_Lens => Optic k is s t a b -> ((s -> a) -> (s -> b -> t) -> r) -> r -- | Tag for a lens. data A_Lens :: OpticKind -- | Type synonym for a type-modifying van Laarhoven lens. type LensVL s t a b = forall f. Functor f => (a -> f b) -> s -> f t -- | Type synonym for a type-preserving van Laarhoven lens. type LensVL' s a = LensVL s s a a -- | Build a lens from the van Laarhoven representation. lensVL :: LensVL s t a b -> Lens s t a b -- | Convert a lens to the van Laarhoven representation. toLensVL :: Is k A_Lens => Optic k is s t a b -> LensVL s t a b -- | Work with a lens in the van Laarhoven representation. withLensVL :: Is k A_Lens => Optic k is s t a b -> (LensVL s t a b -> r) -> r -- | This module defines optics for manipulating Trees. module Data.Tree.Optics -- | A Lens that focuses on the root of a Tree. -- --
--   >>> view root $ Node 42 []
--   42
--   
root :: Lens' (Tree a) a -- | A Lens returning the direct descendants of the root of a -- Tree -- --
--   view branchessubForest
--   
branches :: Lens' (Tree a) [Tree a] -- | This module provides core definitions: -- -- -- -- Each optic kind is identified by a "tag type" (such as A_Lens), -- which is an empty data type. The type of the actual optics (such as -- Lens) is obtained by applying Optic to the tag type. -- -- See the Optics module in the main optics package for -- overview documentation. module Optics.Optic -- | Kind for types used as optic tags, such as A_Lens. type OpticKind = Type -- | Wrapper newtype for the whole family of optics. -- -- The first parameter k identifies the particular optic kind -- (e.g. A_Lens or A_Traversal). -- -- The parameter is is a list of types available as indices. -- This will typically be NoIx for unindexed optics, or -- WithIx for optics with a single index. See the "Indexed optics" -- section of the overview documentation in the Optics module of -- the main optics package for more details. -- -- The parameters s and t represent the "big" -- structure, whereas a and b represent the "small" -- structure. data Optic (k :: OpticKind) (is :: IxList) s t a b -- | Common special case of Optic where source and target types are -- equal. -- -- Here, we need only one "big" and one "small" type. For lenses, this -- means that in the restricted form we cannot do type-changing updates. type Optic' k is s a = Optic k is s s a a -- | Explicit cast from one optic flavour to another. -- -- The resulting optic kind is given in the first type argument, so you -- can use TypeApplications to set it. For example -- --
--   castOptic @A_Lens o
--   
-- -- turns o into a Lens. -- -- This is the identity function, modulo some constraint jiggery-pokery. castOptic :: forall destKind srcKind is s t a b. Is srcKind destKind => Optic srcKind is s t a b -> Optic destKind is s t a b -- | Subtyping relationship between kinds of optics. -- -- An instance of Is k l means that any Optic -- k can be used as an Optic l. For example, we have -- an Is A_Lens A_Traversal instance, but -- not Is A_Traversal A_Lens. -- -- This class needs instances for all possible combinations of tags. class Is k l -- | Computes the least upper bound of two optics kinds. -- -- In presence of a JoinKinds k l m constraint Optic m -- represents the least upper bound of an Optic k and an -- Optic l. This means in particular that composition of an -- Optic k and an Optic k will yield an Optic -- m. class JoinKinds k l m | k l -> m -- | Compose two optics of compatible flavours. -- -- Returns an optic of the appropriate supertype. If either or both -- optics are indexed, the composition preserves all the indices. (%) :: forall k l m is js ks s t u v a b. (JoinKinds k l m, AppendIndices is js ks) => Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b infixl 9 % -- | Compose two optics of the same flavour. -- -- Normally you can simply use (%) instead, but this may be useful -- to help type inference if the type of one of the optics is otherwise -- under-constrained. (%%) :: forall k is js ks s t u v a b. AppendIndices is js ks => Optic k is s t u v -> Optic k js u v a b -> Optic k ks s t a b infixl 9 %% -- | Flipped function application, specialised to optics and binding -- tightly. -- -- Useful for post-composing optics transformations: -- --
--   >>> toListOf (ifolded %& ifiltered (\i s -> length s <= i)) ["", "a","abc"]
--   ["","a"]
--   
(%&) :: Optic k is s t a b -> (Optic k is s t a b -> Optic l js s' t' a' b') -> Optic l js s' t' a' b' infixl 9 %& -- | A list of index types, used for indexed optics. type IxList = [Type] -- | An alias for an empty index-list type NoIx = ('[] :: IxList) -- | Singleton index list type WithIx i = ('[i] :: IxList) -- | In pseudo (dependent-)Haskell, provide a witness -- --
--   foldr f (foldr f init xs) ys = foldr f init (ys ++ xs)
--      where f = (->)
--   
class AppendIndices xs ys ks | xs ys -> ks -- | Check whether a list of indices is not empty and generate sensible -- error message if it's not. class NonEmptyIndices (is :: IxList) -- | Generate sensible error messages in case a user tries to pass either -- an unindexed optic or indexed optic with unflattened indices where -- indexed optic with a single index is expected. class is ~ '[i] => HasSingleIndex (is :: IxList) (i :: Type) -- | Show useful error message when a function expects optics without -- indices. class is ~ NoIx => AcceptsEmptyIndices (f :: Symbol) (is :: IxList) -- | Curry a type-level list. -- -- In pseudo (dependent-)Haskell: -- --
--   Curry xs y = foldr (->) y xs
--   
type family Curry (xs :: IxList) (y :: Type) :: Type -- | Class that is inhabited by all type-level lists xs, providing -- the ability to compose a function under Curry xs. class CurryCompose xs -- | Compose a function under Curry xs. This generalises -- (.) (aka fmap for (->)) to work for -- curried functions with one argument for each type in the list. composeN :: CurryCompose xs => (i -> j) -> Curry xs i -> Curry xs j -- | & is a reverse application operator. This provides -- notational convenience. Its precedence is one higher than that of the -- forward application operator $, which allows & to be -- nested in $. -- --
--   >>> 5 & (+1) & show
--   "6"
--   
(&) :: a -> (a -> b) -> b infixl 1 & -- | Flipped version of <$>. -- --
--   (<&>) = flip fmap
--   
-- --

Examples

-- -- Apply (+1) to a list, a Just and a Right: -- --
--   >>> Just 2 <&> (+1)
--   Just 3
--   
-- --
--   >>> [1,2,3] <&> (+1)
--   [2,3,4]
--   
-- --
--   >>> Right 3 <&> (+1)
--   Right 4
--   
(<&>) :: Functor f => f a -> (a -> b) -> f b infixl 1 <&> -- | This module exists to provide documentation for lenses for working -- with Map, which might otherwise be obscured by their -- genericity. -- -- Map is an instance of At and provides at as a -- lens on values at keys: -- --
--   >>> Map.fromList [(1, "world")] ^. at 1
--   Just "world"
--   
-- --
--   >>> Map.empty & at 1 .~ Just "world"
--   fromList [(1,"world")]
--   
-- --
--   >>> Map.empty & at 0 .~ Just "hello"
--   fromList [(0,"hello")]
--   
-- -- We can traverse, fold over, and map over key-value pairs in a -- Map, thanks to indexed traversals, folds and setters. -- --
--   >>> iover imapped const $ Map.fromList [(1, "Venus")]
--   fromList [(1,1)]
--   
-- --
--   >>> ifoldMapOf ifolded (\i _ -> Sum i) $ Map.fromList [(2, "Earth"), (3, "Mars")]
--   Sum {getSum = 5}
--   
-- --
--   >>> itraverseOf_ ifolded (curry print) $ Map.fromList [(4, "Jupiter")]
--   (4,"Jupiter")
--   
-- --
--   >>> itoListOf ifolded $ Map.fromList [(5, "Saturn")]
--   [(5,"Saturn")]
--   
-- -- A related class, Ixed, allows us to use ix to traverse a -- value at a particular key. -- --
--   >>> Map.fromList [(2, "Earth")] & ix 2 %~ ("New " ++)
--   fromList [(2,"New Earth")]
--   
-- --
--   >>> preview (ix 8) Map.empty
--   Nothing
--   
module Data.Map.Optics -- | Construct a map from an IxFold. -- -- The construction is left-biased (see union), i.e. the first -- occurrences of keys in the fold or traversal order are preferred. -- --
--   >>> toMapOf ifolded ["hello", "world"]
--   fromList [(0,"hello"),(1,"world")]
--   
-- --
--   >>> toMapOf (folded % ifolded) [('a',"alpha"),('b', "beta")]
--   fromList [('a',"alpha"),('b',"beta")]
--   
-- --
--   >>> toMapOf (ifolded <%> ifolded) ["foo", "bar"]
--   fromList [((0,0),'f'),((0,1),'o'),((0,2),'o'),((1,0),'b'),((1,1),'a'),((1,2),'r')]
--   
-- --
--   >>> toMapOf (folded % ifolded) [('a', "hello"), ('b', "world"), ('a', "dummy")]
--   fromList [('a',"hello"),('b',"world")]
--   
toMapOf :: (Is k A_Fold, is `HasSingleIndex` i, Ord i) => Optic' k is s a -> s -> Map i a -- | Focus on the largest key smaller than the given one and its -- corresponding value. -- --
--   >>> Map.fromList [('a', "hi"), ('b', "there")] & over (lt 'b') (++ "!")
--   fromList [('a',"hi!"),('b',"there")]
--   
-- --
--   >>> ipreview (lt 'a') $ Map.fromList [('a', 'x'), ('b', 'y')]
--   Nothing
--   
lt :: Ord k => k -> IxAffineTraversal' k (Map k v) v -- | Focus on the smallest key greater than the given one and its -- corresponding value. -- --
--   >>> Map.fromList [('a', "hi"), ('b', "there")] & over (gt 'b') (++ "!")
--   fromList [('a',"hi"),('b',"there")]
--   
-- --
--   >>> ipreview (gt 'a') $ Map.fromList [('a', 'x'), ('b', 'y')]
--   Just ('b','y')
--   
gt :: Ord k => k -> IxAffineTraversal' k (Map k v) v -- | Focus on the largest key smaller or equal than the given one and its -- corresponding value. -- --
--   >>> Map.fromList [('a', "hi"), ('b', "there")] & over (le 'b') (++ "!")
--   fromList [('a',"hi"),('b',"there!")]
--   
-- --
--   >>> ipreview (le 'a') $ Map.fromList [('a', 'x'), ('b', 'y')]
--   Just ('a','x')
--   
le :: Ord k => k -> IxAffineTraversal' k (Map k v) v -- | Focus on the smallest key greater or equal than the given one and its -- corresponding value. -- --
--   >>> Map.fromList [('a', "hi"), ('c', "there")] & over (ge 'b') (++ "!")
--   fromList [('a',"hi"),('c',"there!")]
--   
-- --
--   >>> ipreview (ge 'b') $ Map.fromList [('a', 'x'), ('c', 'y')]
--   Just ('c','y')
--   
ge :: Ord k => k -> IxAffineTraversal' k (Map k v) v -- | IntMap is an instance of At and provides at as a -- lens on values at keys: -- --
--   >>> IntMap.fromList [(1, "world")] ^. at 1
--   Just "world"
--   
-- --
--   >>> IntMap.empty & at 1 .~ Just "world"
--   fromList [(1,"world")]
--   
-- --
--   >>> IntMap.empty & at 0 .~ Just "hello"
--   fromList [(0,"hello")]
--   
-- -- We can traverse, fold over, and map over key-value pairs in an -- IntMap, thanks to indexed traversals, folds and setters. -- --
--   >>> iover imapped const $ IntMap.fromList [(1, "Venus")]
--   fromList [(1,1)]
--   
-- --
--   >>> ifoldMapOf ifolded (\i _ -> Sum i) $ IntMap.fromList [(2, "Earth"), (3, "Mars")]
--   Sum {getSum = 5}
--   
-- --
--   >>> itraverseOf_ ifolded (curry print) $ IntMap.fromList [(4, "Jupiter")]
--   (4,"Jupiter")
--   
-- --
--   >>> itoListOf ifolded $ IntMap.fromList [(5, "Saturn")]
--   [(5,"Saturn")]
--   
-- -- A related class, Ixed, allows us to use ix to traverse a -- value at a particular key. -- --
--   >>> IntMap.fromList [(2, "Earth")] & ix 2 %~ ("New " ++)
--   fromList [(2,"New Earth")]
--   
-- --
--   >>> preview (ix 8) IntMap.empty
--   Nothing
--   
module Data.IntMap.Optics -- | Construct a map from an IxFold. -- -- The construction is left-biased (see union), i.e. the first -- occurrences of keys in the fold or traversal order are preferred. -- --
--   >>> toMapOf ifolded ["hello", "world"]
--   fromList [(0,"hello"),(1,"world")]
--   
-- --
--   >>> toMapOf (folded % ifolded) [(1,"alpha"),(2, "beta")]
--   fromList [(1,"alpha"),(2,"beta")]
--   
-- --
--   >>> toMapOf (icompose (\a b -> 10*a+b) $ ifolded % ifolded) ["foo", "bar"]
--   fromList [(0,'f'),(1,'o'),(2,'o'),(10,'b'),(11,'a'),(12,'r')]
--   
-- --
--   >>> toMapOf (folded % ifolded) [(1, "hello"), (2, "world"), (1, "dummy")]
--   fromList [(1,"hello"),(2,"world")]
--   
toMapOf :: (Is k A_Fold, is `HasSingleIndex` Int) => Optic' k is s a -> s -> IntMap a -- | Focus on the largest key smaller than the given one and its -- corresponding value. -- --
--   >>> IntMap.fromList [(1, "hi"), (2, "there")] & over (lt 2) (++ "!")
--   fromList [(1,"hi!"),(2,"there")]
--   
-- --
--   >>> ipreview (lt 1) $ IntMap.fromList [(1, 'x'), (2, 'y')]
--   Nothing
--   
lt :: Int -> IxAffineTraversal' Int (IntMap v) v -- | Focus on the smallest key greater than the given one and its -- corresponding value. -- --
--   >>> IntMap.fromList [(1, "hi"), (2, "there")] & over (gt 2) (++ "!")
--   fromList [(1,"hi"),(2,"there")]
--   
-- --
--   >>> ipreview (gt 1) $ IntMap.fromList [(1, 'x'), (2, 'y')]
--   Just (2,'y')
--   
gt :: Int -> IxAffineTraversal' Int (IntMap v) v -- | Focus on the largest key smaller or equal than the given one and its -- corresponding value. -- --
--   >>> IntMap.fromList [(1, "hi"), (2, "there")] & over (le 2) (++ "!")
--   fromList [(1,"hi"),(2,"there!")]
--   
-- --
--   >>> ipreview (le 1) $ IntMap.fromList [(1, 'x'), (2, 'y')]
--   Just (1,'x')
--   
le :: Int -> IxAffineTraversal' Int (IntMap v) v -- | Focus on the smallest key greater or equal than the given one and its -- corresponding value. -- --
--   >>> IntMap.fromList [(1, "hi"), (3, "there")] & over (ge 2) (++ "!")
--   fromList [(1,"hi"),(3,"there!")]
--   
-- --
--   >>> ipreview (ge 2) $ IntMap.fromList [(1, 'x'), (3, 'y')]
--   Just (3,'y')
--   
ge :: Int -> IxAffineTraversal' Int (IntMap v) v -- | A Prism generalises the notion of a constructor (just as a -- Lens generalises the notion of a field). module Optics.Prism -- | Type synonym for a type-modifying prism. type Prism s t a b = Optic A_Prism NoIx s t a b -- | Type synonym for a type-preserving prism. type Prism' s a = Optic' A_Prism NoIx s a -- | Build a prism from a constructor and a matcher, which must respect the -- well-formedness laws. -- -- If you want to build a Prism from the van Laarhoven -- representation, use prismVL from the optics-vl -- package. prism :: (b -> t) -> (s -> Either t a) -> Prism s t a b -- | This is usually used to build a Prism', when you have to use an -- operation like cast which already returns a Maybe. prism' :: (b -> s) -> (s -> Maybe a) -> Prism s s a b -- | This Prism compares for exact equality with a given value. -- --
--   >>> only 4 # ()
--   4
--   
-- --
--   >>> 5 ^? only 4
--   Nothing
--   
only :: Eq a => a -> Prism' a () -- | This Prism 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 -- _Empty with the AsEmpty list instance): -- --
--   >>> nearly [] null # ()
--   []
--   
--   >>> [1,2,3,4] ^? nearly [] null
--   Nothing
--   
-- --
--   nearly [] null :: Prism' [a] ()
--   
-- -- To comply with the Prism laws the arguments you supply to -- nearly a p are somewhat constrained. -- -- We assume p x holds iff x ≡ a. Under that assumption -- then this is a valid Prism. -- -- 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 () -- | Work with a Prism as a constructor and a matcher. withPrism :: Is k A_Prism => Optic k is s t a b -> ((b -> t) -> (s -> Either t a) -> r) -> r -- | Use a Prism to work over part of a structure. aside :: Is k A_Prism => Optic k is s t a b -> Prism (e, s) (e, t) (e, a) (e, b) -- | Given a pair of prisms, project sums. -- -- Viewing a Prism as a co-Lens, this combinator can be -- seen to be dual to alongside. without :: (Is k A_Prism, Is l A_Prism) => Optic k is s t a b -> Optic l is u v c d -> Prism (Either s u) (Either t v) (Either a c) (Either b d) -- | Lift a Prism through a Traversable functor, giving a -- Prism that matches only if all the elements of the container -- match the Prism. below :: (Is k A_Prism, Traversable f) => Optic' k is s a -> Prism' (f s) (f a) -- | Tag for a prism. data A_Prism :: OpticKind -- | This module defines Prisms for the constructors of the -- Maybe datatype. module Data.Maybe.Optics -- | A Prism that matches on the Nothing constructor of -- Maybe. _Nothing :: Prism' (Maybe a) () -- | A Prism that matches on the Just constructor of -- Maybe. _Just :: Prism (Maybe a) (Maybe b) a b -- | Additional optics for manipulating lists are present more generically -- in this package. -- -- The Ixed class allows traversing the element at a specific list -- index. -- --
--   >>> [0..10] ^? ix 4
--   Just 4
--   
-- --
--   >>> [0..5] & ix 4 .~ 2
--   [0,1,2,3,2,5]
--   
-- --
--   >>> [0..10] ^? ix 14
--   Nothing
--   
-- --
--   >>> [0..5] & ix 14 .~ 2
--   [0,1,2,3,4,5]
--   
-- -- The Cons and AsEmpty classes provide Prisms for -- list constructors. -- --
--   >>> [1..10] ^? _Cons
--   Just (1,[2,3,4,5,6,7,8,9,10])
--   
-- --
--   >>> [] ^? _Cons
--   Nothing
--   
-- --
--   >>> [] ^? _Empty
--   Just ()
--   
-- --
--   >>> _Cons # (1, _Empty # ()) :: [Int]
--   [1]
--   
-- -- Additionally, Snoc provides a Prism for accessing the -- end of a list. Note that this Prism always will need to -- traverse the whole list. -- --
--   >>> [1..5] ^? _Snoc
--   Just ([1,2,3,4],5)
--   
-- --
--   >>> _Snoc # ([1,2],5)
--   [1,2,5]
--   
-- -- Finally, it's possible to traverse, fold over, and map over -- index-value pairs thanks to instances of TraversableWithIndex, -- FoldableWithIndex, and FunctorWithIndex. -- --
--   >>> imap (,) "Hello"
--   [(0,'H'),(1,'e'),(2,'l'),(3,'l'),(4,'o')]
--   
-- --
--   >>> ifoldMap replicate "Hello"
--   "ellllloooo"
--   
-- --
--   >>> itraverse_ (curry print) "Hello"
--   (0,'H')
--   (1,'e')
--   (2,'l')
--   (3,'l')
--   (4,'o')
--   
module Data.List.Optics -- | A Prism stripping a prefix from a list when used as a -- Traversal, or prepending that prefix when run backwards: -- --
--   >>> "preview" ^? prefixed "pre"
--   Just "view"
--   
-- --
--   >>> "review" ^? prefixed "pre"
--   Nothing
--   
-- --
--   >>> prefixed "pre" # "amble"
--   "preamble"
--   
prefixed :: Eq a => [a] -> Prism' [a] [a] -- | A Prism stripping a suffix from a list when used as a -- Traversal, or appending that suffix when run backwards: -- --
--   >>> "review" ^? suffixed "view"
--   Just "re"
--   
-- --
--   >>> "review" ^? suffixed "tire"
--   Nothing
--   
-- --
--   >>> suffixed ".o" # "hello"
--   "hello.o"
--   
suffixed :: Eq a => [a] -> Prism' [a] [a] -- | This module defines Prisms for the constructors of the -- Either datatype. module Data.Either.Optics -- | A Prism that matches on the Left constructor of -- Either. _Left :: Prism (Either a b) (Either c b) a c -- | A Prism that matches on the Right constructor of -- Either. _Right :: Prism (Either a b) (Either a c) b c -- | Some optics can be reversed with re. This is mainly useful to -- invert Isos: -- --
--   >>> let _Identity = iso runIdentity Identity
--   
--   >>> view (_1 % re _Identity) ('x', "yz")
--   Identity 'x'
--   
-- -- Yet we can use a Lens as a Review too: -- --
--   >>> review (re _1) ('x', "yz")
--   'x'
--   
-- -- In the following diagram, red arrows illustrate how re -- transforms optics. The ReversedLens and ReversedPrism -- optic kinds are backwards versions of Lens and Prism -- respectively, and are present so that re . re -- does not change the optic kind. -- module Optics.Re -- | Class for optics that can be reversed. class ReversibleOptic k where { -- | Injective type family that maps an optic kind to the optic kind -- produced by reversing it. -- --
    --   ReversedOptic An_Iso            = An_Iso
    --   ReversedOptic A_Prism           = A_ReversedPrism
    --   ReversedOptic A_ReversedPrism   = A_Prism
    --   ReversedOptic A_Lens            = A_ReversedLens
    --   ReversedOptic A_ReversedLens    = A_Lens
    --   ReversedOptic A_Getter          = A_Review
    --   ReversedOptic A_Review          = A_Getter
    --   
type family ReversedOptic k = r | r -> k; } -- | Reverses optics, turning around Iso into Iso, -- Prism into ReversedPrism (and back), Lens into -- ReversedLens (and back) and Getter into Review -- (and back). re :: (ReversibleOptic k, "re" `AcceptsEmptyIndices` is) => Optic k is s t a b -> Optic (ReversedOptic k) is b a t s instance Data.Profunctor.Indexed.Profunctor p => Data.Profunctor.Indexed.Profunctor (Optics.Re.Re p s t) instance Optics.Internal.Bi.Bicontravariant p => Optics.Internal.Bi.Bifunctor (Optics.Re.Re p s t) instance Optics.Internal.Bi.Bifunctor p => Optics.Internal.Bi.Bicontravariant (Optics.Re.Re p s t) instance Data.Profunctor.Indexed.Strong p => Data.Profunctor.Indexed.Costrong (Optics.Re.Re p s t) instance Data.Profunctor.Indexed.Costrong p => Data.Profunctor.Indexed.Strong (Optics.Re.Re p s t) instance Data.Profunctor.Indexed.Choice p => Data.Profunctor.Indexed.Cochoice (Optics.Re.Re p s t) instance Data.Profunctor.Indexed.Cochoice p => Data.Profunctor.Indexed.Choice (Optics.Re.Re p s t) instance Optics.Re.ReversibleOptic Optics.Internal.Optic.Types.An_Iso instance Optics.Re.ReversibleOptic Optics.Internal.Optic.Types.A_Prism instance Optics.Re.ReversibleOptic Optics.Internal.Optic.Types.A_ReversedPrism instance Optics.Re.ReversibleOptic Optics.Internal.Optic.Types.A_Lens instance Optics.Re.ReversibleOptic Optics.Internal.Optic.Types.A_ReversedLens instance Optics.Re.ReversibleOptic Optics.Internal.Optic.Types.A_Getter instance Optics.Re.ReversibleOptic Optics.Internal.Optic.Types.A_Review -- | This module defines getting, which turns a read-write optic -- into its read-only counterpart. module Optics.ReadOnly -- | Class for read-write optics that have their read-only counterparts. class ToReadOnly k s t a b where { type family ReadOnlyOptic k :: OpticKind; } -- | Turn read-write optic into its read-only counterpart (or leave -- read-only optics as-is). -- -- This is useful when you have an optic :: Optic k is s t a -- b of read-write kind k such that s, t, -- a, b are rigid, there is no evidence that s ~ -- t and a ~ b and you want to pass optic to one -- of the functions that accept read-only optic kinds. -- -- Example: -- --
--   >>> let fstIntToChar = _1 :: Lens (Int, r) (Char, r) Int Char
--   
-- --
--   >>> :t view fstIntToChar
--   ...
--   ...Couldn't match type ‘Char’ with ‘Int’
--   ...
--   
-- --
--   >>> :t view (getting fstIntToChar)
--   view (getting fstIntToChar) :: (Int, r) -> Int
--   
getting :: ToReadOnly k s t a b => Optic k is s t a b -> Optic' (ReadOnlyOptic k) is s a instance Optics.ReadOnly.ToReadOnly Optics.Internal.Optic.Types.An_Iso s t a b instance Optics.ReadOnly.ToReadOnly Optics.Internal.Optic.Types.A_Lens s t a b instance Optics.ReadOnly.ToReadOnly Optics.Internal.Optic.Types.A_Prism s t a b instance Optics.ReadOnly.ToReadOnly Optics.Internal.Optic.Types.An_AffineTraversal s t a b instance Optics.ReadOnly.ToReadOnly Optics.Internal.Optic.Types.A_Traversal s t a b instance Optics.ReadOnly.ToReadOnly Optics.Internal.Optic.Types.A_ReversedPrism s t a b instance (s GHC.Types.~ t, a GHC.Types.~ b) => Optics.ReadOnly.ToReadOnly Optics.Internal.Optic.Types.A_Getter s t a b instance (s GHC.Types.~ t, a GHC.Types.~ b) => Optics.ReadOnly.ToReadOnly Optics.Internal.Optic.Types.An_AffineFold s t a b instance (s GHC.Types.~ t, a GHC.Types.~ b) => Optics.ReadOnly.ToReadOnly Optics.Internal.Optic.Types.A_Fold s t a b -- | A ReversedLens is a backwards Lens, i.e. a -- ReversedLens s t a b is equivalent to a -- Lens b a t s. These are typically produced by calling -- re on a Lens. They are distinguished from a -- Review so that re . re on a Lens -- returns a Lens. module Optics.ReversedLens -- | Type synonym for a type-modifying reversed lens. type ReversedLens s t a b = Optic A_ReversedLens NoIx s t a b -- | Type synonym for a type-preserving reversed lens. type ReversedLens' t b = Optic' A_ReversedLens NoIx t b -- | Tag for a reversed lens. data A_ReversedLens :: OpticKind -- | A ReversedPrism is a backwards Prism, i.e. a -- ReversedPrism s t a b is equivalent to a -- Prism b a t s. These are typically produced by calling -- re on a Prism. They are distinguished from a -- Getter so that re . re on a Prism -- returns a Prism. module Optics.ReversedPrism -- | Type synonym for a type-modifying reversed prism. type ReversedPrism s t a b = Optic A_ReversedPrism NoIx s t a b -- | Type synonym for a type-preserving reversed prism. type ReversedPrism' s a = Optic' A_ReversedPrism NoIx s a -- | Tag for a reversed prism. data A_ReversedPrism :: OpticKind -- | A Review is a backwards Getter, i.e. a Review -- T B is just a function B -> T. module Optics.Review -- | Type synonym for a review. type Review t b = Optic' A_Review NoIx t b -- | An analogue of to for reviews. unto :: (b -> t) -> Review t b -- | Retrieve the value targeted by a Review. -- --
--   >>> review _Left "hi"
--   Left "hi"
--   
review :: Is k A_Review => Optic' k is t b -> b -> t -- | Tag for a review. data A_Review :: OpticKind -- | An Isomorphism expresses the fact that two types have the same -- structure, and hence can be converted from one to the other in either -- direction. module Optics.Iso -- | Type synonym for a type-modifying iso. type Iso s t a b = Optic An_Iso NoIx s t a b -- | Type synonym for a type-preserving iso. type Iso' s a = Optic' An_Iso NoIx s a -- | Build an iso from a pair of inverse functions. -- -- If you want to build an Iso from the van Laarhoven -- representation, use isoVL from the optics-vl -- package. iso :: (s -> a) -> (b -> t) -> Iso s t a b -- | Capture type constraints as an isomorphism. -- -- Note: This is the identity optic: -- --
--   >>> :t view equality
--   view equality :: a -> a
--   
equality :: (s ~ a, t ~ b) => Iso s t a b -- | Proof of reflexivity. simple :: Iso' a a -- | Data types that are representationally equal are isomorphic. -- --
--   >>> view coerced 'x' :: Identity Char
--   Identity 'x'
--   
coerced :: (Coercible s a, Coercible t b) => Iso s t a b -- | Type-preserving version of coerced with type parameters -- rearranged for TypeApplications. -- --
--   >>> newtype MkInt = MkInt Int deriving Show
--   
-- --
--   >>> over (coercedTo @Int) (*3) (MkInt 2)
--   MkInt 6
--   
coercedTo :: forall a s. Coercible s a => Iso' s a -- | Special case of coerced for trivial newtype wrappers. -- --
--   >>> over (coerced1 @Identity) (++ "bar") (Identity "foo")
--   Identity "foobar"
--   
coerced1 :: forall f s a. (Coercible s (f s), Coercible a (f a)) => Iso (f s) (f a) s a -- | If v is an element of a type a, and a' is -- a sans the element v, then non v is -- an isomorphism from Maybe a' to a. -- --
--   nonnon' . only
--   
-- -- Keep in mind this is only a real isomorphism if you treat the domain -- as being Maybe (a sans v). -- -- This is practically quite useful when you want to have a Map -- where all the entries should have non-zero values. -- --
--   >>> Map.fromList [("hello",1)] & at "hello" % non 0 %~ (+2)
--   fromList [("hello",3)]
--   
-- --
--   >>> Map.fromList [("hello",1)] & at "hello" % non 0 %~ (subtract 1)
--   fromList []
--   
-- --
--   >>> Map.fromList [("hello",1)] ^. at "hello" % non 0
--   1
--   
-- --
--   >>> Map.fromList [] ^. at "hello" % non 0
--   0
--   
-- -- This combinator is also particularly useful when working with nested -- maps. -- -- e.g. When you want to create the nested Map when it is -- missing: -- --
--   >>> Map.empty & at "hello" % non Map.empty % at "world" ?~ "!!!"
--   fromList [("hello",fromList [("world","!!!")])]
--   
-- -- and when have deleting the last entry from the nested Map mean -- that we should delete its entry from the surrounding one: -- --
--   >>> Map.fromList [("hello", Map.fromList [("world","!!!")])] & at "hello" % non Map.empty % at "world" .~ Nothing
--   fromList []
--   
-- -- It can also be used in reverse to exclude a given value: -- --
--   >>> non 0 # rem 10 4
--   Just 2
--   
-- --
--   >>> non 0 # rem 10 5
--   Nothing
--   
non :: Eq a => a -> Iso' (Maybe a) a -- | non' p generalizes non (p # ()) to -- take any unit Prism -- -- This function generates an isomorphism between Maybe (a | -- isn't p a) and a. -- --
--   >>> Map.singleton "hello" Map.empty & at "hello" % non' _Empty % at "world" ?~ "!!!"
--   fromList [("hello",fromList [("world","!!!")])]
--   
-- --
--   >>> Map.fromList [("hello", Map.fromList [("world","!!!")])] & at "hello" % non' _Empty % at "world" .~ Nothing
--   fromList []
--   
non' :: Prism' a () -> Iso' (Maybe a) a -- | anon a p generalizes non a to take any -- value and a predicate. -- --
--   anon a ≡ non' . nearly a
--   
-- -- This function assumes that p a holds True and -- generates an isomorphism between Maybe (a | not (p -- a)) and a. -- --
--   >>> Map.empty & at "hello" % anon Map.empty Map.null % at "world" ?~ "!!!"
--   fromList [("hello",fromList [("world","!!!")])]
--   
-- --
--   >>> Map.fromList [("hello", Map.fromList [("world","!!!")])] & at "hello" % anon Map.empty Map.null % at "world" .~ Nothing
--   fromList []
--   
anon :: a -> (a -> Bool) -> Iso' (Maybe a) a -- | The canonical isomorphism for currying and uncurrying a function. -- --
--   curried = iso curry uncurry
--   
-- --
--   >>> view curried fst 3 4
--   3
--   
curried :: Iso ((a, b) -> c) ((d, e) -> f) (a -> b -> c) (d -> e -> f) -- | The canonical isomorphism for uncurrying and currying a function. -- --
--   uncurried = iso uncurry curry
--   
-- --
--   uncurried = re curried
--   
-- --
--   >>> (view uncurried (+)) (1,2)
--   3
--   
uncurried :: Iso (a -> b -> c) (d -> e -> f) ((a, b) -> c) ((d, e) -> f) -- | The isomorphism for flipping a function. -- --
--   >>> (view flipped (,)) 1 2
--   (2,1)
--   
flipped :: Iso (a -> b -> c) (a' -> b' -> c') (b -> a -> c) (b' -> a' -> c') -- | Given a function that is its own inverse, this gives you an Iso -- using it in both directions. -- --
--   involutedjoin iso
--   
-- --
--   >>> "live" ^. involuted reverse
--   "evil"
--   
-- --
--   >>> "live" & involuted reverse %~ ('d':)
--   "lived"
--   
involuted :: (a -> a) -> Iso' a a -- | This class provides for symmetric bifunctors. class Bifunctor p => Swapped p -- |
--   swapped . swappedid
--   first f . swapped = swapped . second f
--   second g . swapped = swapped . first g
--   bimap f g . swapped = swapped . bimap g f
--   
-- --
--   >>> view swapped (1,2)
--   (2,1)
--   
swapped :: Swapped p => Iso (p a b) (p c d) (p b a) (p d c) -- | Extract the two components of an isomorphism. withIso :: Iso s t a b -> ((s -> a) -> (b -> t) -> r) -> r -- | Based on ala from Conor McBride's work on Epigram. -- -- This version is generalized to accept any Iso, not just a -- newtype. -- --
--   >>> au (coerced1 @Sum) foldMap [1,2,3,4]
--   10
--   
-- -- You may want to think of this combinator as having the following, -- simpler type: -- --
--   au :: Iso s t a b -> ((b -> t) -> e -> s) -> e -> a
--   
au :: Functor f => Iso s t a b -> ((b -> t) -> f s) -> f a -- | The opposite of working over a Setter is working -- under an isomorphism. -- --
--   underover . re
--   
under :: Iso s t a b -> (t -> s) -> b -> a -- | Tag for an iso. data An_Iso :: OpticKind instance Optics.Iso.Swapped (,) instance Optics.Iso.Swapped Data.Either.Either -- | This module defines mapping, which turns an Optic' k -- NoIx s a into an Optic' (MappedOptic k) -- NoIx (f s) (f a), in other words optic operating on values -- in a Functor. module Optics.Mapping -- | Class for optics supporting mapping through a Functor. class MappingOptic k f g s t a b where { -- | Type family that maps an optic to the optic kind produced by -- mapping using it. type family MappedOptic k; } -- | The mapping can be used to lift optic through a Functor. -- --
--   mapping :: Iso    s t a b -> Iso    (f s) (g t) (f a) (g b)
--   mapping :: Lens   s   a   -> Getter (f s)       (f a)
--   mapping :: Getter s   a   -> Getter (f s)       (f a)
--   mapping :: Prism    t   b -> Review       (g t)       (g b)
--   mapping :: Review   t   b -> Review       (g t)       (g b)
--   
mapping :: (MappingOptic k f g s t a b, "mapping" `AcceptsEmptyIndices` is) => Optic k is s t a b -> Optic (MappedOptic k) is (f s) (g t) (f a) (g b) instance (GHC.Base.Functor f, GHC.Base.Functor g) => Optics.Mapping.MappingOptic Optics.Internal.Optic.Types.An_Iso f g s t a b instance (GHC.Base.Functor f, f GHC.Types.~ g, s GHC.Types.~ t, a GHC.Types.~ b) => Optics.Mapping.MappingOptic Optics.Internal.Optic.Types.A_Getter f g s t a b instance (GHC.Base.Functor f, f GHC.Types.~ g, s GHC.Types.~ t, a GHC.Types.~ b) => Optics.Mapping.MappingOptic Optics.Internal.Optic.Types.A_ReversedPrism f g s t a b instance (GHC.Base.Functor f, f GHC.Types.~ g, s GHC.Types.~ t, a GHC.Types.~ b) => Optics.Mapping.MappingOptic Optics.Internal.Optic.Types.A_Lens f g s t a b instance (GHC.Base.Functor f, f GHC.Types.~ g, s GHC.Types.~ t, a GHC.Types.~ b) => Optics.Mapping.MappingOptic Optics.Internal.Optic.Types.A_Review f g s t a b instance (GHC.Base.Functor f, f GHC.Types.~ g, s GHC.Types.~ t, a GHC.Types.~ b) => Optics.Mapping.MappingOptic Optics.Internal.Optic.Types.A_Prism f g s t a b instance (GHC.Base.Functor f, f GHC.Types.~ g, s GHC.Types.~ t, a GHC.Types.~ b) => Optics.Mapping.MappingOptic Optics.Internal.Optic.Types.A_ReversedLens f g s t a b -- | This module defines the AsEmpty class, which provides a -- Prism for a type that may be _Empty. -- -- Note that orphan instances for this class are defined in the -- Optics.Empty module from optics-extra, so if you are -- not simply depending on optics you may wish to import that -- module instead. -- --
--   >>> isn't _Empty [1,2,3]
--   True
--   
-- --
--   >>> case Nothing of { Empty -> True; _ -> False }
--   True
--   
module Optics.Empty.Core -- | Class for types that may be _Empty. class AsEmpty a -- |
--   >>> isn't _Empty [1,2,3]
--   True
--   
_Empty :: AsEmpty a => Prism' a () -- |
--   >>> isn't _Empty [1,2,3]
--   True
--   
_Empty :: (AsEmpty a, Monoid a, Eq a) => Prism' a () -- | Pattern synonym for matching on any type with an AsEmpty -- instance. -- --
--   >>> case Nothing of { Empty -> True; _ -> False }
--   True
--   
pattern Empty :: forall a. AsEmpty a => a instance Optics.Empty.Core.AsEmpty GHC.Types.Ordering instance Optics.Empty.Core.AsEmpty () instance Optics.Empty.Core.AsEmpty Data.Semigroup.Internal.Any instance Optics.Empty.Core.AsEmpty Data.Semigroup.Internal.All instance Optics.Empty.Core.AsEmpty GHC.Event.Internal.Event instance (GHC.Classes.Eq a, GHC.Num.Num a) => Optics.Empty.Core.AsEmpty (Data.Semigroup.Internal.Product a) instance (GHC.Classes.Eq a, GHC.Num.Num a) => Optics.Empty.Core.AsEmpty (Data.Semigroup.Internal.Sum a) instance Optics.Empty.Core.AsEmpty (GHC.Maybe.Maybe a) instance Optics.Empty.Core.AsEmpty (Data.Monoid.Last a) instance Optics.Empty.Core.AsEmpty (Data.Monoid.First a) instance Optics.Empty.Core.AsEmpty a => Optics.Empty.Core.AsEmpty (Data.Semigroup.Internal.Dual a) instance (Optics.Empty.Core.AsEmpty a, Optics.Empty.Core.AsEmpty b) => Optics.Empty.Core.AsEmpty (a, b) instance (Optics.Empty.Core.AsEmpty a, Optics.Empty.Core.AsEmpty b, Optics.Empty.Core.AsEmpty c) => Optics.Empty.Core.AsEmpty (a, b, c) instance Optics.Empty.Core.AsEmpty [a] instance Optics.Empty.Core.AsEmpty (Control.Applicative.ZipList a) instance Optics.Empty.Core.AsEmpty (Data.Map.Internal.Map k a) instance Optics.Empty.Core.AsEmpty (Data.IntMap.Internal.IntMap a) instance Optics.Empty.Core.AsEmpty (Data.Set.Internal.Set a) instance Optics.Empty.Core.AsEmpty Data.IntSet.Internal.IntSet instance Optics.Empty.Core.AsEmpty (Data.Sequence.Internal.Seq a) -- | A Setter S T A B has the ability to lift a function of -- type A -> B over a function of type S -> -- T, applying the function to update all the As contained -- in S. This can be used to set all the As to a -- single value (by lifting a constant function). -- -- This can be seen as a generalisation of fmap, where the type -- S does not need to be a type constructor with A as -- its last parameter. module Optics.Setter -- | Type synonym for a type-modifying setter. type Setter s t a b = Optic A_Setter NoIx s t a b -- | Type synonym for a type-preserving setter. type Setter' s a = Optic' A_Setter NoIx s a -- | Build a setter from a function to modify the element(s), which must -- respect the well-formedness laws. sets :: ((a -> b) -> s -> t) -> Setter s t a b -- | Apply a setter as a modifier. over :: Is k A_Setter => Optic k is s t a b -> (a -> b) -> s -> t -- | Create a Setter for a Functor. -- --
--   over mappedfmap
--   
mapped :: Functor f => Setter (f a) (f b) a b -- | Apply a setter. -- --
--   set o v ≡ over o (const v)
--   
-- --
--   >>> set _1 'x' ('y', 'z')
--   ('x','z')
--   
set :: Is k A_Setter => Optic k is s t a b -> b -> s -> t -- | Apply a setter, strictly. -- -- TODO DOC: what exactly is the strictness property? set' :: Is k A_Setter => Optic k is s t a b -> b -> s -> t -- | Apply a setter as a modifier, strictly. -- -- TODO DOC: what exactly is the strictness property? -- -- Example: -- --
--   f :: Int -> (Int, a) -> (Int, a)
--   f k acc
--     | k > 0     = f (k - 1) $ over' _1 (+1) acc
--     | otherwise = acc
--   
-- -- runs in constant space, but would result in a space leak if used with -- over. -- -- Note that replacing $ with $! or _1 with -- _1' (which amount to the same thing) doesn't help when -- over is used, because the first coordinate of a pair is never -- forced. over' :: Is k A_Setter => Optic k is s t a b -> (a -> b) -> s -> t -- | Tag for a setter. data A_Setter :: OpticKind -- | Defines some infix operators for optics operations. This is a -- deliberately small collection. -- -- If you like operators, you may also wish to import -- Optics.State.Operators from the optics-extra -- package. module Optics.Operators -- | Flipped infix version of view. (^.) :: Is k A_Getter => s -> Optic' k is s a -> a infixl 8 ^. -- | Flipped infix version of toListOf. (^..) :: Is k A_Fold => s -> Optic' k is s a -> [a] infixl 8 ^.. -- | Flipped infix version of preview. (^?) :: Is k An_AffineFold => s -> Optic' k is s a -> Maybe a infixl 8 ^? -- | Infix version of review. (#) :: Is k A_Review => Optic' k is t b -> b -> t infixr 8 # -- | Infix version of over. (%~) :: Is k A_Setter => Optic k is s t a b -> (a -> b) -> s -> t infixr 4 %~ -- | Infix version of over'. (%!~) :: Is k A_Setter => Optic k is s t a b -> (a -> b) -> s -> t infixr 4 %!~ -- | Infix version of set. (.~) :: Is k A_Setter => Optic k is s t a b -> b -> s -> t infixr 4 .~ -- | Infix version of set'. (!~) :: Is k A_Setter => Optic k is s t a b -> b -> s -> t infixr 4 !~ -- | Set the target of a Setter to Just a value. -- --
--   o ?~ b ≡ set o (Just b)
--   
-- --
--   >>> Nothing & equality ?~ 'x'
--   Just 'x'
--   
-- --
--   >>> Map.empty & at 3 ?~ 'x'
--   fromList [(3,'x')]
--   
(?~) :: Is k A_Setter => Optic k is s t a (Maybe b) -> b -> s -> t infixr 4 ?~ -- | Strict version of (?~). (?!~) :: Is k A_Setter => Optic k is s t a (Maybe b) -> b -> s -> t infixr 4 ?!~ module Optics.Operators.Unsafe -- | Perform an *UNSAFE* head of an affine fold assuming that it is -- there. -- --
--   >>> Left 4 ^?! _Left
--   4
--   
-- --
--   >>> "world" ^?! ix 3
--   'l'
--   
-- --
--   >>> [] ^?! _head
--   *** Exception: (^?!): empty affine fold
--   ...
--   
(^?!) :: (HasCallStack, Is k An_AffineFold) => s -> Optic' k is s a -> a infixl 8 ^?! -- | This module provides optics for Map and Set-like -- containers, including an AffineTraversal to traverse a key in a -- map or an element of a sequence: -- --
--   >>> preview (ix 1) ['a','b','c']
--   Just 'b'
--   
-- -- a Lens to get, set or delete a key in a map: -- --
--   >>> set (at 0) (Just 'b') (Map.fromList [(0, 'a')])
--   fromList [(0,'b')]
--   
-- -- and a Lens to insert or remove an element of a set: -- --
--   >>> IntSet.fromList [1,2,3,4] & contains 3 .~ False
--   fromList [1,2,4]
--   
-- -- The Optics.At module from optics-extra provides -- additional instances of the classes defined here. module Optics.At.Core -- | Type family that takes a key-value container type and returns the type -- of keys (indices) into the container, for example Index -- (Map k a) ~ k. This is shared by Ixed, At -- and Contains. type family Index (s :: Type) :: Type -- | Type family that takes a key-value container type and returns the type -- of values stored in the container, for example IxValue -- (Map k a) ~ a. This is shared by both Ixed and -- At. type family IxValue (m :: Type) :: Type -- | Provides a simple AffineTraversal lets you traverse the value -- at a given key in a Map or element at an ordinal position in a -- list or Seq. class Ixed m where { -- | Type family that takes a key-value container type and returns the kind -- of optic to index into it. For most containers, it's -- An_AffineTraversal, Representable (Naperian) -- containers it is A_Lens, and multi-maps would have -- A_Traversal. type family IxKind (m :: Type) :: OpticKind; type IxKind m = An_AffineTraversal; } -- | NB: Setting the value of this AffineTraversal will only -- set the value in at if it is already present. -- -- If you want to be able to insert missing values, you want -- at. -- --
--   >>> [1,2,3,4] & ix 2 %~ (*10)
--   [1,2,30,4]
--   
-- --
--   >>> "abcd" & ix 2 .~ 'e'
--   "abed"
--   
-- --
--   >>> "abcd" ^? ix 2
--   Just 'c'
--   
-- --
--   >>> [] ^? ix 2
--   Nothing
--   
ix :: Ixed m => Index m -> Optic' (IxKind m) NoIx m (IxValue m) -- | NB: Setting the value of this AffineTraversal will only -- set the value in at if it is already present. -- -- If you want to be able to insert missing values, you want -- at. -- --
--   >>> [1,2,3,4] & ix 2 %~ (*10)
--   [1,2,30,4]
--   
-- --
--   >>> "abcd" & ix 2 .~ 'e'
--   "abed"
--   
-- --
--   >>> "abcd" ^? ix 2
--   Just 'c'
--   
-- --
--   >>> [] ^? ix 2
--   Nothing
--   
ix :: (Ixed m, At m, IxKind m ~ An_AffineTraversal) => Index m -> Optic' (IxKind m) NoIx m (IxValue m) -- | A definition of ix for types with an At instance. This -- is the default if you don't specify a definition for ix. ixAt :: At m => Index m -> AffineTraversal' m (IxValue m) -- | At provides a Lens that can be used to read, write or -- delete the value associated with a key in a Map-like container -- on an ad hoc basis. -- -- An instance of At should satisfy: -- --
--   ix k ≡ at k % _Just
--   
class (Ixed m, IxKind m ~ An_AffineTraversal) => At m -- |
--   >>> Map.fromList [(1,"world")] ^. at 1
--   Just "world"
--   
-- --
--   >>> at 1 ?~ "hello" $ Map.empty
--   fromList [(1,"hello")]
--   
-- -- Note: Usage of this function might introduce space leaks if -- you're not careful to make sure that values put inside the Just -- constructor are evaluated. To force the values and avoid such leaks, -- use at' instead. -- -- Note: Map-like containers form a reasonable instance, -- but not Array-like ones, where you cannot satisfy the -- Lens laws. at :: At m => Index m -> Lens' m (Maybe (IxValue m)) -- | Version of at strict in the value inside the Just -- constructor. -- -- Example: -- --
--   >>> (at () .~ Just (error "oops") $ Nothing) `seq` ()
--   ()
--   
-- --
--   >>> (at' () .~ Just (error "oops") $ Nothing) `seq` ()
--   *** Exception: oops
--   ...
--   
-- --
--   >>> view (at ()) (Just $ error "oops") `seq` ()
--   ()
--   
-- --
--   >>> view (at' ()) (Just $ error "oops") `seq` ()
--   *** Exception: oops
--   ...
--   
-- -- It also works as expected for other data structures: -- --
--   >>> (at 1 .~ Just (error "oops") $ Map.empty) `seq` ()
--   ()
--   
-- --
--   >>> (at' 1 .~ Just (error "oops") $ Map.empty) `seq` ()
--   *** Exception: oops
--   ...
--   
at' :: At m => Index m -> Lens' m (Maybe (IxValue m)) -- | Delete the value associated with a key in a Map-like container -- --
--   sans k = at k .~ Nothing
--   
sans :: At m => Index m -> m -> m -- | This class provides a simple Lens that lets you view (and -- modify) information about whether or not a container contains a given -- Index. Instances are provided for Set-like containers -- only. class Contains m -- |
--   >>> IntSet.fromList [1,2,3,4] ^. contains 3
--   True
--   
-- --
--   >>> IntSet.fromList [1,2,3,4] ^. contains 5
--   False
--   
-- --
--   >>> IntSet.fromList [1,2,3,4] & contains 3 .~ False
--   fromList [1,2,4]
--   
contains :: Contains m => Index m -> Lens' m Bool instance GHC.Classes.Eq e => Optics.At.Core.Ixed (e -> a) instance Optics.At.Core.Ixed (GHC.Maybe.Maybe a) instance Optics.At.Core.Ixed [a] instance Optics.At.Core.Ixed (GHC.Base.NonEmpty a) instance Optics.At.Core.Ixed (Data.Functor.Identity.Identity a) instance Optics.At.Core.Ixed (Data.Tree.Tree a) instance Optics.At.Core.Ixed (Data.Sequence.Internal.Seq a) instance Optics.At.Core.Ixed (Data.IntMap.Internal.IntMap a) instance GHC.Classes.Ord k => Optics.At.Core.Ixed (Data.Map.Internal.Map k a) instance GHC.Classes.Ord k => Optics.At.Core.Ixed (Data.Set.Internal.Set k) instance Optics.At.Core.Ixed Data.IntSet.Internal.IntSet instance GHC.Ix.Ix i => Optics.At.Core.Ixed (GHC.Arr.Array i e) instance (Data.Array.Base.IArray Data.Array.Base.UArray e, GHC.Ix.Ix i) => Optics.At.Core.Ixed (Data.Array.Base.UArray i e) instance (a0 GHC.Types.~ a1) => Optics.At.Core.Ixed (a0, a1) instance (a0 GHC.Types.~ a1, a0 GHC.Types.~ a2) => Optics.At.Core.Ixed (a0, a1, a2) instance (a0 GHC.Types.~ a1, a0 GHC.Types.~ a2, a0 GHC.Types.~ a3) => Optics.At.Core.Ixed (a0, a1, a2, a3) instance (a0 GHC.Types.~ a1, a0 GHC.Types.~ a2, a0 GHC.Types.~ a3, a0 GHC.Types.~ a4) => Optics.At.Core.Ixed (a0, a1, a2, a3, a4) instance (a0 GHC.Types.~ a1, a0 GHC.Types.~ a2, a0 GHC.Types.~ a3, a0 GHC.Types.~ a4, a0 GHC.Types.~ a5) => Optics.At.Core.Ixed (a0, a1, a2, a3, a4, a5) instance (a0 GHC.Types.~ a1, a0 GHC.Types.~ a2, a0 GHC.Types.~ a3, a0 GHC.Types.~ a4, a0 GHC.Types.~ a5, a0 GHC.Types.~ a6) => Optics.At.Core.Ixed (a0, a1, a2, a3, a4, a5, a6) instance (a0 GHC.Types.~ a1, a0 GHC.Types.~ a2, a0 GHC.Types.~ a3, a0 GHC.Types.~ a4, a0 GHC.Types.~ a5, a0 GHC.Types.~ a6, a0 GHC.Types.~ a7) => Optics.At.Core.Ixed (a0, a1, a2, a3, a4, a5, a6, a7) instance (a0 GHC.Types.~ a1, a0 GHC.Types.~ a2, a0 GHC.Types.~ a3, a0 GHC.Types.~ a4, a0 GHC.Types.~ a5, a0 GHC.Types.~ a6, a0 GHC.Types.~ a7, a0 GHC.Types.~ a8) => Optics.At.Core.Ixed (a0, a1, a2, a3, a4, a5, a6, a7, a8) instance Optics.At.Core.At (GHC.Maybe.Maybe a) instance Optics.At.Core.At (Data.IntMap.Internal.IntMap a) instance GHC.Classes.Ord k => Optics.At.Core.At (Data.Map.Internal.Map k a) instance Optics.At.Core.At Data.IntSet.Internal.IntSet instance GHC.Classes.Ord k => Optics.At.Core.At (Data.Set.Internal.Set k) instance Optics.At.Core.Contains Data.IntSet.Internal.IntSet instance GHC.Classes.Ord a => Optics.At.Core.Contains (Data.Set.Internal.Set a) module Optics.Arrow class Arrow arr => ArrowOptic k arr -- | Turn an optic into an arrow transformer. overA :: ArrowOptic k arr => Optic k is s t a b -> arr a b -> arr s t -- | Run an arrow command and use the output to set all the targets of an -- optic to the result. -- --
--   runKleisli action ((), (), ()) where
--     action =      assignA _1 (Kleisli (const getVal1))
--              >>> assignA _2 (Kleisli (const getVal2))
--              >>> assignA _3 (Kleisli (const getVal3))
--     getVal1 :: Either String Int
--     getVal1 = ...
--     getVal2 :: Either String Bool
--     getVal2 = ...
--     getVal3 :: Either String Char
--     getVal3 = ...
--   
-- -- has the type Either String (Int, Bool, -- Char) assignA :: (Is k A_Setter, Arrow arr) => Optic k is s t a b -> arr s b -> arr s t instance Control.Arrow.Arrow arr => Optics.Arrow.ArrowOptic Optics.Internal.Optic.Types.An_Iso arr instance Control.Arrow.Arrow arr => Optics.Arrow.ArrowOptic Optics.Internal.Optic.Types.A_Lens arr instance Control.Arrow.ArrowChoice arr => Optics.Arrow.ArrowOptic Optics.Internal.Optic.Types.A_Prism arr instance Control.Arrow.ArrowChoice arr => Optics.Arrow.ArrowOptic Optics.Internal.Optic.Types.An_AffineTraversal arr instance Control.Category.Category p => Control.Category.Category (Optics.Arrow.WrappedArrow p i) instance Control.Arrow.Arrow p => Control.Arrow.Arrow (Optics.Arrow.WrappedArrow p i) instance Control.Arrow.Arrow p => Data.Profunctor.Indexed.Profunctor (Optics.Arrow.WrappedArrow p) instance Control.Arrow.Arrow p => Data.Profunctor.Indexed.Strong (Optics.Arrow.WrappedArrow p) instance Control.Arrow.ArrowChoice p => Data.Profunctor.Indexed.Choice (Optics.Arrow.WrappedArrow p) instance Control.Arrow.ArrowChoice p => Data.Profunctor.Indexed.Visiting (Optics.Arrow.WrappedArrow p) -- | This module defines optics for constructing and manipulating finite -- Sets. module Data.Set.Optics -- | This Setter can be used to change the type of a Set by -- mapping the elements to new values. -- -- Sadly, you can't create a valid Traversal for a Set, but -- you can manipulate it by reading using folded and reindexing it -- via setmapped. -- --
--   >>> over setmapped (+1) (Set.fromList [1,2,3,4])
--   fromList [2,3,4,5]
--   
setmapped :: Ord b => Setter (Set a) (Set b) a b -- | Construct a set from a fold. -- --
--   >>> setOf folded ["hello","world"]
--   fromList ["hello","world"]
--   
-- --
--   >>> setOf (folded % _2) [("hello",1),("world",2),("!!!",3)]
--   fromList [1,2,3]
--   
setOf :: (Is k A_Fold, Ord a) => Optic' k is s a -> s -> Set a -- | This module defines optics for constructing and manipulating finite -- IntSets. module Data.IntSet.Optics -- | IntSet isn't Foldable, but this Fold can be used to access the -- members of an IntSet. -- --
--   >>> sumOf members $ setOf folded [1,2,3,4]
--   10
--   
members :: Fold IntSet Int -- | This Setter can be used to change the type of a IntSet -- by mapping the elements to new values. -- -- Sadly, you can't create a valid Traversal for an IntSet, -- but you can manipulate it by reading using folded and -- reindexing it via setmapped. -- --
--   >>> over setmapped (+1) (IntSet.fromList [1,2,3,4])
--   fromList [2,3,4,5]
--   
setmapped :: Setter' IntSet Int -- | Construct an IntSet from a fold. -- --
--   >>> setOf folded [1,2,3,4]
--   fromList [1,2,3,4]
--   
-- --
--   >>> setOf (folded % _2) [("hello",1),("world",2),("!!!",3)]
--   fromList [1,2,3]
--   
setOf :: Is k A_Fold => Optic' k is s Int -> s -> IntSet -- | A Traversal lifts an effectful operation on elements to act on -- structures containing those elements. -- -- That is, given a function op :: A -> F B where F -- is Applicative, a Traversal S T A B can produce -- a function S -> F T that applies op to all the -- As contained in the S. -- -- This can be seen as a generalisation of traverse, where the -- type S does not need to be a type constructor with A -- as the last parameter. -- -- A Lens is a Traversal that acts on a single value. -- -- A close relative is the AffineTraversal, which is a -- Traversal that acts on at most one value. module Optics.Traversal -- | Type synonym for a type-modifying traversal. type Traversal s t a b = Optic A_Traversal NoIx s t a b -- | Type synonym for a type-preserving traversal. type Traversal' s a = Optic' A_Traversal NoIx s a -- | Build a traversal from the van Laarhoven representation. -- --
--   traversalVL . traverseOfid
--   traverseOf . traversalVLid
--   
traversalVL :: TraversalVL s t a b -> Traversal s t a b -- | Map each element of a structure targeted by a Traversal, -- evaluate these actions from left to right, and collect the results. traverseOf :: (Is k A_Traversal, Applicative f) => Optic k is s t a b -> (a -> f b) -> s -> f t -- | Construct a Traversal via the Traversable class. -- --
--   traverseOf traversed = traverse
--   
traversed :: Traversable t => Traversal (t a) (t b) a b -- | Traverse both parts of a Bitraversable container with matching -- types. -- -- Note: for traversing a pair or an Either it's better to -- use each and chosen respectively to reduce potential for -- bugs due to too much polymorphism. -- --
--   >>> (1,2) & both %~ (*10)
--   (10,20)
--   
-- --
--   >>> over both length ("hello","world")
--   (5,5)
--   
-- --
--   >>> foldOf both ("hello","world")
--   "helloworld"
--   
both :: Bitraversable r => Traversal (r a a) (r b b) a b -- | A version of traverseOf with the arguments flipped. forOf :: (Is k A_Traversal, Applicative f) => Optic k is s t a b -> s -> (a -> f b) -> f t -- | Evaluate each action in the structure from left to right, and collect -- the results. -- --
--   >>> sequenceOf each ([1,2],[3,4])
--   [(1,3),(1,4),(2,3),(2,4)]
--   
-- --
--   sequencesequenceOf traversedtraverse id
--   sequenceOf o ≡ traverseOf o id
--   
sequenceOf :: (Is k A_Traversal, Applicative f) => Optic k is s t (f b) b -> s -> f t -- | This generalizes transpose to an arbitrary Traversal. -- -- Note: transpose handles ragged inputs more intelligently, but -- for non-ragged inputs: -- --
--   >>> transposeOf traversed [[1,2,3],[4,5,6]]
--   [[1,4],[2,5],[3,6]]
--   
-- --
--   transposetransposeOf traverse
--   
transposeOf :: Is k A_Traversal => Optic k is s t [a] a -> s -> [t] -- | This generalizes mapAccumR to an arbitrary Traversal. -- --
--   mapAccumRmapAccumROf traversed
--   
-- -- mapAccumROf accumulates State from right to left. mapAccumROf :: Is k A_Traversal => Optic k is s t a b -> (acc -> a -> (b, acc)) -> acc -> s -> (t, acc) -- | This generalizes mapAccumL to an arbitrary Traversal. -- --
--   mapAccumLmapAccumLOf traverse
--   
-- -- mapAccumLOf accumulates State from left to right. mapAccumLOf :: Is k A_Traversal => Optic k is s t a b -> (acc -> a -> (b, acc)) -> acc -> s -> (t, acc) -- | This permits the use of scanr1 over an arbitrary -- Traversal. -- --
--   scanr1scanr1Of traversed
--   
scanr1Of :: Is k A_Traversal => Optic k is s t a a -> (a -> a -> a) -> s -> t -- | This permits the use of scanl1 over an arbitrary -- Traversal. -- --
--   scanl1scanl1Of traversed
--   
scanl1Of :: Is k A_Traversal => Optic k is s t a a -> (a -> a -> a) -> s -> t -- | Try to map a function over this Traversal, returning Nothing if -- the traversal has no targets. -- --
--   >>> failover (element 3) (*2) [1,2]
--   Nothing
--   
-- --
--   >>> failover _Left (*2) (Right 4)
--   Nothing
--   
-- --
--   >>> failover _Right (*2) (Right 4)
--   Just (Right 8)
--   
failover :: Is k A_Traversal => Optic k is s t a b -> (a -> b) -> s -> Maybe t -- | Version of failover strict in the application of f. failover' :: Is k A_Traversal => Optic k is s t a b -> (a -> b) -> s -> Maybe t -- | This allows you to traverse the elements of a traversal in the -- opposite order. backwards :: Is k A_Traversal => Optic k is s t a b -> Traversal s t a b -- | partsOf turns a Traversal into a Lens. -- -- Note: You should really try to maintain the invariant of the -- number of children in the list. -- --
--   >>> ('a','b','c') & partsOf each .~ ['x','y','z']
--   ('x','y','z')
--   
-- -- Any extras will be lost. If you do not supply enough, then the -- remainder will come from the original structure. -- --
--   >>> ('a','b','c') & partsOf each .~ ['w','x','y','z']
--   ('w','x','y')
--   
-- --
--   >>> ('a','b','c') & partsOf each .~ ['x','y']
--   ('x','y','c')
--   
-- --
--   >>> ('b', 'a', 'd', 'c') & partsOf each %~ sort
--   ('a','b','c','d')
--   
-- -- So technically, this is only a Lens if you do not change the -- number of results it returns. partsOf :: forall k is s t a. Is k A_Traversal => Optic k is s t a a -> Lens s t [a] [a] -- | Convert a traversal to an AffineTraversal that visits the first -- element of the original traversal. -- -- For the fold version see pre. -- --
--   >>> "foo" & singular traversed .~ 'z'
--   "zoo"
--   
singular :: forall k is s a. Is k A_Traversal => Optic' k is s a -> AffineTraversal' s a -- | Combine two disjoint traversals into one. -- --
--   >>> over (_1 % _Just `adjoin` _2 % _Right) not (Just True, Right False)
--   (Just False,Right True)
--   
-- -- Note: if the argument traversals are not disjoint, the result -- will not respect the Traversal laws, because it will visit the -- same element multiple times. See section 7 of Understanding -- Idiomatic Traversals Backwards and Forwards by Bird et al. for why -- this is illegal. -- --
--   >>> view (partsOf (each `adjoin` _1)) ('x','y')
--   "xyx"
--   
--   >>> set (partsOf (each `adjoin` _1)) "abc" ('x','y')
--   ('c','b')
--   
-- -- For the Fold version see summing. adjoin :: (Is k A_Traversal, Is l A_Traversal) => Optic' k is s a -> Optic' l js s a -> Traversal' s a infixr 6 `adjoin` -- | Tag for a traversal. data A_Traversal :: OpticKind -- | Type synonym for a type-modifying van Laarhoven traversal. type TraversalVL s t a b = forall f. Applicative f => (a -> f b) -> s -> f t -- | Type synonym for a type-preserving van Laarhoven traversal. type TraversalVL' s a = TraversalVL s s a a -- | An IxTraversal is an indexed version of a Traversal. See -- the "Indexed optics" section of the overview documentation in the -- Optics module of the main optics package for more -- details on indexed optics. module Optics.IxTraversal -- | Type synonym for a type-modifying indexed traversal. type IxTraversal i s t a b = Optic A_Traversal (WithIx i) s t a b -- | Type synonym for a type-preserving indexed traversal. type IxTraversal' i s a = Optic' A_Traversal (WithIx i) s a -- | Build an indexed traversal from the van Laarhoven representation. -- --
--   itraversalVL . itraverseOfid
--   itraverseOf . itraversalVLid
--   
itraversalVL :: IxTraversalVL i s t a b -> IxTraversal i s t a b -- | Map each element of a structure targeted by an IxTraversal -- (supplying the index), evaluate these actions from left to right, and -- collect the results. -- -- This yields the van Laarhoven representation of an indexed traversal. itraverseOf :: (Is k A_Traversal, Applicative f, is `HasSingleIndex` i) => Optic k is s t a b -> (i -> a -> f b) -> s -> f t -- | Indexed traversal via the TraversableWithIndex class. -- --
--   itraverseOf itraverseditraverse
--   
-- --
--   >>> iover (itraversed <%> itraversed) (,) ["ab", "cd"]
--   [[((0,0),'a'),((0,1),'b')],[((1,0),'c'),((1,1),'d')]]
--   
itraversed :: TraversableWithIndex i f => IxTraversal i (f a) (f b) a b -- | This is the trivial empty IxAffineTraversal, i.e. the optic -- that targets no substructures. -- -- This is the identity element when a Fold, AffineFold, -- IxFold, IxAffineFold, Traversal or -- IxTraversal is viewed as a monoid. -- --
--   >>> 6 & ignored %~ absurd
--   6
--   
ignored :: IxAffineTraversal i s s a b -- | Traverse selected elements of a Traversal where their ordinal -- positions match a predicate. elementsOf :: Is k A_Traversal => Optic k is s t a a -> (Int -> Bool) -> IxTraversal Int s t a a -- | Traverse elements of a Traversable container where their -- ordinal positions match a predicate. -- --
--   elementselementsOf traverse
--   
elements :: Traversable f => (Int -> Bool) -> IxTraversal' Int (f a) a -- | Traverse the nth element of a Traversal if it exists. elementOf :: Is k A_Traversal => Optic' k is s a -> Int -> IxAffineTraversal' Int s a -- | Traverse the nth element of a Traversable container. -- --
--   elementelementOf traversed
--   
element :: Traversable f => Int -> IxAffineTraversal' Int (f a) a -- | A version of itraverseOf with the arguments flipped. iforOf :: (Is k A_Traversal, Applicative f, is `HasSingleIndex` i) => Optic k is s t a b -> s -> (i -> a -> f b) -> f t -- | Generalizes mapAccumL to an arbitrary IxTraversal. -- -- imapAccumLOf accumulates state from left to right. -- --
--   mapAccumLOf o ≡ imapAccumLOf o . const
--   
imapAccumLOf :: (Is k A_Traversal, is `HasSingleIndex` i) => Optic k is s t a b -> (i -> acc -> a -> (b, acc)) -> acc -> s -> (t, acc) -- | Generalizes mapAccumR to an arbitrary IxTraversal. -- -- imapAccumROf accumulates state from right to left. -- --
--   mapAccumROf o ≡ imapAccumROf o . const
--   
imapAccumROf :: (Is k A_Traversal, is `HasSingleIndex` i) => Optic k is s t a b -> (i -> acc -> a -> (b, acc)) -> acc -> s -> (t, acc) -- | This permits the use of scanl1 over an arbitrary -- IxTraversal. iscanl1Of :: (Is k A_Traversal, is `HasSingleIndex` i) => Optic k is s t a a -> (i -> a -> a -> a) -> s -> t -- | This permits the use of scanr1 over an arbitrary -- IxTraversal. iscanr1Of :: (Is k A_Traversal, is `HasSingleIndex` i) => Optic k is s t a a -> (i -> a -> a -> a) -> s -> t -- | Try to map a function which uses the index over this -- IxTraversal, returning Nothing if the IxTraversal -- has no targets. ifailover :: (Is k A_Traversal, is `HasSingleIndex` i) => Optic k is s t a b -> (i -> a -> b) -> s -> Maybe t -- | Version of ifailover strict in the application of the function. ifailover' :: (Is k A_Traversal, is `HasSingleIndex` i) => Optic k is s t a b -> (i -> a -> b) -> s -> Maybe t -- | Filter results of an IxTraversal that don't satisfy a predicate -- on the indices. -- --
--   >>> toListOf (itraversed %& indices even) "foobar"
--   "foa"
--   
indices :: (Is k A_Traversal, is `HasSingleIndex` i) => (i -> Bool) -> Optic k is s t a a -> IxTraversal i s t a a -- | This allows you to traverse the elements of an indexed -- traversal in the opposite order. ibackwards :: (Is k A_Traversal, is `HasSingleIndex` i) => Optic k is s t a b -> IxTraversal i s t a b -- | An indexed version of partsOf that receives the entire list of -- indices as its indices. ipartsOf :: forall k is i s t a. (Is k A_Traversal, is `HasSingleIndex` i) => Optic k is s t a a -> IxLens [i] s t [a] [a] -- | Convert an indexed traversal to an IxAffineTraversal that -- visits the first element of the original traversal. -- -- For the fold version see ipre. -- --
--   >>> [1,2,3] & iover (isingular itraversed) (-)
--   [-1,2,3]
--   
isingular :: forall k is i s a. (Is k A_Traversal, is `HasSingleIndex` i) => Optic' k is s a -> IxAffineTraversal' i s a -- | Combine two disjoint indexed traversals into one. -- --
--   >>> iover (_1 % itraversed `iadjoin` _2 % itraversed) (+) ([0, 0, 0], (3, 5))
--   ([0,1,2],(3,8))
--   
-- -- Note: if the argument traversals are not disjoint, the result -- will not respect the IxTraversal laws, because it will visit -- the same element multiple times. See section 7 of Understanding -- Idiomatic Traversals Backwards and Forwards by Bird et al. for why -- this is illegal. -- --
--   >>> iview (ipartsOf (each `iadjoin` each)) ("x","y")
--   ([0,1,0,1],["x","y","x","y"])
--   
--   >>> iset (ipartsOf (each `iadjoin` each)) (const ["a","b","c","d"]) ("x","y")
--   ("c","d")
--   
-- -- For the IxFold version see isumming. iadjoin :: (Is k A_Traversal, Is l A_Traversal, is `HasSingleIndex` i) => Optic' k is s a -> Optic' l is s a -> IxTraversal' i s a infixr 6 `iadjoin` -- | Tag for a traversal. data A_Traversal :: OpticKind -- | Type synonym for a type-modifying van Laarhoven indexed traversal. type IxTraversalVL i s t a b = forall f. Applicative f => (i -> a -> f b) -> s -> f t -- | Type synonym for a type-preserving van Laarhoven indexed traversal. type IxTraversalVL' i s a = IxTraversalVL i s s a a -- | A Traversable with an additional index. -- -- An instance must satisfy a (modified) form of the Traversable -- laws: -- --
--   itraverse (const Identity) ≡ Identity
--   fmap (itraverse f) . itraverse g ≡ getCompose . itraverse (\i -> Compose . fmap (f i) . g i)
--   
class (FunctorWithIndex i t, FoldableWithIndex i t, Traversable t) => TraversableWithIndex i (t :: Type -> Type) | t -> i -- | Traverse an indexed container. -- --
--   itraverseitraverseOf itraversed
--   
itraverse :: (TraversableWithIndex i t, Applicative f) => (i -> a -> f b) -> t a -> f (t b) -- | This module defines the Each class, which provides an -- IxTraversal that extracts each element of a (potentially -- monomorphic) container. -- -- Note that orphan instances for this class are defined in the -- Optics.Each module from optics-extra, so if you are -- not simply depending on optics you may wish to import that -- module instead. module Optics.Each.Core -- | Extract each element of a (potentially monomorphic) container. -- --
--   >>> over each (*10) (1,2,3)
--   (10,20,30)
--   
-- --
--   >>> iover each (\i a -> a*10 + succ i) (1,2,3)
--   (11,22,33)
--   
class Each i s t a b | s -> i a, t -> i b, s b -> t, t a -> s each :: Each i s t a b => IxTraversal i s t a b each :: (Each i s t a b, TraversableWithIndex i g, s ~ g a, t ~ g b) => IxTraversal i s t a b instance (a GHC.Types.~ a1, b GHC.Types.~ b1) => Optics.Each.Core.Each GHC.Types.Int (a, a1) (b, b1) a b instance (a GHC.Types.~ a1, a GHC.Types.~ a2, b GHC.Types.~ b1, b GHC.Types.~ b2) => Optics.Each.Core.Each GHC.Types.Int (a, a1, a2) (b, b1, b2) a b instance (a GHC.Types.~ a1, a GHC.Types.~ a2, a GHC.Types.~ a3, b GHC.Types.~ b1, b GHC.Types.~ b2, b GHC.Types.~ b3) => Optics.Each.Core.Each GHC.Types.Int (a, a1, a2, a3) (b, b1, b2, b3) a b instance (a GHC.Types.~ a1, a GHC.Types.~ a2, a GHC.Types.~ a3, a GHC.Types.~ a4, b GHC.Types.~ b1, b GHC.Types.~ b2, b GHC.Types.~ b3, b GHC.Types.~ b4) => Optics.Each.Core.Each GHC.Types.Int (a, a1, a2, a3, a4) (b, b1, b2, b3, b4) a b instance (a GHC.Types.~ a1, a GHC.Types.~ a2, a GHC.Types.~ a3, a GHC.Types.~ a4, a GHC.Types.~ a5, b GHC.Types.~ b1, b GHC.Types.~ b2, b GHC.Types.~ b3, b GHC.Types.~ b4, b GHC.Types.~ b5) => Optics.Each.Core.Each GHC.Types.Int (a, a1, a2, a3, a4, a5) (b, b1, b2, b3, b4, b5) a b instance (a GHC.Types.~ a1, a GHC.Types.~ a2, a GHC.Types.~ a3, a GHC.Types.~ a4, a GHC.Types.~ a5, a GHC.Types.~ a6, b GHC.Types.~ b1, b GHC.Types.~ b2, b GHC.Types.~ b3, b GHC.Types.~ b4, b GHC.Types.~ b5, b GHC.Types.~ b6) => Optics.Each.Core.Each GHC.Types.Int (a, a1, a2, a3, a4, a5, a6) (b, b1, b2, b3, b4, b5, b6) a b instance (a GHC.Types.~ a1, a GHC.Types.~ a2, a GHC.Types.~ a3, a GHC.Types.~ a4, a GHC.Types.~ a5, a GHC.Types.~ a6, a GHC.Types.~ a7, b GHC.Types.~ b1, b GHC.Types.~ b2, b GHC.Types.~ b3, b GHC.Types.~ b4, b GHC.Types.~ b5, b GHC.Types.~ b6, b GHC.Types.~ b7) => Optics.Each.Core.Each GHC.Types.Int (a, a1, a2, a3, a4, a5, a6, a7) (b, b1, b2, b3, b4, b5, b6, b7) a b instance (a GHC.Types.~ a1, a GHC.Types.~ a2, a GHC.Types.~ a3, a GHC.Types.~ a4, a GHC.Types.~ a5, a GHC.Types.~ a6, a GHC.Types.~ a7, a GHC.Types.~ a8, b GHC.Types.~ b1, b GHC.Types.~ b2, b GHC.Types.~ b3, b GHC.Types.~ b4, b GHC.Types.~ b5, b GHC.Types.~ b6, b GHC.Types.~ b7, b GHC.Types.~ b8) => Optics.Each.Core.Each GHC.Types.Int (a, a1, a2, a3, a4, a5, a6, a7, a8) (b, b1, b2, b3, b4, b5, b6, b7, b8) a b instance (a GHC.Types.~ a1, a GHC.Types.~ a2, a GHC.Types.~ a3, a GHC.Types.~ a4, a GHC.Types.~ a5, a GHC.Types.~ a6, a GHC.Types.~ a7, a GHC.Types.~ a8, a GHC.Types.~ a9, b GHC.Types.~ b1, b GHC.Types.~ b2, b GHC.Types.~ b3, b GHC.Types.~ b4, b GHC.Types.~ b5, b GHC.Types.~ b6, b GHC.Types.~ b7, b GHC.Types.~ b8, b GHC.Types.~ b9) => Optics.Each.Core.Each GHC.Types.Int (a, a1, a2, a3, a4, a5, a6, a7, a8, a9) (b, b1, b2, b3, b4, b5, b6, b7, b8, b9) a b instance (a GHC.Types.~ a', b GHC.Types.~ b') => Optics.Each.Core.Each (Data.Either.Either () ()) (Data.Either.Either a a') (Data.Either.Either b b') a b instance Optics.Each.Core.Each (Data.Either.Either () ()) (Data.Complex.Complex a) (Data.Complex.Complex b) a b instance (k GHC.Types.~ k') => Optics.Each.Core.Each k (Data.Map.Internal.Map k a) (Data.Map.Internal.Map k' b) a b instance Optics.Each.Core.Each GHC.Types.Int (Data.IntMap.Internal.IntMap a) (Data.IntMap.Internal.IntMap b) a b instance Optics.Each.Core.Each GHC.Types.Int [a] [b] a b instance Optics.Each.Core.Each GHC.Types.Int (GHC.Base.NonEmpty a) (GHC.Base.NonEmpty b) a b instance Optics.Each.Core.Each () (Data.Functor.Identity.Identity a) (Data.Functor.Identity.Identity b) a b instance Optics.Each.Core.Each () (GHC.Maybe.Maybe a) (GHC.Maybe.Maybe b) a b instance Optics.Each.Core.Each GHC.Types.Int (Data.Sequence.Internal.Seq a) (Data.Sequence.Internal.Seq b) a b instance Optics.Each.Core.Each [GHC.Types.Int] (Data.Tree.Tree a) (Data.Tree.Tree b) a b instance (GHC.Ix.Ix i, i GHC.Types.~ j) => Optics.Each.Core.Each i (GHC.Arr.Array i a) (GHC.Arr.Array j b) a b module Optics.Internal.Generic -- | Convert from the data type to its representation (or back) -- --
--   >>> view (generic % re generic) "hello" :: String
--   "hello"
--   
generic :: (Generic a, Generic b) => Iso a b (Rep a x) (Rep b y) -- | Convert from the data type to its representation (or back) generic1 :: (Generic1 f, Generic1 g) => Iso (f x) (g y) (Rep1 f x) (Rep1 g y) _V1 :: Lens (V1 s) (V1 t) a b _U1 :: Iso (U1 p) (U1 q) () () _Par1 :: Iso (Par1 p) (Par1 q) p q _Rec1 :: Iso (Rec1 f p) (Rec1 g q) (f p) (g q) _K1 :: Iso (K1 i c p) (K1 j d q) c d _M1 :: Iso (M1 i c f p) (M1 j d g q) (f p) (g q) _L1 :: Prism ((a :+: c) t) ((b :+: c) t) (a t) (b t) _R1 :: Prism ((c :+: a) t) ((c :+: b) t) (a t) (b t) class GFieldImpl (name :: Symbol) s t a b | name s -> a gfieldImpl :: GFieldImpl name s t a b => Lens s t a b class GSetFieldSum (path :: PathTree Symbol) g h b | path h -> b, path g b -> h gsetFieldSum :: GSetFieldSum path g h b => g x -> b -> h x class GSetFieldProd (path :: [Path]) g h b | path h -> b, path g b -> h gsetFieldProd :: GSetFieldProd path g h b => g x -> b -> h x class GAffineFieldImpl (repDefined :: Bool) (name :: Symbol) s t a b | name s -> a gafieldImpl :: GAffineFieldImpl repDefined name s t a b => AffineTraversal s t a b class GAffineFieldSum (path :: PathTree Symbol) g h a b gafieldSum :: GAffineFieldSum path g h a b => AffineTraversalVL (g x) (h x) a b class GFieldProd (path :: [Path]) g h a b | path g -> a, path h -> b, path g b -> h, path h a -> g gfieldProd :: GFieldProd path g h a b => LensVL (g x) (h x) a b class GPositionImpl (repDefined :: Bool) (n :: Nat) s t a b | n s -> a gpositionImpl :: GPositionImpl repDefined n s t a b => Lens s t a b class GPositionSum (path :: PathTree (Nat, Nat)) g h a b | path g -> a, path h -> b, path g b -> h, path h a -> g gpositionSum :: GPositionSum path g h a b => LensVL (g x) (h x) a b class GConstructorImpl (repDefined :: Bool) (name :: Symbol) s t a b | name s -> a gconstructorImpl :: GConstructorImpl repDefined name s t a b => Prism s t a b class GConstructorSum (path :: [Path]) g h a b | path g -> a, path h -> b, path g b -> h, path h a -> g gconstructorSum :: GConstructorSum path g h a b => Prism (g x) (h x) a b class GConstructorTuple g h a b | g -> a, h -> b, g b -> h, h a -> g gconstructorTuple :: GConstructorTuple g h a b => Prism (g x) (h x) a b class GPlateImpl g a gplateImpl :: GPlateImpl g a => TraversalVL' (g x) a class GPlateInner (repDefined :: Bool) s a gplateInner :: GPlateInner repDefined s a => TraversalVL' s a instance Optics.Internal.Generic.GPlateInner (Optics.Internal.Optic.TypeLevel.Defined (GHC.Generics.Rep b)) b a => Optics.Internal.Generic.GPlateImpl (GHC.Generics.K1 i b) a instance (GHC.Generics.Generic s, Optics.Internal.Generic.GPlateImpl (GHC.Generics.Rep s) a) => Optics.Internal.Generic.GPlateInner 'GHC.Types.True s a instance Optics.Internal.Generic.GPlateInner repNotDefined s a instance Optics.Internal.Generic.GPlateImpl f a => Optics.Internal.Generic.GPlateImpl (GHC.Generics.M1 i c f) a instance (Optics.Internal.Generic.GPlateImpl f a, Optics.Internal.Generic.GPlateImpl g a) => Optics.Internal.Generic.GPlateImpl (f GHC.Generics.:+: g) a instance (Optics.Internal.Generic.GPlateImpl f a, Optics.Internal.Generic.GPlateImpl g a) => Optics.Internal.Generic.GPlateImpl (f GHC.Generics.:*: g) a instance Optics.Internal.Generic.GPlateImpl (GHC.Generics.K1 i a) a instance Optics.Internal.Generic.GPlateImpl GHC.Generics.U1 a instance Optics.Internal.Generic.GPlateImpl GHC.Generics.V1 a instance Optics.Internal.Generic.GPlateImpl (GHC.Generics.URec b) a instance (r GHC.Types.~ a, s GHC.Types.~ b) => Optics.Internal.Generic.GConstructorTuple (Optics.Internal.Generic.F m a) (Optics.Internal.Generic.F m b) r s instance (r GHC.Types.~ (a1, a2), s GHC.Types.~ (b1, b2)) => Optics.Internal.Generic.GConstructorTuple (Optics.Internal.Generic.F m1 a1 GHC.Generics.:*: Optics.Internal.Generic.F m2 a2) (Optics.Internal.Generic.F m1 b1 GHC.Generics.:*: Optics.Internal.Generic.F m2 b2) r s instance (r GHC.Types.~ (a1, a2, a3), s GHC.Types.~ (b1, b2, b3)) => Optics.Internal.Generic.GConstructorTuple (Optics.Internal.Generic.F m1 a1 GHC.Generics.:*: (Optics.Internal.Generic.F m2 a2 GHC.Generics.:*: Optics.Internal.Generic.F m3 a3)) (Optics.Internal.Generic.F m1 b1 GHC.Generics.:*: (Optics.Internal.Generic.F m2 b2 GHC.Generics.:*: Optics.Internal.Generic.F m3 b3)) r s instance (r GHC.Types.~ (a1, a2, a3, a4), s GHC.Types.~ (b1, b2, b3, b4)) => Optics.Internal.Generic.GConstructorTuple ((Optics.Internal.Generic.F m1 a1 GHC.Generics.:*: Optics.Internal.Generic.F m2 a2) GHC.Generics.:*: (Optics.Internal.Generic.F m3 a3 GHC.Generics.:*: Optics.Internal.Generic.F m4 a4)) ((Optics.Internal.Generic.F m1 b1 GHC.Generics.:*: Optics.Internal.Generic.F m2 b2) GHC.Generics.:*: (Optics.Internal.Generic.F m3 b3 GHC.Generics.:*: Optics.Internal.Generic.F m4 b4)) r s instance (r GHC.Types.~ (a1, a2, a3, a4, a5), s GHC.Types.~ (b1, b2, b3, b4, b5)) => Optics.Internal.Generic.GConstructorTuple ((Optics.Internal.Generic.F m1 a1 GHC.Generics.:*: Optics.Internal.Generic.F m2 a2) GHC.Generics.:*: (Optics.Internal.Generic.F m3 a3 GHC.Generics.:*: (Optics.Internal.Generic.F m4 a4 GHC.Generics.:*: Optics.Internal.Generic.F m5 a5))) ((Optics.Internal.Generic.F m1 b1 GHC.Generics.:*: Optics.Internal.Generic.F m2 b2) GHC.Generics.:*: (Optics.Internal.Generic.F m3 b3 GHC.Generics.:*: (Optics.Internal.Generic.F m4 b4 GHC.Generics.:*: Optics.Internal.Generic.F m5 b5))) r s instance Optics.Internal.Generic.GConstructorTuple g h a b => Optics.Internal.Generic.GConstructorSum '[] (GHC.Generics.M1 GHC.Generics.C m g) (GHC.Generics.M1 GHC.Generics.C m h) a b instance (Optics.Internal.Magic.Dysfunctional () () g h a b, (TypeError ...)) => Optics.Internal.Generic.GConstructorTuple g h a b instance (a GHC.Types.~ (), b GHC.Types.~ ()) => Optics.Internal.Generic.GConstructorTuple GHC.Generics.U1 GHC.Generics.U1 a b instance (GHC.Generics.Generic s, GHC.Generics.Generic t, epath GHC.Types.~ Optics.Internal.Generic.TypeLevel.GetNamePath name (GHC.Generics.Rep s) '[], path GHC.Types.~ Optics.Internal.Optic.TypeLevel.FromRight (TypeError ...) epath, Optics.Internal.Optic.TypeLevel.When (Optics.Internal.Optic.TypeLevel.IsLeft epath) (Optics.Internal.Generic.TypeLevel.HideReps (GHC.Generics.Rep s) (GHC.Generics.Rep t)), Optics.Internal.Generic.GConstructorSum path (GHC.Generics.Rep s) (GHC.Generics.Rep t) a b) => Optics.Internal.Generic.GConstructorImpl 'GHC.Types.True name s t a b instance Optics.Internal.Generic.GConstructorSum path g h a b => Optics.Internal.Generic.GConstructorSum path (GHC.Generics.M1 GHC.Generics.D m g) (GHC.Generics.M1 GHC.Generics.D m h) a b instance Optics.Internal.Generic.GConstructorSum path g1 h1 a b => Optics.Internal.Generic.GConstructorSum ('Optics.Internal.Generic.TypeLevel.PathLeft : path) (g1 GHC.Generics.:+: g2) (h1 GHC.Generics.:+: g2) a b instance (Optics.Internal.Generic.GConstructorSum path g1 h1 a b, g2 GHC.Types.~ h2) => Optics.Internal.Generic.GConstructorSum ('Optics.Internal.Generic.TypeLevel.PathLeft : path) (g1 GHC.Generics.:+: g2) (h1 GHC.Generics.:+: h2) a b instance Optics.Internal.Generic.GConstructorSum path g2 h2 a b => Optics.Internal.Generic.GConstructorSum ('Optics.Internal.Generic.TypeLevel.PathRight : path) (g1 GHC.Generics.:+: g2) (g1 GHC.Generics.:+: h2) a b instance (Optics.Internal.Generic.GConstructorSum path g2 h2 a b, g1 GHC.Types.~ h1) => Optics.Internal.Generic.GConstructorSum ('Optics.Internal.Generic.TypeLevel.PathRight : path) (g1 GHC.Generics.:+: g2) (h1 GHC.Generics.:+: h2) a b instance (path GHC.Types.~ Optics.Internal.Generic.GPositionPath con epath, Optics.Internal.Optic.TypeLevel.When (Optics.Internal.Optic.TypeLevel.IsLeft epath) (Optics.Internal.Generic.TypeLevel.HideReps g h), Optics.Internal.Generic.GFieldProd path g h a b) => Optics.Internal.Generic.GPositionSum ('Optics.Internal.Generic.TypeLevel.PathLeaf epath) (GHC.Generics.M1 GHC.Generics.C ('GHC.Generics.MetaCons con fix hs) g) (GHC.Generics.M1 GHC.Generics.C ('GHC.Generics.MetaCons con fix hs) h) a b instance (GHC.Generics.Generic s, GHC.Generics.Generic t, path GHC.Types.~ Data.Type.Bool.If (n GHC.TypeNats.<=? 0) (TypeError ...) (Optics.Internal.Generic.TypeLevel.GetPositionPaths s n (GHC.Generics.Rep s)), Optics.Internal.Optic.TypeLevel.When (n GHC.TypeNats.<=? 0) (Optics.Internal.Generic.TypeLevel.HideReps (GHC.Generics.Rep s) (GHC.Generics.Rep t)), Optics.Internal.Generic.GPositionSum path (GHC.Generics.Rep s) (GHC.Generics.Rep t) a b) => Optics.Internal.Generic.GPositionImpl 'GHC.Types.True n s t a b instance Optics.Internal.Generic.GPositionSum path g h a b => Optics.Internal.Generic.GPositionSum path (GHC.Generics.M1 GHC.Generics.D m g) (GHC.Generics.M1 GHC.Generics.D m h) a b instance (Optics.Internal.Generic.GPositionSum path1 g1 h1 a b, Optics.Internal.Generic.GPositionSum path2 g2 h2 a b) => Optics.Internal.Generic.GPositionSum ('Optics.Internal.Generic.TypeLevel.PathTree path1 path2) (g1 GHC.Generics.:+: g2) (h1 GHC.Generics.:+: h2) a b instance Optics.Internal.Generic.GFieldProd prodPath g h a b => Optics.Internal.Generic.GAffineFieldMaybe ('Data.Either.Right prodPath) g h a b instance Optics.Internal.Generic.GFieldProd path g1 h1 a b => Optics.Internal.Generic.GFieldProd ('Optics.Internal.Generic.TypeLevel.PathLeft : path) (g1 GHC.Generics.:*: g2) (h1 GHC.Generics.:*: g2) a b instance (Optics.Internal.Generic.GFieldProd path g1 h1 a b, g2 GHC.Types.~ h2) => Optics.Internal.Generic.GFieldProd ('Optics.Internal.Generic.TypeLevel.PathLeft : path) (g1 GHC.Generics.:*: g2) (h1 GHC.Generics.:*: h2) a b instance Optics.Internal.Generic.GFieldProd path g2 h2 a b => Optics.Internal.Generic.GFieldProd ('Optics.Internal.Generic.TypeLevel.PathRight : path) (g1 GHC.Generics.:*: g2) (g1 GHC.Generics.:*: h2) a b instance (Optics.Internal.Generic.GFieldProd path g2 h2 a b, g1 GHC.Types.~ h1) => Optics.Internal.Generic.GFieldProd ('Optics.Internal.Generic.TypeLevel.PathRight : path) (g1 GHC.Generics.:*: g2) (h1 GHC.Generics.:*: h2) a b instance (r GHC.Types.~ a, s GHC.Types.~ b) => Optics.Internal.Generic.GFieldProd '[] (GHC.Generics.M1 GHC.Generics.S m (GHC.Generics.Rec0 a)) (GHC.Generics.M1 GHC.Generics.S m (GHC.Generics.Rec0 b)) r s instance Optics.Internal.Generic.GAffineFieldMaybe epath g h a b => Optics.Internal.Generic.GAffineFieldSum ('Optics.Internal.Generic.TypeLevel.PathLeaf epath) (GHC.Generics.M1 GHC.Generics.C m g) (GHC.Generics.M1 GHC.Generics.C m h) a b instance (g GHC.Types.~ h) => Optics.Internal.Generic.GAffineFieldMaybe ('Data.Either.Left name) g h a b instance (GHC.Generics.Generic s, GHC.Generics.Generic t, path GHC.Types.~ Optics.Internal.Generic.TypeLevel.GetFieldPaths s name (GHC.Generics.Rep s), GHC.Records.HasField name s a, Optics.Internal.Optic.TypeLevel.Unless (Optics.Internal.Generic.TypeLevel.AnyHasPath path) (TypeError ...), Optics.Internal.Generic.GAffineFieldSum path (GHC.Generics.Rep s) (GHC.Generics.Rep t) a b) => Optics.Internal.Generic.GAffineFieldImpl 'GHC.Types.True name s t a b instance Optics.Internal.Generic.GAffineFieldSum path g h a b => Optics.Internal.Generic.GAffineFieldSum path (GHC.Generics.M1 GHC.Generics.D m g) (GHC.Generics.M1 GHC.Generics.D m h) a b instance (Optics.Internal.Generic.GAffineFieldSum path1 g1 h1 a b, Optics.Internal.Generic.GAffineFieldSum path2 g2 h2 a b) => Optics.Internal.Generic.GAffineFieldSum ('Optics.Internal.Generic.TypeLevel.PathTree path1 path2) (g1 GHC.Generics.:+: g2) (h1 GHC.Generics.:+: h2) a b instance (path GHC.Types.~ Optics.Internal.Generic.GSetFieldPath con epath, Optics.Internal.Optic.TypeLevel.When (Optics.Internal.Optic.TypeLevel.IsLeft epath) (Optics.Internal.Generic.TypeLevel.HideReps g h), Optics.Internal.Generic.GSetFieldProd path g h b) => Optics.Internal.Generic.GSetFieldSum ('Optics.Internal.Generic.TypeLevel.PathLeaf epath) (GHC.Generics.M1 GHC.Generics.C ('GHC.Generics.MetaCons con fix hs) g) (GHC.Generics.M1 GHC.Generics.C ('GHC.Generics.MetaCons con fix hs) h) b instance Optics.Internal.Generic.GSetFieldProd path g1 h1 b => Optics.Internal.Generic.GSetFieldProd ('Optics.Internal.Generic.TypeLevel.PathLeft : path) (g1 GHC.Generics.:*: g2) (h1 GHC.Generics.:*: g2) b instance (Optics.Internal.Generic.GSetFieldProd path g1 h1 b, g2 GHC.Types.~ h2) => Optics.Internal.Generic.GSetFieldProd ('Optics.Internal.Generic.TypeLevel.PathLeft : path) (g1 GHC.Generics.:*: g2) (h1 GHC.Generics.:*: h2) b instance Optics.Internal.Generic.GSetFieldProd path g2 h2 b => Optics.Internal.Generic.GSetFieldProd ('Optics.Internal.Generic.TypeLevel.PathRight : path) (g1 GHC.Generics.:*: g2) (g1 GHC.Generics.:*: h2) b instance (Optics.Internal.Generic.GSetFieldProd path g2 h2 b, g1 GHC.Types.~ h1) => Optics.Internal.Generic.GSetFieldProd ('Optics.Internal.Generic.TypeLevel.PathRight : path) (g1 GHC.Generics.:*: g2) (h1 GHC.Generics.:*: h2) b instance (r GHC.Types.~ b) => Optics.Internal.Generic.GSetFieldProd '[] (GHC.Generics.M1 GHC.Generics.S m (GHC.Generics.Rec0 a)) (GHC.Generics.M1 GHC.Generics.S m (GHC.Generics.Rec0 b)) r instance (GHC.Generics.Generic s, GHC.Generics.Generic t, path GHC.Types.~ Optics.Internal.Generic.TypeLevel.GetFieldPaths s name (GHC.Generics.Rep s), GHC.Records.HasField name s a, Optics.Internal.Generic.GSetFieldSum path (GHC.Generics.Rep s) (GHC.Generics.Rep t) b) => Optics.Internal.Generic.GFieldImpl name s t a b instance Optics.Internal.Generic.GSetFieldSum path g h b => Optics.Internal.Generic.GSetFieldSum path (GHC.Generics.M1 GHC.Generics.D m g) (GHC.Generics.M1 GHC.Generics.D m h) b instance (Optics.Internal.Generic.GSetFieldSum path1 g1 h1 b, Optics.Internal.Generic.GSetFieldSum path2 g2 h2 b) => Optics.Internal.Generic.GSetFieldSum ('Optics.Internal.Generic.TypeLevel.PathTree path1 path2) (g1 GHC.Generics.:+: g2) (h1 GHC.Generics.:+: h2) b -- | Overloaded labels are a solution to Haskell's namespace problem for -- records. The -XOverloadedLabels extension allows a new -- expression syntax for labels, a prefix # sign followed by an -- identifier, e.g. #foo. These expressions can then be given an -- interpretation that depends on the type at which they are used and the -- text of the label. module Optics.Label -- | Support for overloaded labels as optics. -- -- An overloaded label #foo can be used as an optic if there is -- an instance LabelOptic "foo" k s t a b. -- -- Alternatively, if both s and t have a Generic -- (GenericLabelOptics if explicit-generic-labels flag is -- enabled) instance, a total field of s is accessible by a -- label #field of kind A_Lens, whereas its constructor -- by a label #_Constructor of kind A_Prism. class LabelOptic (name :: Symbol) k s t a b | name s -> k a, name t -> k b, name s b -> t, name t a -> s -- | Used to interpret overloaded label syntax. An overloaded label -- #foo corresponds to labelOptic @"foo". labelOptic :: LabelOptic name k s t a b => Optic k NoIx s t a b -- | Type synonym for a type-preserving optic as overloaded label. type LabelOptic' name k s a = LabelOptic name k s s a a -- | If the explicit-generic-labels Cabal flag is enabled, only -- types with this instance (which can be trivially derived with -- DeriveAnyClass extension) will be able to use labels as -- generic optics with a specific type. -- -- It's an option for application developers to disable implicit fallback -- to generic optics for more control. -- -- Libraries using generic labels with their data types should derive -- this instance for compatibility with the -- explicit-generic-labels flag. -- -- Note: the flag explicit-generic-labels is disabled by -- default. Enabling it is generally unsupported as it might lead to -- compilation errors of dependencies relying on implicit fallback to -- generic optics. class Generic a => GenericLabelOptics a where { type family HasGenericLabelOptics a :: Bool; type HasGenericLabelOptics a = 'True; } instance Optics.Label.GenericLabelOpticContext repDefined name k s t a b => Optics.Label.LabelOptic name k s t a b instance Optics.Internal.Generic.GFieldImpl name s t a b => Optics.Label.GenericOptic repDefined name Optics.Internal.Optic.Types.A_Lens s t a b instance (Optics.Internal.Generic.GConstructorImpl repDefined name s t a b, _name GHC.Types.~ GHC.TypeLits.AppendSymbol "_" name) => Optics.Label.GenericOptic repDefined _name Optics.Internal.Optic.Types.A_Prism s t a b instance (k GHC.Types.~ Optics.Internal.Optic.Types.An_Iso, a GHC.Types.~ Optics.Label.Void0, b GHC.Types.~ Optics.Label.Void0) => Optics.Label.LabelOptic name k Optics.Label.Void0 Optics.Label.Void0 a b instance (Optics.Label.LabelOptic name k s t a b, is GHC.Types.~ Optics.Internal.Optic.TypeLevel.NoIx) => GHC.OverloadedLabels.IsLabel name (Optics.Internal.Optic.Optic k is s t a b) -- | Note: GHC.Generics exports a number of names that -- collide with Optics (at least to). -- -- You can use hiding of imports to mitigate this to an extent. The -- following imports represent a fair compromise for user code: -- --
--   import Optics
--   import GHC.Generics hiding (to)
--   import GHC.Generics.Optics
--   
-- -- You can use generic to replace from and to from -- GHC.Generics. module GHC.Generics.Optics -- | Convert from the data type to its representation (or back) -- --
--   >>> view (generic % re generic) "hello" :: String
--   "hello"
--   
generic :: (Generic a, Generic b) => Iso a b (Rep a x) (Rep b y) -- | Convert from the data type to its representation (or back) generic1 :: (Generic1 f, Generic1 g) => Iso (f x) (g y) (Rep1 f x) (Rep1 g y) _V1 :: Lens (V1 s) (V1 t) a b _U1 :: Iso (U1 p) (U1 q) () () _Par1 :: Iso (Par1 p) (Par1 q) p q _Rec1 :: Iso (Rec1 f p) (Rec1 g q) (f p) (g q) _K1 :: Iso (K1 i c p) (K1 j d q) c d _M1 :: Iso (M1 i c f p) (M1 j d g q) (f p) (g q) _L1 :: Prism ((a :+: c) t) ((b :+: c) t) (a t) (b t) _R1 :: Prism ((c :+: a) t) ((c :+: b) t) (a t) (b t) -- | This module defines basic functionality for indexed optics. See the -- "Indexed optics" section of the overview documentation in the -- Optics module of the main optics package for more -- details. module Optics.Indexed.Core -- | Class for optic kinds that can have indices. class IxOptic k s t a b -- | Convert an indexed optic to its unindexed equivalent. noIx :: (IxOptic k s t a b, NonEmptyIndices is) => Optic k is s t a b -> Optic k NoIx s t a b -- | Construct a conjoined indexed optic that provides a separate code path -- when used without indices. Useful for defining indexed optics that are -- as efficient as their unindexed equivalents when used without indices. -- -- Note: conjoined f g is well-defined if and only -- if f ≡ noIx g. conjoined :: is `HasSingleIndex` i => Optic k NoIx s t a b -> Optic k is s t a b -> Optic k is s t a b -- | Compose two optics of compatible flavours. -- -- Returns an optic of the appropriate supertype. If either or both -- optics are indexed, the composition preserves all the indices. (%) :: forall k l m is js ks s t u v a b. (JoinKinds k l m, AppendIndices is js ks) => Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b infixl 9 % -- | Compose two indexed optics. Their indices are composed as a pair. -- --
--   >>> itoListOf (ifolded <%> ifolded) ["foo", "bar"]
--   [((0,0),'f'),((0,1),'o'),((0,2),'o'),((1,0),'b'),((1,1),'a'),((1,2),'r')]
--   
(<%>) :: (JoinKinds k l m, IxOptic m s t a b, is `HasSingleIndex` i, js `HasSingleIndex` j) => Optic k is s t u v -> Optic l js u v a b -> Optic m (WithIx (i, j)) s t a b infixl 9 <%> -- | Compose two indexed optics and drop indices of the left one. (If you -- want to compose a non-indexed and an indexed optic, you can just use -- (%).) -- --
--   >>> itoListOf (ifolded %> ifolded) ["foo", "bar"]
--   [(0,'f'),(1,'o'),(2,'o'),(0,'b'),(1,'a'),(2,'r')]
--   
(%>) :: (JoinKinds k l m, IxOptic k s t u v, NonEmptyIndices is) => Optic k is s t u v -> Optic l js u v a b -> Optic m js s t a b infixl 9 %> -- | Compose two indexed optics and drop indices of the right one. (If you -- want to compose an indexed and a non-indexed optic, you can just use -- (%).) -- --
--   >>> itoListOf (ifolded <% ifolded) ["foo", "bar"]
--   [(0,'f'),(0,'o'),(0,'o'),(1,'b'),(1,'a'),(1,'r')]
--   
(<%) :: (JoinKinds k l m, IxOptic l u v a b, NonEmptyIndices js) => Optic k is s t u v -> Optic l js u v a b -> Optic m is s t a b infixl 9 <% -- | Remap the index. -- --
--   >>> itoListOf (reindexed succ ifolded) "foo"
--   [(1,'f'),(2,'o'),(3,'o')]
--   
-- --
--   >>> itoListOf (ifolded %& reindexed succ) "foo"
--   [(1,'f'),(2,'o'),(3,'o')]
--   
reindexed :: is `HasSingleIndex` i => (i -> j) -> Optic k is s t a b -> Optic k (WithIx j) s t a b -- | Flatten indices obtained from two indexed optics. -- --
--   >>> itoListOf (ifolded % ifolded %& icompose (,)) ["foo","bar"]
--   [((0,0),'f'),((0,1),'o'),((0,2),'o'),((1,0),'b'),((1,1),'a'),((1,2),'r')]
--   
icompose :: (i -> j -> ix) -> Optic k '[i, j] s t a b -> Optic k (WithIx ix) s t a b -- | Flatten indices obtained from three indexed optics. -- --
--   >>> itoListOf (ifolded % ifolded % ifolded %& icompose3 (,,)) [["foo","bar"],["xyz"]]
--   [((0,0,0),'f'),((0,0,1),'o'),((0,0,2),'o'),((0,1,0),'b'),((0,1,1),'a'),((0,1,2),'r'),((1,0,0),'x'),((1,0,1),'y'),((1,0,2),'z')]
--   
icompose3 :: (i1 -> i2 -> i3 -> ix) -> Optic k '[i1, i2, i3] s t a b -> Optic k (WithIx ix) s t a b -- | Flatten indices obtained from four indexed optics. icompose4 :: (i1 -> i2 -> i3 -> i4 -> ix) -> Optic k '[i1, i2, i3, i4] s t a b -> Optic k (WithIx ix) s t a b -- | Flatten indices obtained from five indexed optics. icompose5 :: (i1 -> i2 -> i3 -> i4 -> i5 -> ix) -> Optic k '[i1, i2, i3, i4, i5] s t a b -> Optic k (WithIx ix) s t a b -- | Flatten indices obtained from arbitrary number of indexed optics. icomposeN :: forall k i is s t a b. (CurryCompose is, NonEmptyIndices is) => Curry is i -> Optic k is s t a b -> Optic k (WithIx i) s t a b -- | A Functor with an additional index. -- -- Instances must satisfy a modified form of the Functor laws: -- --
--   imap f . imap g ≡ imap (\i -> f i . g i)
--   imap (\_ a -> a) ≡ id
--   
class Functor f => FunctorWithIndex i (f :: Type -> Type) | f -> i -- | Map with access to the index. imap :: FunctorWithIndex i f => (i -> a -> b) -> f a -> f b -- | A container that supports folding with an additional index. class Foldable f => FoldableWithIndex i (f :: Type -> Type) | f -> i -- | Fold a container by mapping value to an arbitrary Monoid with -- access to the index i. -- -- When you don't need access to the index then foldMap is more -- flexible in what it accepts. -- --
--   foldMapifoldMap . const
--   
ifoldMap :: (FoldableWithIndex i f, Monoid m) => (i -> a -> m) -> f a -> m -- | A variant of ifoldMap that is strict in the accumulator. ifoldMap' :: (FoldableWithIndex i f, Monoid m) => (i -> a -> m) -> f a -> m -- | Right-associative fold of an indexed container with access to the -- index i. -- -- When you don't need access to the index then foldr is more -- flexible in what it accepts. -- --
--   foldrifoldr . const
--   
ifoldr :: FoldableWithIndex i f => (i -> a -> b -> b) -> b -> f a -> b -- | Left-associative fold of an indexed container with access to the index -- i. -- -- When you don't need access to the index then foldl is more -- flexible in what it accepts. -- --
--   foldlifoldl . const
--   
ifoldl :: FoldableWithIndex i f => (i -> b -> a -> b) -> b -> f a -> b -- | Strictly fold right over the elements of a structure with -- access to the index i. -- -- When you don't need access to the index then foldr' is more -- flexible in what it accepts. -- --
--   foldr'ifoldr' . const
--   
ifoldr' :: FoldableWithIndex i f => (i -> a -> b -> b) -> b -> f a -> b -- | Fold over the elements of a structure with an index, associating to -- the left, but strictly. -- -- When you don't need access to the index then foldlOf' is more -- flexible in what it accepts. -- --
--   foldlOf' l ≡ ifoldlOf' l . const
--   
ifoldl' :: FoldableWithIndex i f => (i -> b -> a -> b) -> b -> f a -> b -- | Traverse elements with access to the index i, discarding the -- results. -- -- When you don't need access to the index then traverse_ is -- more flexible in what it accepts. -- --
--   traverse_ l = itraverse . const
--   
itraverse_ :: (FoldableWithIndex i t, Applicative f) => (i -> a -> f b) -> t a -> f () -- | Traverse elements with access to the index i, discarding the -- results (with the arguments flipped). -- --
--   ifor_flip itraverse_
--   
-- -- When you don't need access to the index then for_ is more -- flexible in what it accepts. -- --
--   for_ a ≡ ifor_ a . const
--   
ifor_ :: (FoldableWithIndex i t, Applicative f) => t a -> (i -> a -> f b) -> f () -- | Extract the key-value pairs from a structure. -- -- When you don't need access to the indices in the result, then -- toList is more flexible in what it accepts. -- --
--   toListmap snd . itoList
--   
itoList :: FoldableWithIndex i f => f a -> [(i, a)] -- | A Traversable with an additional index. -- -- An instance must satisfy a (modified) form of the Traversable -- laws: -- --
--   itraverse (const Identity) ≡ Identity
--   fmap (itraverse f) . itraverse g ≡ getCompose . itraverse (\i -> Compose . fmap (f i) . g i)
--   
class (FunctorWithIndex i t, FoldableWithIndex i t, Traversable t) => TraversableWithIndex i (t :: Type -> Type) | t -> i -- | Traverse an indexed container. -- --
--   itraverseitraverseOf itraversed
--   
itraverse :: (TraversableWithIndex i t, Applicative f) => (i -> a -> f b) -> t a -> f (t b) -- | Traverse with an index (and the arguments flipped). -- --
--   for a ≡ ifor a . const
--   iforflip itraverse
--   
ifor :: (TraversableWithIndex i t, Applicative f) => t a -> (i -> a -> f b) -> f (t b) instance (s GHC.Types.~ t, a GHC.Types.~ b) => Optics.Indexed.Core.IxOptic Optics.Internal.Optic.Types.A_Getter s t a b instance Optics.Indexed.Core.IxOptic Optics.Internal.Optic.Types.A_Lens s t a b instance Optics.Indexed.Core.IxOptic Optics.Internal.Optic.Types.An_AffineTraversal s t a b instance (s GHC.Types.~ t, a GHC.Types.~ b) => Optics.Indexed.Core.IxOptic Optics.Internal.Optic.Types.An_AffineFold s t a b instance Optics.Indexed.Core.IxOptic Optics.Internal.Optic.Types.A_Traversal s t a b instance (s GHC.Types.~ t, a GHC.Types.~ b) => Optics.Indexed.Core.IxOptic Optics.Internal.Optic.Types.A_Fold s t a b instance Optics.Indexed.Core.IxOptic Optics.Internal.Optic.Types.A_Setter s t a b -- | This module provides, for data types having a Generic instance, -- a way to focus on: -- -- -- -- Note: gfield and gconstructor are supported by -- labelOptic and can be used with a consise syntax via -- OverloadedLabels. -- -- If you're looking for optics for working with a generic representation -- of a data type, there's GHC.Generics.Optics. module Optics.Generic -- | Focus on a field name of type a within a type -- s using its Generic instance. -- --
--   >>> :{
--   data User a
--     = User { name :: String
--            , age  :: a
--            }
--     | LazyUser { name :: String
--                , age  :: a
--                , lazy :: Bool
--                }
--     deriving (Show, Generic)
--   :}
--   
-- --
--   >>> let user = User "Tom" 32 :: User Int
--   
-- --
--   >>> user ^. gfield @"name"
--   "Tom"
--   
-- --
--   >>> user ^. gfield @"age"
--   32
--   
-- --
--   >>> user ^. gfield @"salary"
--   ...
--   ...Data constructor ‘User’ doesn't have a field named ‘salary’
--   ...In the...
--   ...
--   
-- -- Only total fields are accessible (for partial ones see -- gafield): -- --
--   >>> user ^. gfield @"lazy"
--   ...
--   ...Data constructor ‘User’ doesn't have a field named ‘lazy’
--   ...In the...
--   ...
--   
-- -- Type changing updates are supported: -- --
--   >>> user & gfield @"age" .~ ()
--   User {name = "Tom", age = ()}
--   
-- -- Types without a Generic instance are not supported: -- --
--   >>> NoG 'x' ^. gfield @"any"
--   ...
--   ...Type ‘NoG’ doesn't have a Generic instance
--   ...In the...
--   ...
--   
-- -- Note: gfield is supported by labelOptic and can -- be used with a concise syntax via OverloadedLabels. -- --
--   >>> user ^. #name
--   "Tom"
--   
-- --
--   >>> user & #age %~ (+1)
--   User {name = "Tom", age = 33}
--   
class GField (name :: Symbol) s t a b | name s -> t a b, name t -> s a b gfield :: GField name s t a b => Lens s t a b -- | Focus on a possibly partial field name of type a -- within a type s using its Generic instance. -- --
--   >>> :{
--   data Fish = Herring { name :: String }
--             | Tuna    { name :: String, sleeping :: Bool }
--     deriving Generic
--   :}
--   
-- --
--   >>> let herring = Herring { name = "Henry" }
--   
--   >>> let tuna    = Tuna { name = "Tony", sleeping = True }
--   
-- --
--   >>> herring ^? gafield @"name"
--   Just "Henry"
--   
-- --
--   >>> herring ^? gafield @"sleeping"
--   Nothing
--   
-- --
--   >>> tuna ^? gafield @"sleeping"
--   Just True
--   
-- -- Types without a Generic instance are not supported: -- --
--   >>> NoG 'x' ^? gafield @"any"
--   ...
--   ...Type ‘NoG’ doesn't have a Generic instance
--   ...In the...
--   ...
--   
-- -- Note: trying to access a field that doesn't exist in any data -- constructor results in an error: -- --
--   >>> tuna ^? gafield @"salary"
--   ...
--   ...Type ‘Fish’ doesn't have a field named ‘salary’
--   ...In the...
--   ...
--   
class GAffineField (name :: Symbol) s t a b | name s -> t a b, name t -> s a b gafield :: GAffineField name s t a b => AffineTraversal s t a b -- | Focus on a field at position n of type a within a -- type s using its Generic instance. -- --
--   >>> ('a', 'b', 'c') ^. gposition @2
--   'b'
--   
-- --
--   >>> ('a', 'b') & gposition @1 .~ "hi" & gposition @2 .~ "there"
--   ("hi","there")
--   
-- --
--   >>> ('a', 'b', 'c') ^. gposition @4
--   ...
--   ...Data constructor ‘(,,)’ has 3 fields, 4th requested
--   ...In the...
--   ...
--   
-- --
--   >>> () ^. gposition @1
--   ...
--   ...Data constructor ‘()’ has no fields, 1st requested
--   ...In the...
--   ...
--   
-- -- Types without a Generic instance are not supported: -- --
--   >>> NoG 'x' ^. gposition @1
--   ...
--   ...Type ‘NoG’ doesn't have a Generic instance
--   ...In the...
--   ...
--   
-- -- Note: Positions start from 1: -- --
--   >>> ('a', 'b') ^. gposition @0
--   ...
--   ...There is no 0th position
--   ...In the...
--   ...
--   
class GPosition (n :: Nat) s t a b | n s -> t a b, n t -> s a b gposition :: GPosition n s t a b => Lens s t a b -- | Focus on a constructor name of a type s using its -- Generic instance. -- --
--   >>> :{
--   data Animal = Dog { name :: String, age :: Int }
--               | Cat { name :: String, purrs :: Bool }
--     deriving (Show, Generic)
--   :}
--   
-- --
--   >>> let dog = Dog "Sparky" 2
--   
--   >>> let cat = Cat "Cuddly" True
--   
-- --
--   >>> dog ^? gconstructor @"Dog"
--   Just ("Sparky",2)
--   
-- --
--   >>> dog ^? gconstructor @"Cat"
--   Nothing
--   
-- --
--   >>> cat & gconstructor @"Cat" % _2 %~ not
--   Cat {name = "Cuddly", purrs = False}
--   
-- --
--   >>> dog & gconstructor @"Cat" % _1 .~ "Merry"
--   Dog {name = "Sparky", age = 2}
--   
-- --
--   >>> cat ^? gconstructor @"Parrot"
--   ...
--   ...Type ‘Animal’ doesn't have a constructor named ‘Parrot’
--   ...In the...
--   ...
--   
-- -- Types without a Generic instance are not supported: -- --
--   >>> NoG 'x' ^. gconstructor @"NoG"
--   ...
--   ...Type ‘NoG’ doesn't have a Generic instance
--   ...In the...
--   ...
--   
-- -- Note: gconstructor is supported by labelOptic and -- can be used with a concise syntax via OverloadedLabels. -- --
--   >>> dog ^? #_Dog
--   Just ("Sparky",2)
--   
-- --
--   >>> cat & #_Cat % _1 .~ "Merry"
--   Cat {name = "Merry", purrs = True}
--   
class GConstructor (name :: Symbol) s t a b | name s -> t a b, name t -> s a b gconstructor :: GConstructor name s t a b => Prism s t a b -- | Traverse occurrences of a type a within a type s -- using its Generic instance. -- --
--   >>> toListOf (gplate @Char) ('h', ((), 'e', Just 'l'), "lo")
--   "hello"
--   
-- -- If a occurs recursively in its own definition, only outermost -- occurrences of a within s will be traversed: -- --
--   >>> toListOf (gplate @String) ("one","two")
--   ["one","two"]
--   
-- -- Note: types without a Generic instance in scope when -- GPlate class constraint is resolved will not be entered during -- the traversal. -- --
--   >>> let noG = (NoG 'n', (Just 'i', "c"), 'e')
--   
-- --
--   >>> toListOf (gplate @Char) noG
--   "ice"
--   
-- --
--   >>> deriving instance Generic NoG
--   
-- --
--   >>> toListOf (gplate @Char) noG
--   "nice"
--   
class GPlate a s gplate :: GPlate a s => Traversal' s a instance Optics.Generic.GPlateContext a s => Optics.Generic.GPlate a s instance Optics.Generic.GPlate a Optics.Generic.Void0 instance Optics.Generic.GPlate Optics.Generic.Void0 a instance Optics.Generic.GConstructorContext repDefined name s t a b => Optics.Generic.GConstructor name s t a b instance (a GHC.Types.~ Optics.Generic.Void0, b GHC.Types.~ Optics.Generic.Void0) => Optics.Generic.GConstructor name Optics.Generic.Void0 Optics.Generic.Void0 a b instance Optics.Generic.GPositionContext repDefined n s t a b => Optics.Generic.GPosition n s t a b instance (a GHC.Types.~ Optics.Generic.Void0, b GHC.Types.~ Optics.Generic.Void0) => Optics.Generic.GPosition name Optics.Generic.Void0 Optics.Generic.Void0 a b instance Optics.Generic.GAFieldContext repDefined name s t a b => Optics.Generic.GAffineField name s t a b instance (a GHC.Types.~ Optics.Generic.Void0, b GHC.Types.~ Optics.Generic.Void0) => Optics.Generic.GAffineField name Optics.Generic.Void0 Optics.Generic.Void0 a b instance Optics.Generic.GFieldContext name s t a b => Optics.Generic.GField name s t a b instance (a GHC.Types.~ Optics.Generic.Void0, b GHC.Types.~ Optics.Generic.Void0) => Optics.Generic.GField name Optics.Generic.Void0 Optics.Generic.Void0 a b -- | This module defines Lenses for the fields of tuple types. These -- are overloaded using the Field1 to Field9 typeclasses, -- so that _1 can be used as a Lens for the first field of -- a tuple with any number of fields (up to the maximum supported tuple -- size, which is currently 9). For example: -- --
--   >>> view _1 ('a','b','c')
--   'a'
--   
-- --
--   >>> set _3 True ('a','b','c')
--   ('a','b',True)
--   
-- -- If a datatype has a Generic instance, the corresponding -- FieldN instances can be defined using their default methods: -- --
--   >>> :set -XDeriveGeneric
--   
--   >>> import GHC.Generics (Generic)
--   
--   >>> data T a b = MkT a Int b deriving (Generic, Show)
--   
--   >>> instance Field1 (T a c) (T b c) a b
--   
--   >>> instance Field2 (T a b) (T a b) Int Int
--   
--   >>> instance Field3 (T c a) (T c b) a b
--   
-- --
--   >>> set _3 'x' (MkT False 1 ())
--   MkT False 1 'x'
--   
-- -- For a generalization of this pattern see GPosition. module Data.Tuple.Optics -- | 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). -- --
--   >>> (1,2) ^. _1
--   1
--   
-- --
--   >>> (1,2) & _1 .~ "hello"
--   ("hello",2)
--   
-- --
--   >>> traverseOf _1 putStrLn ("hello","world")
--   hello
--   ((),"world")
--   
-- -- This can also be used on larger tuples as well: -- --
--   >>> (1,2,3,4,5) & _1 %~ (+41)
--   (42,2,3,4,5)
--   
_1 :: Field1 s t a b => Lens s t a b -- | Access the 1st field of a tuple (and possibly change its type). -- --
--   >>> (1,2) ^. _1
--   1
--   
-- --
--   >>> (1,2) & _1 .~ "hello"
--   ("hello",2)
--   
-- --
--   >>> traverseOf _1 putStrLn ("hello","world")
--   hello
--   ((),"world")
--   
-- -- This can also be used on larger tuples as well: -- --
--   >>> (1,2,3,4,5) & _1 %~ (+41)
--   (42,2,3,4,5)
--   
_1 :: (Field1 s t a b, GPosition 1 s t a b) => Lens s t a b -- | Provides access to the 2nd field of a tuple. class Field2 s t a b | s -> a, t -> b, s b -> t, t a -> s -- | Access the 2nd field of a tuple. -- --
--   >>> _2 .~ "hello" $ (1,(),3,4)
--   (1,"hello",3,4)
--   
-- --
--   >>> (1,2,3,4) & _2 %~ (*3)
--   (1,6,3,4)
--   
-- --
--   >>> traverseOf _2 print (1,2)
--   2
--   (1,())
--   
_2 :: Field2 s t a b => Lens s t a b -- | Access the 2nd field of a tuple. -- --
--   >>> _2 .~ "hello" $ (1,(),3,4)
--   (1,"hello",3,4)
--   
-- --
--   >>> (1,2,3,4) & _2 %~ (*3)
--   (1,6,3,4)
--   
-- --
--   >>> traverseOf _2 print (1,2)
--   2
--   (1,())
--   
_2 :: (Field2 s t a b, GPosition 2 s 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 -- | Access the 3rd field of a tuple. _3 :: (Field3 s t a b, GPosition 3 s 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 -- | Access the 4th field of a tuple. _4 :: (Field4 s t a b, GPosition 4 s 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 -- | Access the 5th field of a tuple. _5 :: (Field5 s t a b, GPosition 5 s 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 -- | Access the 6th field of a tuple. _6 :: (Field6 s t a b, GPosition 6 s 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 -- | Access the 7th field of a tuple. _7 :: (Field7 s t a b, GPosition 7 s 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 -- | Access the 8th field of a tuple. _8 :: (Field8 s t a b, GPosition 8 s 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 -- | Access the 9th field of a tuple. _9 :: (Field9 s t a b, GPosition 9 s t a b) => Lens s t a b -- | Strict version of _1 _1' :: Field1 s t a b => Lens s t a b -- | Strict version of _2 _2' :: Field2 s t a b => Lens s t a b -- | Strict version of _3 _3' :: Field3 s t a b => Lens s t a b -- | Strict version of _4 _4' :: Field4 s t a b => Lens s t a b -- | Strict version of _5 _5' :: Field5 s t a b => Lens s t a b -- | Strict version of _6 _6' :: Field6 s t a b => Lens s t a b -- | Strict version of _7 _7' :: Field7 s t a b => Lens s t a b -- | Strict version of _8 _8' :: Field8 s t a b => Lens s t a b -- | Strict version of _9 _9' :: Field9 s t a b => Lens s t a b instance Data.Tuple.Optics.Field9 (a, b, c, d, e, f, g, h, i) (a, b, c, d, e, f, g, h, i') i i' instance Data.Tuple.Optics.Field8 (a, b, c, d, e, f, g, h) (a, b, c, d, e, f, g, h') h h' instance Data.Tuple.Optics.Field8 (a, b, c, d, e, f, g, h, i) (a, b, c, d, e, f, g, h', i) h h' instance Data.Tuple.Optics.Field7 (a, b, c, d, e, f, g) (a, b, c, d, e, f, g') g g' instance Data.Tuple.Optics.Field7 (a, b, c, d, e, f, g, h) (a, b, c, d, e, f, g', h) g g' instance Data.Tuple.Optics.Field7 (a, b, c, d, e, f, g, h, i) (a, b, c, d, e, f, g', h, i) g g' instance Data.Tuple.Optics.Field6 (a, b, c, d, e, f) (a, b, c, d, e, f') f f' instance Data.Tuple.Optics.Field6 (a, b, c, d, e, f, g) (a, b, c, d, e, f', g) f f' instance Data.Tuple.Optics.Field6 (a, b, c, d, e, f, g, h) (a, b, c, d, e, f', g, h) f f' instance Data.Tuple.Optics.Field6 (a, b, c, d, e, f, g, h, i) (a, b, c, d, e, f', g, h, i) f f' instance Data.Tuple.Optics.Field5 (a, b, c, d, e) (a, b, c, d, e') e e' instance Data.Tuple.Optics.Field5 (a, b, c, d, e, f) (a, b, c, d, e', f) e e' instance Data.Tuple.Optics.Field5 (a, b, c, d, e, f, g) (a, b, c, d, e', f, g) e e' instance Data.Tuple.Optics.Field5 (a, b, c, d, e, f, g, h) (a, b, c, d, e', f, g, h) e e' instance Data.Tuple.Optics.Field5 (a, b, c, d, e, f, g, h, i) (a, b, c, d, e', f, g, h, i) e e' instance Data.Tuple.Optics.Field4 (a, b, c, d) (a, b, c, d') d d' instance Data.Tuple.Optics.Field4 (a, b, c, d, e) (a, b, c, d', e) d d' instance Data.Tuple.Optics.Field4 (a, b, c, d, e, f) (a, b, c, d', e, f) d d' instance Data.Tuple.Optics.Field4 (a, b, c, d, e, f, g) (a, b, c, d', e, f, g) d d' instance Data.Tuple.Optics.Field4 (a, b, c, d, e, f, g, h) (a, b, c, d', e, f, g, h) d d' instance Data.Tuple.Optics.Field4 (a, b, c, d, e, f, g, h, i) (a, b, c, d', e, f, g, h, i) d d' instance Data.Tuple.Optics.Field3 (a, b, c) (a, b, c') c c' instance Data.Tuple.Optics.Field3 (a, b, c, d) (a, b, c', d) c c' instance Data.Tuple.Optics.Field3 (a, b, c, d, e) (a, b, c', d, e) c c' instance Data.Tuple.Optics.Field3 (a, b, c, d, e, f) (a, b, c', d, e, f) c c' instance Data.Tuple.Optics.Field3 (a, b, c, d, e, f, g) (a, b, c', d, e, f, g) c c' instance Data.Tuple.Optics.Field3 (a, b, c, d, e, f, g, h) (a, b, c', d, e, f, g, h) c c' instance Data.Tuple.Optics.Field3 (a, b, c, d, e, f, g, h, i) (a, b, c', d, e, f, g, h, i) c c' instance Data.Tuple.Optics.Field2 (Data.Functor.Product.Product f g a) (Data.Functor.Product.Product f g' a) (g a) (g' a) instance Data.Tuple.Optics.Field2 ((GHC.Generics.:*:) f g p) ((GHC.Generics.:*:) f g' p) (g p) (g' p) instance Data.Tuple.Optics.Field2 (a, b) (a, b') b b' instance Data.Tuple.Optics.Field2 (a, b, c) (a, b', c) b b' instance Data.Tuple.Optics.Field2 (a, b, c, d) (a, b', c, d) b b' instance Data.Tuple.Optics.Field2 (a, b, c, d, e) (a, b', c, d, e) b b' instance Data.Tuple.Optics.Field2 (a, b, c, d, e, f) (a, b', c, d, e, f) b b' instance Data.Tuple.Optics.Field2 (a, b, c, d, e, f, g) (a, b', c, d, e, f, g) b b' instance Data.Tuple.Optics.Field2 (a, b, c, d, e, f, g, h) (a, b', c, d, e, f, g, h) b b' instance Data.Tuple.Optics.Field2 (a, b, c, d, e, f, g, h, i) (a, b', c, d, e, f, g, h, i) b b' instance Data.Tuple.Optics.Field1 (Data.Functor.Identity.Identity a) (Data.Functor.Identity.Identity b) a b instance Data.Tuple.Optics.Field1 (Data.Functor.Product.Product f g a) (Data.Functor.Product.Product f' g a) (f a) (f' a) instance Data.Tuple.Optics.Field1 ((GHC.Generics.:*:) f g p) ((GHC.Generics.:*:) f' g p) (f p) (f' p) instance Data.Tuple.Optics.Field1 (a, b) (a', b) a a' instance Data.Tuple.Optics.Field1 (a, b, c) (a', b, c) a a' instance Data.Tuple.Optics.Field1 (a, b, c, d) (a', b, c, d) a a' instance Data.Tuple.Optics.Field1 (a, b, c, d, e) (a', b, c, d, e) a a' instance Data.Tuple.Optics.Field1 (a, b, c, d, e, f) (a', b, c, d, e, f) a a' instance Data.Tuple.Optics.Field1 (a, b, c, d, e, f, g) (a', b, c, d, e, f, g) a a' instance Data.Tuple.Optics.Field1 (a, b, c, d, e, f, g, h) (a', b, c, d, e, f, g, h) a a' instance Data.Tuple.Optics.Field1 (a, b, c, d, e, f, g, h, i) (a', b, c, d, e, f, g, h, i) a a' -- | This module defines the Cons and Snoc classes, which -- provide Prisms for the leftmost and rightmost elements of a -- container, respectively. -- -- Note that orphan instances for these classes are defined in the -- Optics.Cons module from optics-extra, so if you are -- not simply depending on optics you may wish to import that -- module instead. module Optics.Cons.Core -- | 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 -- |
--   _Cons :: Prism [a] [b] (a, [a]) (b, [b])
--   _Cons :: Prism (Seq a) (Seq b) (a, Seq a) (b, Seq b)
--   _Cons :: Prism (Vector a) (Vector b) (a, Vector a) (b, Vector b)
--   _Cons :: Prism' String (Char, String)
--   _Cons :: Prism' Text (Char, Text)
--   _Cons :: Prism' ByteString (Word8, ByteString)
--   
_Cons :: Cons s t a b => Prism s t (a, s) (b, t) -- | cons an element onto a container. -- -- This is an infix alias for cons. -- --
--   >>> 1 <| []
--   [1]
--   
-- --
--   >>> 'a' <| "bc"
--   "abc"
--   
-- --
--   >>> 1 <| []
--   [1]
--   
-- --
--   >>> 1 <| [2, 3]
--   [1,2,3]
--   
(<|) :: Cons s s a a => a -> s -> s infixr 5 <| -- | cons an element onto a container. -- --
--   >>> cons 'a' ""
--   "a"
--   
-- --
--   >>> cons 'a' "bc"
--   "abc"
--   
cons :: Cons s s a a => a -> s -> s infixr 5 `cons` -- | Attempt to extract the left-most element from a container, and a -- version of the container without that element. -- --
--   >>> uncons []
--   Nothing
--   
-- --
--   >>> uncons [1, 2, 3]
--   Just (1,[2,3])
--   
uncons :: Cons s s a a => s -> Maybe (a, s) -- | An AffineTraversal reading and writing to the head of a -- non-empty container. -- --
--   >>> "abc" ^? _head
--   Just 'a'
--   
-- --
--   >>> "abc" & _head .~ 'd'
--   "dbc"
--   
-- --
--   >>> [1,2,3] & _head %~ (*10)
--   [10,2,3]
--   
-- --
--   >>> [] & _head %~ absurd
--   []
--   
-- --
--   >>> [1,2,3] ^? _head
--   Just 1
--   
-- --
--   >>> [] ^? _head
--   Nothing
--   
-- --
--   >>> [1,2] ^? _head
--   Just 1
--   
-- --
--   >>> [] & _head .~ 1
--   []
--   
-- --
--   >>> [0] & _head .~ 2
--   [2]
--   
-- --
--   >>> [0,1] & _head .~ 2
--   [2,1]
--   
_head :: Cons s s a a => AffineTraversal' s a -- | An AffineTraversal reading and writing to the tail of a -- non-empty container. -- --
--   >>> "ab" & _tail .~ "cde"
--   "acde"
--   
-- --
--   >>> [] & _tail .~ [1,2]
--   []
--   
-- --
--   >>> [1,2,3,4,5] & _tail % traversed %~ (*10)
--   [1,20,30,40,50]
--   
-- --
--   >>> [1,2] & _tail .~ [3,4,5]
--   [1,3,4,5]
--   
-- --
--   >>> [] & _tail .~ [1,2]
--   []
--   
-- --
--   >>> "abc" ^? _tail
--   Just "bc"
--   
-- --
--   >>> "hello" ^? _tail
--   Just "ello"
--   
-- --
--   >>> "" ^? _tail
--   Nothing
--   
_tail :: Cons s s a a => AffineTraversal' s s -- | Pattern synonym for matching on the leftmost element of a structure. -- --
--   >>> case ['a','b','c'] of (x :< _) -> x
--   'a'
--   
pattern (:<) :: forall s a. Cons s s a a => a -> s -> s infixr 5 :< -- | 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 _Snoc :: Snoc s t a b => Prism s t (s, a) (t, b) -- | snoc an element onto the end of a container. -- -- This is an infix alias for snoc. -- --
--   >>> "" |> 'a'
--   "a"
--   
-- --
--   >>> "bc" |> 'a'
--   "bca"
--   
(|>) :: Snoc s s a a => s -> a -> s infixl 5 |> -- | snoc an element onto the end of a container. -- --
--   >>> snoc "hello" '!'
--   "hello!"
--   
snoc :: Snoc s s a a => s -> a -> s infixl 5 `snoc` -- | Attempt to extract the right-most element from a container, and a -- version of the container without that element. -- --
--   >>> unsnoc "hello!"
--   Just ("hello",'!')
--   
-- --
--   >>> unsnoc ""
--   Nothing
--   
unsnoc :: Snoc s s a a => s -> Maybe (s, a) -- | An AffineTraversal reading and replacing all but the a last -- element of a non-empty container. -- --
--   >>> "abcd" ^? _init
--   Just "abc"
--   
-- --
--   >>> "" ^? _init
--   Nothing
--   
-- --
--   >>> "ab" & _init .~ "cde"
--   "cdeb"
--   
-- --
--   >>> [] & _init .~ [1,2]
--   []
--   
-- --
--   >>> [1,2,3,4] & _init % traversed %~ (*10)
--   [10,20,30,4]
--   
-- --
--   >>> [1,2,3] ^? _init
--   Just [1,2]
--   
-- --
--   >>> "hello" ^? _init
--   Just "hell"
--   
-- --
--   >>> [] ^? _init
--   Nothing
--   
_init :: Snoc s s a a => AffineTraversal' s s -- | An AffineTraversal reading and writing to the last element of a -- non-empty container. -- --
--   >>> "abc" ^? _last
--   Just 'c'
--   
-- --
--   >>> "" ^? _last
--   Nothing
--   
-- --
--   >>> [1,2,3] & _last %~ (+1)
--   [1,2,4]
--   
-- --
--   >>> [1,2] ^? _last
--   Just 2
--   
-- --
--   >>> [] & _last .~ 1
--   []
--   
-- --
--   >>> [0] & _last .~ 2
--   [2]
--   
-- --
--   >>> [0,1] & _last .~ 2
--   [0,2]
--   
_last :: Snoc s s a a => AffineTraversal' s a -- | Pattern synonym for matching on the rightmost element of a structure. -- --
--   >>> case ['a','b','c'] of (_ :> x) -> x
--   'c'
--   
pattern (:>) :: forall s a. Snoc s s a a => s -> a -> s infixl 5 :> instance Optics.Cons.Core.Snoc [a] [b] a b instance Optics.Cons.Core.Snoc (Control.Applicative.ZipList a) (Control.Applicative.ZipList b) a b instance Optics.Cons.Core.Snoc (Data.Sequence.Internal.Seq a) (Data.Sequence.Internal.Seq b) a b instance Optics.Cons.Core.Cons [a] [b] a b instance Optics.Cons.Core.Cons (Control.Applicative.ZipList a) (Control.Applicative.ZipList b) a b instance Optics.Cons.Core.Cons (Data.Sequence.Internal.Seq a) (Data.Sequence.Internal.Seq b) a b module Numeric.Optics -- | A prism that shows and reads integers in base-2 through base-36 -- -- Note: This is an improper prism, since leading 0s are stripped when -- reading. -- --
--   >>> "100" ^? base 16
--   Just 256
--   
-- --
--   >>> 1767707668033969 ^. re (base 36)
--   "helloworld"
--   
base :: (HasCallStack, Integral a) => Int -> Prism' String a -- | This Prism can be used to model the fact that every -- Integral type is a subset of Integer. -- -- Embedding through the Prism only succeeds if the Integer -- would pass through unmodified when re-extracted. integral :: (Integral a, Integral b) => Prism Integer Integer a b -- |
--   binary = base 2
--   
binary :: Integral a => Prism' String a -- |
--   octal = base 8
--   
octal :: Integral a => Prism' String a -- |
--   decimal = base 10
--   
decimal :: Integral a => Prism' String a -- |
--   hex = base 16
--   
hex :: Integral a => Prism' String a -- |
--   adding n = iso (+n) (subtract n)
--   
-- --
--   >>> [1..3] ^.. traversed % adding 1000
--   [1001,1002,1003]
--   
adding :: Num a => a -> Iso' a a -- |
--   subtracting n = iso (subtract n) ((+n)
--   subtracting n = re (adding n)
--   
subtracting :: Num a => a -> Iso' a a -- |
--   multiplying n = iso (*n) (/n)
--   
-- -- Note: This errors for n = 0 -- --
--   >>> 5 & multiplying 1000 %~ (+3)
--   5.003
--   
-- --
--   >>> let fahrenheit = multiplying (9/5) % adding 32 in 230 ^. re fahrenheit
--   110.0
--   
multiplying :: (Fractional a, Eq a) => a -> Iso' a a -- |
--   dividing n = iso (/n) (*n)
--   dividing n = re (multiplying n)
--   
-- -- Note: This errors for n = 0 dividing :: (Fractional a, Eq a) => a -> Iso' a a -- |
--   exponentiating n = iso (**n) (**recip n)
--   
-- -- Note: This errors for n = 0 -- --
--   >>> au (coerced1 @Sum % re (exponentiating 2)) (foldMapOf each) (3,4) == 5
--   True
--   
exponentiating :: (Floating a, Eq a) => a -> Iso' a a -- |
--   negated = iso negate negate
--   
-- --
--   >>> au (coerced1 @Sum % negated) (foldMapOf each) (3,4) == 7
--   True
--   
-- --
--   >>> au (coerced1 @Sum) (foldMapOf (each % negated)) (3,4) == -7
--   True
--   
negated :: Num a => Iso' a a -- | Pattern synonym that can be used to construct or pattern match on an -- Integer as if it were of any Integral type. pattern Integral :: forall a. Integral a => a -> Integer -- | See the Optics module in the main optics package for -- overview documentation. module Optics.Core -- | This module defines optics for constructing and manipulating finite -- Seqs. module Data.Sequence.Optics -- | A Seq is isomorphic to a ViewL -- --
--   viewl m ≡ m ^. viewL
--   
-- --
--   >>> Seq.fromList [1,2,3] ^. viewL
--   1 :< fromList [2,3]
--   
-- --
--   >>> Seq.empty ^. viewL
--   EmptyL
--   
-- --
--   >>> EmptyL ^. re viewL
--   fromList []
--   
-- --
--   >>> review viewL $ 1 Seq.:< Seq.fromList [2,3]
--   fromList [1,2,3]
--   
viewL :: Iso (Seq a) (Seq b) (ViewL a) (ViewL b) -- | A Seq is isomorphic to a ViewR -- --
--   viewr m ≡ m ^. viewR
--   
-- --
--   >>> Seq.fromList [1,2,3] ^. viewR
--   fromList [1,2] :> 3
--   
-- --
--   >>> Seq.empty ^. viewR
--   EmptyR
--   
-- --
--   >>> EmptyR ^. re viewR
--   fromList []
--   
-- --
--   >>> review viewR $ Seq.fromList [1,2] Seq.:> 3
--   fromList [1,2,3]
--   
viewR :: Iso (Seq a) (Seq b) (ViewR a) (ViewR b) -- | Traverse all the elements numbered from i to j of a -- Seq -- --
--   >>> Seq.fromList [1,2,3,4,5] & sliced 1 3 %~ (*10)
--   fromList [1,20,30,4,5]
--   
-- --
--   >>> Seq.fromList [1,2,3,4,5] ^.. sliced 1 3
--   [2,3]
--   
-- --
--   >>> Seq.fromList [1,2,3,4,5] & sliced 1 3 .~ 0
--   fromList [1,0,0,4,5]
--   
sliced :: Int -> Int -> IxTraversal' Int (Seq a) a -- | Traverse the first n elements of a Seq -- --
--   >>> Seq.fromList [1,2,3,4,5] ^.. slicedTo 2
--   [1,2]
--   
-- --
--   >>> Seq.fromList [1,2,3,4,5] & slicedTo 2 %~ (*10)
--   fromList [10,20,3,4,5]
--   
-- --
--   >>> Seq.fromList [1,2,4,5,6] & slicedTo 10 .~ 0
--   fromList [0,0,0,0,0]
--   
slicedTo :: Int -> IxTraversal' Int (Seq a) a -- | Traverse all but the first n elements of a Seq -- --
--   >>> Seq.fromList [1,2,3,4,5] ^.. slicedFrom 2
--   [3,4,5]
--   
-- --
--   >>> Seq.fromList [1,2,3,4,5] & slicedFrom 2 %~ (*10)
--   fromList [1,2,30,40,50]
--   
-- --
--   >>> Seq.fromList [1,2,3,4,5] & slicedFrom 10 .~ 0
--   fromList [1,2,3,4,5]
--   
slicedFrom :: Int -> IxTraversal' Int (Seq a) a -- | Construct a Seq from a fold. -- --
--   >>> seqOf folded ["hello","world"]
--   fromList ["hello","world"]
--   
-- --
--   >>> seqOf (folded % _2) [("hello",1),("world",2),("!!!",3)]
--   fromList [1,2,3]
--   
seqOf :: Is k A_Fold => Optic' k is s a -> s -> Seq a