proto-lens-0.7.1.3: A lens-based implementation of protocol buffers in Haskell.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.ProtoLens.Prism

Description

This module defines the Prism type and combinators. Used for building Prisms for oneof fields.

Synopsis

Documentation

type Prism s t a b = forall p f. (Choice p, Applicative f) => p a (f b) -> p s (f t) Source #

type Prism' s a = Prism s s a a Source #

type AReview t b = Optic' Tagged Identity t b Source #

(#) :: AReview t b -> b -> t infixr 8 Source #

Used for constructing Prism values.

_Just # 5 == Just 5

prism :: (b -> t) -> (s -> Either t a) -> Prism s t a b Source #

Build a Prism.

Either t a is used instead of Maybe a to permit the types of s and t to differ.

prism' :: (b -> s) -> (s -> Maybe a) -> Prism s s a b Source #

This is usually used to build a Prism', when you have to use an operation like cast which already returns a Maybe.

_Left :: Prism (Either a c) (Either b c) a b Source #

_Right :: Prism (Either c a) (Either c b) a b Source #

_Just :: Prism (Maybe a) (Maybe b) a b Source #