planet-mitchell-0.1.0: Planet Mitchell

Optic.Review

Contents

Synopsis

# Review

type Review t b = forall (p :: * -> * -> *) (f :: * -> *). (Choice p, Bifunctor p, Settable f) => Optic' p f t b #

This is a limited form of a Prism that can only be used for re operations.

Like with a Getter, there are no laws to state for a Review.

You can generate a Review by using unto. You can also use any Prism or Iso directly as a Review.

review :: MonadReader b m => AReview t b -> m t #

This can be used to turn an Iso or Prism around and view a value (or the current environment) through it the other way.

review ≡ view . re
review . unto ≡ id

>>> review _Left "mustard"
Left "mustard"

>>> review (unto succ) 5
6


Usually review is used in the (->) Monad with a Prism or Iso, in which case it may be useful to think of it as having one of these more restricted type signatures:

review :: Iso' s a   -> a -> s
review :: Prism' s a -> a -> s


However, when working with a Monad transformer stack, it is sometimes useful to be able to review the current environment, in which case it may be beneficial to think of it as having one of these slightly more liberal type signatures:

review :: MonadReader a m => Iso' s a   -> m s
review :: MonadReader a m => Prism' s a -> m s