Module

Data.Lens.Types

This module defines types for working with lenses.

All optics have their normal name (e.g. Lens) and one whose name is prefixed with either "A" or "An" (e.g. ALens). Prefixed versions avoid the issue of "impredicativity". To understand that concept more and why prefixed names are sometimes necessary, see the ./docs folder.

#AGetter

type AGetter s t a b = Fold a s t a b

#AGetter'

type AGetter' s a = AGetter s s a a

#AGrate

type AGrate s t a b = Optic (Grating a b) s t a b

A grate defined in terms of Grating, which can be used to avoid issues with impredicativity.

#AGrate'

type AGrate' s a = AGrate s s a a

#ALens

type ALens s t a b = Optic (Shop a b) s t a b

A lens defined in terms of Shop, which can be used to avoid issues with impredicativity.

#ALens'

type ALens' s a = ALens s s a a

#APrism

type APrism s t a b = Optic (Market a b) s t a b

A prism defined in terms of Market to be safe from impredicativity issues in the type checker. See the docs/ folder for a more detailed explanation.

#APrism'

type APrism' s a = APrism s s a a

#ATraversal

type ATraversal s t a b = Optic (Bazaar Function a b) s t a b

A traversal defined in terms of Bazaar, which can be used to avoid issues with impredicativity.

#ATraversal'

type ATraversal' s a = ATraversal s s a a

#AffineTraversal

type AffineTraversal s t a b = forall p. Strong p => Choice p => Optic p s t a b

An affine traversal (has at most one focus, but is not a prism).

#AffineTraversal'

#AnAffineTraversal

type AnAffineTraversal s t a b = Optic (Stall a b) s t a b

An affine traversal defined in terms of Stall, which can be used to avoid issues with impredicativity.

#AnAffineTraversal'

#AnIndexedLens

type AnIndexedLens i s t a b = IndexedOptic (Shop (Tuple i a) b) i s t a b

An indexed lens defined in terms of Shop, which can be used to avoid issues with impredicativity.

#AnIndexedLens'

type AnIndexedLens' i s a = AnIndexedLens i s s a a

#AnIso

type AnIso s t a b = Optic (Exchange a b) s t a b

An isomorphism defined in terms of Exchange, which can be used to avoid issues with impredicativity.

#AnIso'

type AnIso' s a = AnIso s s a a

#Fold

type Fold r s t a b = Optic (Forget r) s t a b

A fold.

#Fold'

type Fold' r s a = Fold r s s a a

#Getter

type Getter s t a b = forall r. Fold r s t a b

A getter.

#Getter'

type Getter' s a = Getter s s a a

#Grate

type Grate s t a b = forall p. Closed p => Optic p s t a b

A grate (http://r6research.livejournal.com/28050.html)

#Grate'

type Grate' s a = Grate s s a a

#IndexedFold

type IndexedFold r i s t a b = IndexedOptic (Forget r) i s t a b

An indexed fold.

#IndexedFold'

type IndexedFold' r i s a = IndexedFold r i s s a a

#IndexedGetter

type IndexedGetter i s t a b = IndexedFold a i s t a b

An indexed getter.

#IndexedGetter'

type IndexedGetter' i s a = IndexedGetter i s s a a

#IndexedLens

type IndexedLens i s t a b = forall p. Strong p => IndexedOptic p i s t a b

An indexed lens.

#IndexedLens'

type IndexedLens' i s a = IndexedLens i s s a a

#IndexedOptic

type IndexedOptic :: (Type -> Type -> Type) -> Type -> Type -> Type -> Type -> Type -> Typetype IndexedOptic p i s t a b = Indexed p i a b -> p s t

An indexed optic.

#IndexedOptic'

type IndexedOptic' :: (Type -> Type -> Type) -> Type -> Type -> Type -> Typetype IndexedOptic' p i s a = IndexedOptic p i s s a a

#IndexedSetter

type IndexedSetter i s t a b = IndexedOptic Function i s t a b

An indexed setter.

#IndexedSetter'

type IndexedSetter' i s a = IndexedSetter i s s a a

#IndexedTraversal

type IndexedTraversal i s t a b = forall p. Wander p => IndexedOptic p i s t a b

An indexed traversal.

#IndexedTraversal'

type IndexedTraversal' i s a = IndexedTraversal i s s a a

#Iso

type Iso s t a b = forall p. Profunctor p => Optic p s t a b

A generalized isomorphism.

#Iso'

type Iso' s a = Iso s s a a

#Lens

type Lens s t a b = forall p. Strong p => Optic p s t a b

Given 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:

  • s is Tuple String String
  • t is Tuple String Int
  • a is String
  • b is Int

See Data.Lens.Getter and Data.Lens.Setter for functions and operators frequently used with lenses.

#Lens'

type Lens' s a = Lens s s a a

Lens' 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.

#Optic

type Optic :: (Type -> Type -> Type) -> Type -> Type -> Type -> Type -> Typetype Optic p s t a b = p a b -> p s t

A general-purpose Data.Lens.

#Optic'

type Optic' :: (Type -> Type -> Type) -> Type -> Type -> Typetype Optic' p s a = Optic p s s a a

#Prism

type Prism s t a b = forall p. Choice p => Optic p s t a b

A prism.

#Prism'

type Prism' s a = Prism s s a a

#Review

type Review s t a b = Optic Tagged s t a b

A review.

#Review'

type Review' s a = Review s s a a

#Setter

type Setter s t a b = Optic Function s t a b

A setter.

#Setter'

type Setter' s a = Setter s s a a

#Traversal

type Traversal s t a b = forall p. Wander p => Optic p s t a b

A traversal.

#Traversal'

type Traversal' s a = Traversal s s a a

Re-exports from Data.Lens.Internal.Exchange

#Exchange

data Exchange a b s t

The Exchange profunctor characterizes an Iso.

Constructors

Instances

Re-exports from Data.Lens.Internal.Forget

#Forget

newtype Forget :: forall k. Type -> Type -> k -> Typenewtype Forget r a b

Profunctor that forgets the b value and returns (and accumulates) a value of type r.

Forget r is isomorphic to Star (Const r), but can be given a Cochoice instance.

Constructors

Instances

Re-exports from Data.Lens.Internal.Grating

#Grating

newtype Grating a b s t

Instances

Re-exports from Data.Lens.Internal.Indexed

#Indexed

newtype Indexed :: (Type -> Type -> Type) -> Type -> Type -> Type -> Typenewtype Indexed p i s t

Profunctor used for IndexedOptics.

Constructors

Instances

Re-exports from Data.Lens.Internal.Market

#Market

data Market a b s t

The Market profunctor characterizes a Prism.

Constructors

Instances

Re-exports from Data.Lens.Internal.Re

#Re

newtype Re :: (Type -> Type -> Type) -> Type -> Type -> Type -> Type -> Typenewtype Re p s t a b

Constructors

  • Re (p b a -> p t s)

Instances

Re-exports from Data.Lens.Internal.Shop

#Shop

data Shop a b s t

The Shop profunctor characterizes a Lens.

Constructors

  • Shop (s -> a) (s -> b -> t)

Instances

Re-exports from Data.Lens.Internal.Stall

#Stall

data Stall a b s t

The Stall profunctor characterizes an AffineTraversal.

Constructors

Instances

Re-exports from Data.Lens.Internal.Tagged

#Tagged

newtype Tagged :: forall k. k -> Type -> Typenewtype Tagged a b

Constructors

Instances

Re-exports from Data.Lens.Internal.Wander

#Wander

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

Modules