optics-extra-0.4.2.1: Extra utilities and instances for optics-core
Safe HaskellNone
LanguageHaskell2010

Optics.View

Description

EXPERIMENTAL

Synopsis

Documentation

class ViewableOptic k r where Source #

Generalized view (even more powerful than view from the lens library).

View the value(s) pointed to by an optic.

The type of the result depends on the optic. You get:

When in doubt, use specific, flavour restricted versions. This function is mostly useful for things such as passthrough.

Associated Types

type ViewResult k r :: Type Source #

Methods

gview :: MonadReader s m => Optic' k is s r -> m (ViewResult k r) Source #

gviews :: MonadReader s m => Optic' k is s a -> (a -> r) -> m (ViewResult k r) Source #

Instances

Instances details
ViewableOptic An_Iso r Source # 
Instance details

Defined in Optics.View

Associated Types

type ViewResult An_Iso r Source #

Methods

gview :: forall s m (is :: IxList). MonadReader s m => Optic' An_Iso is s r -> m (ViewResult An_Iso r) Source #

gviews :: forall s m (is :: IxList) a. MonadReader s m => Optic' An_Iso is s a -> (a -> r) -> m (ViewResult An_Iso r) Source #

ViewableOptic A_Lens r Source # 
Instance details

Defined in Optics.View

Associated Types

type ViewResult A_Lens r Source #

Methods

gview :: forall s m (is :: IxList). MonadReader s m => Optic' A_Lens is s r -> m (ViewResult A_Lens r) Source #

gviews :: forall s m (is :: IxList) a. MonadReader s m => Optic' A_Lens is s a -> (a -> r) -> m (ViewResult A_Lens r) Source #

ViewableOptic A_Prism r Source # 
Instance details

Defined in Optics.View

Associated Types

type ViewResult A_Prism r Source #

Methods

gview :: forall s m (is :: IxList). MonadReader s m => Optic' A_Prism is s r -> m (ViewResult A_Prism r) Source #

gviews :: forall s m (is :: IxList) a. MonadReader s m => Optic' A_Prism is s a -> (a -> r) -> m (ViewResult A_Prism r) Source #

ViewableOptic An_AffineTraversal r Source # 
Instance details

Defined in Optics.View

Associated Types

type ViewResult An_AffineTraversal r Source #

Methods

gview :: forall s m (is :: IxList). MonadReader s m => Optic' An_AffineTraversal is s r -> m (ViewResult An_AffineTraversal r) Source #

gviews :: forall s m (is :: IxList) a. MonadReader s m => Optic' An_AffineTraversal is s a -> (a -> r) -> m (ViewResult An_AffineTraversal r) Source #

Monoid r => ViewableOptic A_Traversal r Source # 
Instance details

Defined in Optics.View

Associated Types

type ViewResult A_Traversal r Source #

Methods

gview :: forall s m (is :: IxList). MonadReader s m => Optic' A_Traversal is s r -> m (ViewResult A_Traversal r) Source #

gviews :: forall s m (is :: IxList) a. MonadReader s m => Optic' A_Traversal is s a -> (a -> r) -> m (ViewResult A_Traversal r) Source #

ViewableOptic A_ReversedPrism r Source # 
Instance details

Defined in Optics.View

Associated Types

type ViewResult A_ReversedPrism r Source #

Methods

gview :: forall s m (is :: IxList). MonadReader s m => Optic' A_ReversedPrism is s r -> m (ViewResult A_ReversedPrism r) Source #

gviews :: forall s m (is :: IxList) a. MonadReader s m => Optic' A_ReversedPrism is s a -> (a -> r) -> m (ViewResult A_ReversedPrism r) Source #

ViewableOptic A_Getter r Source # 
Instance details

Defined in Optics.View

Associated Types

type ViewResult A_Getter r Source #

Methods

gview :: forall s m (is :: IxList). MonadReader s m => Optic' A_Getter is s r -> m (ViewResult A_Getter r) Source #

gviews :: forall s m (is :: IxList) a. MonadReader s m => Optic' A_Getter is s a -> (a -> r) -> m (ViewResult A_Getter r) Source #

ViewableOptic An_AffineFold r Source # 
Instance details

Defined in Optics.View

Associated Types

type ViewResult An_AffineFold r Source #

Methods

gview :: forall s m (is :: IxList). MonadReader s m => Optic' An_AffineFold is s r -> m (ViewResult An_AffineFold r) Source #

gviews :: forall s m (is :: IxList) a. MonadReader s m => Optic' An_AffineFold is s a -> (a -> r) -> m (ViewResult An_AffineFold r) Source #

Monoid r => ViewableOptic A_Fold r Source # 
Instance details

Defined in Optics.View

Associated Types

type ViewResult A_Fold r Source #

Methods

gview :: forall s m (is :: IxList). MonadReader s m => Optic' A_Fold is s r -> m (ViewResult A_Fold r) Source #

gviews :: forall s m (is :: IxList) a. MonadReader s m => Optic' A_Fold is s a -> (a -> r) -> m (ViewResult A_Fold r) Source #

guse :: (ViewableOptic k a, MonadState s m) => Optic' k is s a -> m (ViewResult k a) Source #

Use the target of a Lens, Iso, or Getter in the current state, or use a summary of a Fold or Traversal that points to a monoidal value.

>>> evalState (guse _1) ('a','b')
'a'
>>> evalState (guse _2) ("hello","world")
"world"

Since: 0.2

guses :: (ViewableOptic k r, MonadState s m) => Optic' k is s a -> (a -> r) -> m (ViewResult k r) Source #

Use the target of a Lens, Iso or Getter in the current state, or use a summary of a Fold or Traversal that points to a monoidal value.

>>> evalState (guses _1 length) ("hello","world")
5

Since: 0.2

glistening :: (ViewableOptic k r, MonadWriter s m) => Optic' k is s r -> m a -> m (a, ViewResult k r) Source #

This is a generalized form of listen that only extracts the portion of the log that is focused on by a Getter. If given a Fold or a Traversal then a monoidal summary of the parts of the log that are visited will be returned.

Since: 0.2

glistenings :: (ViewableOptic k r, MonadWriter s m) => Optic' k is s a -> (a -> r) -> m b -> m (b, ViewResult k r) Source #

This is a generalized form of listen that only extracts the portion of the log that is focused on by a Getter. If given a Fold or a Traversal then a monoidal summary of the parts of the log that are visited will be returned.

Since: 0.2