Data.Lens.Zoom
- Package
- purescript-profunctor-lenses
- Repository
- purescript-contrib/purescript-profunctor-lenses
This module defines functions for zooming in a state monad.
Re-exports from Data.Lens.Types
#Traversal' Source
type Traversal' s a = Traversal s s a a#Traversal Source
type Traversal s t a b = forall p. Wander p => Optic p s t a bThe specialized type Traversal s a means that the type s contains zero, one, or many values of type a.
They're especially useful when working with collections like arrays, maps, and any other member of the Traversable type class.
They are also a more general form of lenses and prisms.
Traversals which focus on at most one element (like lenses, prisms, and their composition) are called affine traversals.
#Tagged Source
#Re Source
#Lens' Source
type Lens' s a = Lens s s a aLens' is a specialization of Lens. An optic of type Lens'
can change only the value of its focus,
not its type. As an example, consider the Lens _2, which has this type:
_2 :: forall s t a b. Lens (Tuple s a) (Tuple t b) a b
_2 can produce a Tuple Int String from a Tuple Int Int:
set _2 "NEW" (Tuple 1 2) == (Tuple 1 "NEW")
If we specialize _2's type with Lens', the following will not
type check:
set (_2 :: Lens' (Tuple Int Int) Int) "NEW" (Tuple 1 2)
^^^^^^^^^^^^^^^^^^^^^^^^^
See Data.Lens.Getter and Data.Lens.Setter for functions and operators
frequently used with lenses.
#Lens Source
type Lens s t a b = forall p. Strong p => Optic p s t a bGiven a type whose "focus element" always exists, a lens provides a convenient way to view, set, and transform that element.
For example, _2 is a tuple-specific Lens available from Data.Lens, so:
over _2 String.length $ Tuple "ignore" "four" == Tuple "ignore" 4
Note the result has a different type than the original tuple.
That is, the four Lens type variables have been narrowed to:
sisTuple String StringtisTuple String IntaisStringbisInt
See Data.Lens.Getter and Data.Lens.Setter for functions and operators
frequently used with lenses.
#Iso Source
type Iso s t a b = forall p. Profunctor p => Optic p s t a bA generalized isomorphism.
Isos are the most constrained optic, simply enabling you to transform back and forth between two types without losing information.
The specialized type Iso' s a means that s and a are isomorphic – the two types represent the same information.
They’re especially useful when you need to unwrap a newtype or transform an array to a list or otherwise convert between types.
This optic is also useful for backward compatibility without boilerplate.
#IndexedTraversal' Source
type IndexedTraversal' i s a = IndexedTraversal i s s a a#IndexedTraversal Source
type IndexedTraversal i s t a b = forall p. Wander p => IndexedOptic p i s t a b#IndexedSetter' Source
type IndexedSetter' i s a = IndexedSetter i s s a a#IndexedSetter Source
type IndexedSetter i s t a b = IndexedOptic Function i s t a b#IndexedOptic' Source
type IndexedOptic' :: (Type -> Type -> Type) -> Type -> Type -> Type -> Typetype IndexedOptic' p i s a = IndexedOptic p i s s a a
#IndexedLens' Source
type IndexedLens' i s a = IndexedLens i s s a a#IndexedLens Source
type IndexedLens i s t a b = forall p. Strong p => IndexedOptic p i s t a bAn indexed lens.
#IndexedGetter' Source
type IndexedGetter' i s a = IndexedGetter i s s a a#IndexedGetter Source
type IndexedGetter i s t a b = IndexedFold a i s t a b#IndexedFold' Source
type IndexedFold' r i s a = IndexedFold r i s s a a#IndexedFold Source
type IndexedFold r i s t a b = IndexedOptic (Forget r) i s t a b#Indexed Source
#Forget Source
#AnIndexedLens' Source
type AnIndexedLens' i s a = AnIndexedLens i s s a a#AnIndexedLens Source
type AnIndexedLens i s t a b = IndexedOptic (Shop (Tuple i a) b) i s t a bAn indexed lens defined in terms of Shop, which can be used
to avoid issues with impredicativity.
#AnAffineTraversal' Source
type AnAffineTraversal' s a = AnAffineTraversal s s a a#AnAffineTraversal Source
type AnAffineTraversal s t a b = Optic (Stall a b) s t a bAn affine traversal defined in terms of Stall, which can be used
to avoid issues with impredicativity.
#AffineTraversal' Source
type AffineTraversal' s a = AffineTraversal s s a a#AffineTraversal Source
type AffineTraversal s t a b = forall p. Strong p => Choice p => Optic p s t a bAn affine traversal (has at most one focus, but is not a prism).
#ATraversal' Source
type ATraversal' s a = ATraversal s s a a#ATraversal Source
type ATraversal s t a b = Optic (Bazaar Function a b) s t a bA traversal defined in terms of Bazaar, which can be used
to avoid issues with impredicativity.
#Wander Source
class Wander :: (Type -> Type -> Type) -> Constraintclass (Strong p, Choice p) <= Wander p where
Class for profunctors that support polymorphic traversals.
Members
wander :: forall s t a b. (forall f. Applicative f => (a -> f b) -> s -> f t) -> p a b -> p s t
Instances
Wander Function(Applicative f) => Wander (Star f)
- Modules
- Data.
Lens - Data.
Lens. AffineTraversal - Data.
Lens. At - Data.
Lens. Common - Data.
Lens. Fold - Data.
Lens. Fold. Partial - Data.
Lens. Getter - Data.
Lens. Grate - Data.
Lens. Index - Data.
Lens. Indexed - Data.
Lens. Internal. Bazaar - Data.
Lens. Internal. Exchange - Data.
Lens. Internal. Focusing - Data.
Lens. Internal. Forget - Data.
Lens. Internal. Grating - Data.
Lens. Internal. Indexed - Data.
Lens. Internal. Market - Data.
Lens. Internal. Re - Data.
Lens. Internal. Shop - Data.
Lens. Internal. Stall - Data.
Lens. Internal. Tagged - Data.
Lens. Internal. Wander - Data.
Lens. Internal. Zipping - Data.
Lens. Iso - Data.
Lens. Iso. Newtype - Data.
Lens. Lens - Data.
Lens. Lens. Product - Data.
Lens. Lens. Tuple - Data.
Lens. Lens. Unit - Data.
Lens. Lens. Void - Data.
Lens. Prism - Data.
Lens. Prism. Coproduct - Data.
Lens. Prism. Either - Data.
Lens. Prism. Maybe - Data.
Lens. Record - Data.
Lens. Setter - Data.
Lens. Traversal - Data.
Lens. Types - Data.
Lens. Zoom