Safe Haskell | None |
---|---|

Language | Haskell2010 |

EXPERIMENTAL

## Synopsis

- class ViewableOptic k r where
- type ViewResult k r :: *
- gview :: MonadReader s m => Optic' k is s r -> m (ViewResult k r)
- gviews :: MonadReader s m => Optic' k is s a -> (a -> r) -> m (ViewResult k r)

- guse :: (ViewableOptic k a, MonadState s m) => Optic' k is s a -> m (ViewResult k a)
- guses :: (ViewableOptic k r, MonadState s m) => Optic' k is s a -> (a -> r) -> m (ViewResult k r)
- glistening :: (ViewableOptic k r, MonadWriter s m) => Optic' k is s r -> m a -> m (a, ViewResult k r)
- glistenings :: (ViewableOptic k r, MonadWriter s m) => Optic' k is s a -> (a -> r) -> m b -> m (b, ViewResult k r)

# 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:

- Exactly one result
`a`

with`Iso`

,`Lens`

,`ReversedPrism`

and`Getter`

. - At most one result
`Maybe a`

with`Prism`

,`AffineTraversal`

and`AffineFold`

. - Monoidal summary of all results
`Monoid a => a`

with`Traversal`

and`Fold`

.

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

.

type ViewResult k r :: * Source #

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

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

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

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

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