HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Moduleoptics-core-0.4.2Haskell2010

Optics.ReversedPrism

A ReversedPrism is a backwards Prism, i.e. a ReversedPrism s t a b is equivalent to a Prism b a t s. These are typically produced by calling re on a Prism. They are distinguished from a Getter so that re . re on a Prism returns a Prism.

Contents
  1. Formation
  2. Introduction
  3. Elimination
  4. Computation
  5. Subtyping
Synopsis
  • Packageoptics-core-0.4.2
  • Exports3
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceReversedPrism.hs

Formation

Introduction

There is no canonical introduction form for ReversedPrism, but you can use re to construct one from a Prism:

(\ f g -> re (prism f g)) :: (s -> a) -> (b -> Either a t) -> ReversedPrism s t a b

Elimination

A ReversedPrism is a Getter, so you can specialise types to obtain:

view :: ReversedPrism' s a -> s -> a

There is no reversed matching defined, but it is definable using re:

matching . re :: ReversedPrism s t a b -> b -> Either a t

Computation

view          $ re (prism f g) ≡ f
matching . re $ re (prism f g) ≡ g

Subtyping

Tag for a reversed prism.

Instances27ReversibleOptic, Is, JoinKinds, ToReadOnly, MappingOptic, MappedOptic, …