HORIZON HASKELLDocslts/ghc-10.0.x8174fa42026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8174fa4 · 2026-10-11

Moduleoptics-core-0.4.2Haskell2010

Optics.Getter

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.

  • 2 types
  • 3 values
  • Packageoptics-core-0.4.2
  • Exports5
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceGetter.hs

Formation

1 declaration

Introduction

1 declaration
valueto :: (s -> a) -> Getter s a
#

Build a getter from a function.

Elimination

2 declarations
valueview :: Is k A_Getter => Optic' k is s a -> s -> a
#

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.

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

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

Computation

0 declarations
view (to f) ≡ f

Well-formedness

0 declarations

A Getter is not subject to any laws.

Subtyping

1 declaration
datadata A_Getter
#

Tag for a getter.

Instances29ReversibleOptic, Is, JoinKinds, IxOptic, ToReadOnly, MappingOptic, …