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)
- use :: (ViewableOptic k a, MonadState s m) => Optic' k is s a -> m (ViewResult k a)
- uses :: (ViewableOptic k r, MonadState s m) => Optic' k is s a -> (a -> r) -> m (ViewResult k r)
- listening :: (ViewableOptic k r, MonadWriter s m) => Optic' k is s r -> m a -> m (a, ViewResult k r)
- listenings :: (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
withIso
,Lens
,ReversedPrism
andGetter
. - At most one result
Maybe a
withPrism
,AffineTraversal
andAffineFold
. - Monoidal summary of all results
Monoid a => a
withTraversal
andFold
.
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
use :: (ViewableOptic k a, MonadState s m) => Optic' k is s a -> m (ViewResult k a) Source #
uses :: (ViewableOptic k r, MonadState s m) => Optic' k is s a -> (a -> r) -> m (ViewResult k r) Source #
listening :: (ViewableOptic k r, MonadWriter s m) => Optic' k is s r -> m a -> m (a, ViewResult k r) Source #
listenings :: (ViewableOptic k r, MonadWriter s m) => Optic' k is s a -> (a -> r) -> m b -> m (b, ViewResult k r) Source #