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

Safe HaskellNone
LanguageHaskell2010

Optics.Getter

Contents

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/Getters alone, but when you are composing multiple Optics 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.

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 Source #

Tag for a getter.

Instances
ReversibleOptic A_Getter Source # 
Instance details

Defined in Optics.Re

Associated Types

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

Methods

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

Methods

implies :: proxy A_Getter A_Fold p -> (Constraints A_Getter p -> r) -> Constraints A_Fold p -> r Source #

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

Methods

implies :: proxy A_Lens A_Getter p -> (Constraints A_Lens p -> r) -> Constraints A_Getter p -> r Source #

Is An_Iso A_Getter Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

implies :: proxy An_Iso A_Getter p -> (Constraints An_Iso p -> r) -> Constraints A_Getter p -> r Source #

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

Defined in Optics.ReadOnly

Methods

getting :: Optic A_Getter is s t a b -> Optic' (Join A_Getter A_Getter) is s a Source #

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

Defined in Optics.Indexed.Core

Methods

noIx :: NonEmptyIndices is => Optic A_Getter is s t a b -> Optic A_Getter NoIx s t a b Source #

type ReversedOptic A_Getter Source # 
Instance details

Defined in Optics.Re