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

Safe Haskell | None
Language | Haskell2010

Optics.IxSetter

Contents

- Formation
- Introduction
- Elimination
- Computation
- Well-formedness
- Additional introduction forms
- Additional elimination forms
- Subtyping
- Re-exports

Description

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.

Synopsis

- type IxSetter i s t a b = Optic A_Setter (WithIx i) s t a b
- type IxSetter' i s a = Optic' A_Setter (WithIx i) s a
- isets :: ((i -> a -> b) -> s -> t) -> IxSetter i s t a b
- iover :: forall k (is :: IxList) i s t a b. (Is k A_Setter, HasSingleIndex is i) => Optic k is s t a b -> (i -> a -> b) -> s -> t
- imapped :: FunctorWithIndex i f => IxSetter i (f a) (f b) a b
- iset :: forall k (is :: IxList) i s t a b. (Is k A_Setter, HasSingleIndex is i) => Optic k is s t a b -> (i -> b) -> s -> t
- iset' :: forall k (is :: IxList) i s t a b. (Is k A_Setter, HasSingleIndex is i) => Optic k is s t a b -> (i -> b) -> s -> t
- iover' :: forall k (is :: IxList) i s t a b. (Is k A_Setter, HasSingleIndex is i) => Optic k is s t a b -> (i -> a -> b) -> s -> t
- data A_Setter
- class Functor f => FunctorWithIndex i (f :: Type -> Type) | f -> i where
  - imap :: (i -> a -> b) -> f a -> f b

# Formation

type IxSetter i s t a b = Optic A_Setter (WithIx i) s t a b Source #

Type synonym for a type-modifying indexed setter.

type IxSetter' i s a = Optic' A_Setter (WithIx i) s a Source #

Type synonym for a type-preserving indexed setter.

# Introduction

isets :: ((i -> a -> b) -> s -> t) -> IxSetter i s t a b Source #

Build an indexed setter from a function to modify the element(s).

# Elimination

iover :: forall k (is :: IxList) i s t a b. (Is k A_Setter, HasSingleIndex is i) => Optic k is s t a b -> (i -> a -> b) -> s -> t Source #

Apply an indexed setter as a modifier.

# Computation

    iover (isets f) ≡ f

# Well-formedness

- PutPut: Setting twice is the same as setting once:

      iset l v' (iset l v s) ≡ iset l v' s

- Functoriality: `IxSetter`s must preserve identities and composition:

      iover s (const id) ≡ id
      iover s f . iover s g ≡ iover s (i -> f i . g i)

# Additional introduction forms

imapped :: FunctorWithIndex i f => IxSetter i (f a) (f b) a b Source #

Indexed setter via the `FunctorWithIndex` class.

    iover imapped ≡ imap

# Additional elimination forms

iset :: forall k (is :: IxList) i s t a b. (Is k A_Setter, HasSingleIndex is i) => Optic k is s t a b -> (i -> b) -> s -> t Source #

Apply an indexed setter.

    iset o f ≡ iover o (i _ -> f i)

iset' :: forall k (is :: IxList) i s t a b. (Is k A_Setter, HasSingleIndex is i) => Optic k is s t a b -> (i -> b) -> s -> t Source #

Apply an indexed setter, strictly.

iover' :: forall k (is :: IxList) i s t a b. (Is k A_Setter, HasSingleIndex is i) => Optic k is s t a b -> (i -> a -> b) -> s -> t Source #

Apply an indexed setter as a modifier, strictly.

# Subtyping

data A_Setter Source #

Tag for a setter.

#### Instances

Instances details

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

# Re-exports

class Functor f => FunctorWithIndex i (f :: Type -> Type) | f -> i where Source #

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

Minimal complete definition

Nothing

Methods

imap :: (i -> a -> b) -> f a -> f b Source #

Map with access to the index.

default imap :: TraversableWithIndex i f => (i -> a -> b) -> f a -> f b Source #

#### Instances

Instances details

FunctorWithIndex () Identity |
Instance details Defined in WithIndex Methods imap :: (() -> a -> b) -> Identity a -> Identity b Source #
FunctorWithIndex () Par1 |
Instance details Defined in WithIndex Methods imap :: (() -> a -> b) -> Par1 a -> Par1 b Source #
FunctorWithIndex () Maybe |
Instance details Defined in WithIndex Methods imap :: (() -> a -> b) -> Maybe a -> Maybe b Source #
FunctorWithIndex Int IntMap |
Instance details Defined in WithIndex Methods imap :: (Int -> a -> b) -> IntMap a -> IntMap b Source #
FunctorWithIndex Int Seq | The position in the `Seq` is available as the index.
Instance details Defined in WithIndex Methods imap :: (Int -> a -> b) -> Seq a -> Seq b Source #
FunctorWithIndex Int NonEmpty |
Instance details Defined in WithIndex Methods imap :: (Int -> a -> b) -> NonEmpty a -> NonEmpty b Source #
FunctorWithIndex Int ZipList | Same instance as for `[]`.
Instance details Defined in WithIndex Methods imap :: (Int -> a -> b) -> ZipList a -> ZipList b Source #
FunctorWithIndex Int [] | The position in the list is available as the index.
Instance details Defined in WithIndex Methods imap :: (Int -> a -> b) -> [a] -> [b] Source #
FunctorWithIndex Void (Proxy :: Type -> Type) |
Instance details Defined in WithIndex Methods imap :: (Void -> a -> b) -> Proxy a -> Proxy b Source #
FunctorWithIndex Void (U1 :: Type -> Type) |
Instance details Defined in WithIndex Methods imap :: (Void -> a -> b) -> U1 a -> U1 b Source #
FunctorWithIndex Void (V1 :: Type -> Type) |
Instance details Defined in WithIndex Methods imap :: (Void -> a -> b) -> V1 a -> V1 b Source #
Ix i => FunctorWithIndex i (Array i) |
Instance details Defined in WithIndex Methods imap :: (i -> a -> b) -> Array i a -> Array i b Source #
FunctorWithIndex k (Map k) |
Instance details Defined in WithIndex Methods imap :: (k -> a -> b) -> Map k a -> Map k b Source #
FunctorWithIndex k ((,) k) |
Instance details Defined in WithIndex Methods imap :: (k -> a -> b) -> (k, a) -> (k, b) Source #
FunctorWithIndex Void (Const e :: Type -> Type) |
Instance details Defined in WithIndex Methods imap :: (Void -> a -> b) -> Const e a -> Const e b Source #
FunctorWithIndex Void (Constant e :: Type -> Type) |
Instance details Defined in WithIndex Methods imap :: (Void -> a -> b) -> Constant e a -> Constant e b Source #
FunctorWithIndex i f => FunctorWithIndex i (Rec1 f) |
Instance details Defined in WithIndex Methods imap :: (i -> a -> b) -> Rec1 f a -> Rec1 f b Source #
FunctorWithIndex i f => FunctorWithIndex i (Backwards f) |
Instance details Defined in WithIndex Methods imap :: (i -> a -> b) -> Backwards f a -> Backwards f b Source #
FunctorWithIndex i m => FunctorWithIndex i (IdentityT m) |
Instance details Defined in WithIndex Methods imap :: (i -> a -> b) -> IdentityT m a -> IdentityT m b Source #
FunctorWithIndex i f => FunctorWithIndex i (Reverse f) |
Instance details Defined in WithIndex Methods imap :: (i -> a -> b) -> Reverse f a -> Reverse f b Source #
FunctorWithIndex Void (K1 i c :: Type -> Type) |
Instance details Defined in WithIndex Methods imap :: (Void -> a -> b) -> K1 i c a -> K1 i c b Source #
FunctorWithIndex r ((->) r) |
Instance details Defined in WithIndex Methods imap :: (r -> a -> b) -> (r -> a) -> r -> b Source #
FunctorWithIndex [Int] Tree |
Instance details Defined in WithIndex Methods imap :: ([Int] -> a -> b) -> Tree a -> Tree b Source #
FunctorWithIndex i m => FunctorWithIndex (e, i) (ReaderT e m) |
Instance details Defined in WithIndex Methods imap :: ((e, i) -> a -> b) -> ReaderT e m a -> ReaderT e m b Source #
(FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (Either i j) (Product f g) |
Instance details Defined in WithIndex Methods imap :: (Either i j -> a -> b) -> Product f g a -> Product f g b Source #
(FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (Either i j) (Sum f g) |
Instance details Defined in WithIndex Methods imap :: (Either i j -> a -> b) -> Sum f g a -> Sum f g b Source #
(FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (Either i j) (f :*: g) |
Instance details Defined in WithIndex Methods imap :: (Either i j -> a -> b) -> (f :*: g) a -> (f :*: g) b Source #
(FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (Either i j) (f :+: g) |
Instance details Defined in WithIndex Methods imap :: (Either i j -> a -> b) -> (f :+: g) a -> (f :+: g) b Source #
(FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (i, j) (Compose f g) |
Instance details Defined in WithIndex Methods imap :: ((i, j) -> a -> b) -> Compose f g a -> Compose f g b Source #
(FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (i, j) (f :.: g) |
Instance details Defined in WithIndex Methods imap :: ((i, j) -> a -> b) -> (f :.: g) a -> (f :.: g) b Source #