optics-core-0.4.1: Optics as an abstract interface: core definitions
Safe Haskell None
Language Haskell2010

Optics.Getter

Description

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/ Getter s alone, but when you are composing multiple Optic s to produce a Getter .

Synopsis

Formation

type Getter s a = Optic' A_Getter NoIx s a Source #

Type synonym for a getter.

Introduction

to :: (s -> a) -> Getter s a Source #

Build a getter from a function.

Elimination

view :: Is k A_Getter => Optic' k is s a -> s -> a Source #

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 .

views :: Is k A_Getter => Optic' k is s a -> (a -> r) -> s -> r Source #

View the function of the value pointed to by a getter.

Computation

view (to f) ≡ f

Well-formedness

A Getter is not subject to any laws.

Subtyping

data A_Getter :: OpticKind Source #

Tag for a getter.

Instances

Instances details
ReversibleOptic A_Getter Source #
Instance details

Defined in Optics.Re

Associated Types

type ReversedOptic A_Getter = (r :: Type ) Source #

Methods

re :: forall (is :: IxList ) s t a b. AcceptsEmptyIndices "re" is => Optic A_Getter is s t a b -> Optic ( ReversedOptic A_Getter ) is b a t s Source #

Is A_Getter A_Fold Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

Is A_Getter An_AffineFold Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

Is A_ReversedPrism A_Getter Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

Is A_Lens A_Getter Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

Is An_Iso A_Getter Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

k ~ A_Fold => JoinKinds A_Fold A_Getter k Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

k ~ An_AffineFold => JoinKinds An_AffineFold A_Getter k Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

k ~ A_Fold => JoinKinds A_Getter A_Fold k Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

k ~ An_AffineFold => JoinKinds A_Getter An_AffineFold k Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

k ~ A_Getter => JoinKinds A_Getter A_Getter k Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

k ~ A_Getter => JoinKinds A_Getter A_ReversedPrism k Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

k ~ A_Fold => JoinKinds A_Getter A_Traversal k Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

k ~ An_AffineFold => JoinKinds A_Getter An_AffineTraversal k Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

k ~ An_AffineFold => JoinKinds A_Getter A_Prism k Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

k ~ A_Getter => JoinKinds A_Getter A_Lens k Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

k ~ A_Getter => JoinKinds A_Getter An_Iso k Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

k ~ A_Getter => JoinKinds A_ReversedPrism A_Getter k Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

k ~ A_Fold => JoinKinds A_Traversal A_Getter k Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

k ~ An_AffineFold => JoinKinds An_AffineTraversal A_Getter k Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

k ~ An_AffineFold => JoinKinds A_Prism A_Getter k Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

k ~ A_Getter => JoinKinds A_Lens A_Getter k Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

k ~ A_Getter => JoinKinds An_Iso A_Getter k Source #
Instance details

Defined in Optics.Internal.Optic.Subtyping

(s ~ t, a ~ b) => ToReadOnly A_Getter s t a b Source #
Instance details

Defined in Optics.ReadOnly

(s ~ t, a ~ b) => IxOptic A_Getter s t a b Source #
Instance details

Defined in Optics.Indexed.Core

( Functor f, f ~ g, s ~ t, a ~ b) => MappingOptic A_Getter f g s t a b Source #
>>> [('a', True), ('b', False)] ^. _1 %& mapping
"ab"
>>> let v = [[ (('a', True), "foo"), (('b', False), "bar")], [ (('c', True), "xyz") ] ]
>>> v ^. _1 % _2 %& mapping %& mapping
[[True,False],[True]]
Instance details

Defined in Optics.Mapping

Methods

mapping :: forall (is :: IxList ). AcceptsEmptyIndices "mapping" is => Optic A_Getter is s t a b -> Optic ( MappedOptic A_Getter ) is (f s) (g t) (f a) (g b) Source #

type ReversedOptic A_Getter Source #
Instance details

Defined in Optics.Re

type ReadOnlyOptic A_Getter Source #
Instance details

Defined in Optics.ReadOnly

type MappedOptic A_Getter Source #
Instance details

Defined in Optics.Mapping