HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleoptics-core-0.4.1.1Haskell2010

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

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, …