optics-core-0.4.1.1: Optics as an abstract interface: core definitions

Safe Haskell | None
Language | Haskell2010

Optics.IxAffineFold

Contents

- Formation
- Introduction
- Elimination
- Computation
- Additional introduction forms
- Additional elimination forms
- Combinators
- Monoid structure
- Subtyping

Description

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.

Synopsis

- type IxAffineFold i s a = Optic' An_AffineFold (WithIx i) s a
- iafolding :: (s -> Maybe (i, a)) -> IxAffineFold i s a
- ipreview :: forall k (is :: IxList) i s a. (Is k An_AffineFold, HasSingleIndex is i) => Optic' k is s a -> s -> Maybe (i, a)
- ipreviews :: forall k (is :: IxList) i s a r. (Is k An_AffineFold, HasSingleIndex is i) => Optic' k is s a -> (i -> a -> r) -> s -> Maybe r
- iafoldVL :: (forall (f :: Type -> Type). Functor f => (forall r. r -> f r) -> (i -> a -> f u) -> s -> f v) -> IxAffineFold i s a
- iatraverseOf_ :: forall k f (is :: IxList) i s a u. (Is k An_AffineFold, Functor f, HasSingleIndex is i) => Optic' k is s a -> (forall r. r -> f r) -> (i -> a -> f u) -> s -> f ()
- filteredBy :: forall k (is :: IxList) a i. Is k An_AffineFold => Optic' k is a i -> IxAffineFold i a a
- iafailing :: forall k l (is1 :: IxList) i (is2 :: IxList) s a. (Is k An_AffineFold, Is l An_AffineFold, HasSingleIndex is1 i, HasSingleIndex is2 i) => Optic' k is1 s a -> Optic' l is2 s a -> IxAffineFold i s a
- data An_AffineFold

# Formation

type IxAffineFold i s a = Optic' An_AffineFold (WithIx i) s a Source #

Type synonym for an indexed affine fold.

# Introduction

iafolding :: (s -> Maybe (i, a)) -> IxAffineFold i s a Source #

Create an `IxAffineFold` from a partial function.

# Elimination

ipreview :: forall k (is :: IxList) i s a. (Is k An_AffineFold, HasSingleIndex is i) => Optic' k is s a -> s -> Maybe (i, a) Source #

Retrieve the value along with its index targeted by an `IxAffineFold`.

ipreviews :: forall k (is :: IxList) i s a r. (Is k An_AffineFold, HasSingleIndex is i) => Optic' k is s a -> (i -> a -> r) -> s -> Maybe r Source #

Retrieve a function of the value and its index targeted by an `IxAffineFold`.

# Computation

    ipreview (iafolding f) ≡ f

# Additional introduction forms

iafoldVL :: (forall (f :: Type -> Type). Functor f => (forall r. r -> f r) -> (i -> a -> f u) -> s -> f v) -> IxAffineFold i s a Source #

Obtain an `IxAffineFold` by lifting `itraverse_` like function.

    aifoldVL . iatraverseOf_ ≡ id
    aitraverseOf_ . iafoldVL ≡ id

Since: 0.3

# Additional elimination forms

iatraverseOf_ :: forall k f (is :: IxList) i s a u. (Is k An_AffineFold, Functor f, HasSingleIndex is i) => Optic' k is s a -> (forall r. r -> f r) -> (i -> a -> f u) -> s -> f () Source #

Traverse over the target of an `IxAffineFold`, computing a `Functor`-based answer, but unlike `iatraverseOf` do not construct a new structure.

Since: 0.3

# Combinators

filteredBy :: forall k (is :: IxList) a i. Is k An_AffineFold => Optic' k is a i -> IxAffineFold i a a Source #

Obtain a potentially empty `IxAffineFold` by taking the element from another `AffineFold` and using it as an index.

Since: 0.3

# Monoid structure

`IxAffineFold` admits a monoid structure where `iafailing` combines folds (returning a result from the second fold only if the first returns none) and the identity element is `ignored` (which returns no results).

Note: There is no `isumming` equivalent that returns an `IxAffineFold`, because it would not need to return more than one result.

There is no `Semigroup` or `Monoid` instance for `IxAffineFold`, because there is not a unique choice of monoid to use that works for all optics, and the (`<>`) operator could not be used to combine optics of different kinds.

iafailing :: forall k l (is1 :: IxList) i (is2 :: IxList) s a. (Is k An_AffineFold, Is l An_AffineFold, HasSingleIndex is1 i, HasSingleIndex is2 i) => Optic' k is1 s a -> Optic' l is2 s a -> IxAffineFold i s a infixl 3 Source #

Try the first `IxAffineFold`. If it returns no entry, try the second one.

# Subtyping

data An_AffineFold Source #

Tag for an affine fold.

#### Instances

Instances details

Is A_Getter An_AffineFold Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods implies :: forall (p :: Type -> Type -> Type -> Type) r. (Constraints A_Getter p => r) -> Constraints An_AffineFold p => r Source #
Is A_Lens An_AffineFold Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods implies :: forall (p :: Type -> Type -> Type -> Type) r. (Constraints A_Lens p => r) -> Constraints An_AffineFold p => r Source #
Is A_Prism An_AffineFold Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods implies :: forall (p :: Type -> Type -> Type -> Type) r. (Constraints A_Prism p => r) -> Constraints An_AffineFold p => r Source #
Is A_ReversedPrism An_AffineFold Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods implies :: forall (p :: Type -> Type -> Type -> Type) r. (Constraints A_ReversedPrism p => r) -> Constraints An_AffineFold p => r Source #
Is An_AffineFold A_Fold Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods implies :: forall (p :: Type -> Type -> Type -> Type) r. (Constraints An_AffineFold p => r) -> Constraints A_Fold p => r Source #
Is An_AffineTraversal An_AffineFold Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods implies :: forall (p :: Type -> Type -> Type -> Type) r. (Constraints An_AffineTraversal p => r) -> Constraints An_AffineFold p => r Source #
Is An_Iso An_AffineFold Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods implies :: forall (p :: Type -> Type -> Type -> Type) r. (Constraints An_Iso p => r) -> Constraints An_AffineFold p => r Source #
k ~ A_Fold => JoinKinds A_Fold An_AffineFold k Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_Fold p, Constraints An_AffineFold p) => r) -> Constraints k p => r Source #
k ~ An_AffineFold => JoinKinds A_Getter An_AffineFold k Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_Getter p, Constraints An_AffineFold p) => r) -> Constraints k p => r Source #
k ~ An_AffineFold => JoinKinds A_Lens An_AffineFold k Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_Lens p, Constraints An_AffineFold p) => r) -> Constraints k p => r Source #
k ~ An_AffineFold => JoinKinds A_Prism An_AffineFold k Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_Prism p, Constraints An_AffineFold p) => r) -> Constraints k p => r Source #
k ~ An_AffineFold => JoinKinds A_ReversedPrism An_AffineFold k Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_ReversedPrism p, Constraints An_AffineFold p) => r) -> Constraints k p => r Source #
k ~ A_Fold => JoinKinds A_Traversal An_AffineFold k Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_Traversal p, Constraints An_AffineFold p) => r) -> Constraints k p => r Source #
k ~ A_Fold => JoinKinds An_AffineFold A_Fold k Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints An_AffineFold p, Constraints A_Fold p) => r) -> Constraints k p => r Source #
k ~ An_AffineFold => JoinKinds An_AffineFold A_Getter k Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints An_AffineFold p, Constraints A_Getter p) => r) -> Constraints k p => r Source #
k ~ An_AffineFold => JoinKinds An_AffineFold A_Lens k Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints An_AffineFold p, Constraints A_Lens p) => r) -> Constraints k p => r Source #
k ~ An_AffineFold => JoinKinds An_AffineFold A_Prism k Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints An_AffineFold p, Constraints A_Prism p) => r) -> Constraints k p => r Source #
k ~ An_AffineFold => JoinKinds An_AffineFold A_ReversedPrism k Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints An_AffineFold p, Constraints A_ReversedPrism p) => r) -> Constraints k p => r Source #
k ~ A_Fold => JoinKinds An_AffineFold A_Traversal k Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints An_AffineFold p, Constraints A_Traversal p) => r) -> Constraints k p => r Source #
k ~ An_AffineFold => JoinKinds An_AffineFold An_AffineFold k Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints An_AffineFold p, Constraints An_AffineFold p) => r) -> Constraints k p => r Source #
k ~ An_AffineFold => JoinKinds An_AffineFold An_AffineTraversal k Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints An_AffineFold p, Constraints An_AffineTraversal p) => r) -> Constraints k p => r Source #
k ~ An_AffineFold => JoinKinds An_AffineFold An_Iso k Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints An_AffineFold p, Constraints An_Iso p) => r) -> Constraints k p => r Source #
k ~ An_AffineFold => JoinKinds An_AffineTraversal An_AffineFold k Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints An_AffineTraversal p, Constraints An_AffineFold p) => r) -> Constraints k p => r Source #
k ~ An_AffineFold => JoinKinds An_Iso An_AffineFold k Source # |
Instance details Defined in Optics.Internal.Optic.Subtyping Methods joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints An_Iso p, Constraints An_AffineFold p) => r) -> Constraints k p => r Source #
(s ~ t, a ~ b) => IxOptic An_AffineFold s t a b Source # |
Instance details Defined in Optics.Indexed.Core Methods noIx :: forall (is :: IxList). NonEmptyIndices is => Optic An_AffineFold is s t a b -> Optic An_AffineFold NoIx s t a b Source #
(s ~ t, a ~ b) => ToReadOnly An_AffineFold s t a b Source # |

Instance details

Defined in Optics.ReadOnly

Associated Types

type ReadOnlyOptic An_AffineFold |
Instance details Defined in Optics.ReadOnly type ReadOnlyOptic An_AffineFold = An_AffineFold

Methods

getting :: forall (is :: IxList). Optic An_AffineFold is s t a b -> Optic' (ReadOnlyOptic An_AffineFold) is s a Source #

type ReadOnlyOptic An_AffineFold Source # |
Instance details Defined in Optics.ReadOnly type ReadOnlyOptic An_AffineFold = An_AffineFold