Safe Haskell | None |
---|---|
Language | Haskell2010 |
Optic counterparts of MonadReader combinators from the lens library.
|
- hreader :: (MonadHReader m, HGettable (MHRElements m) s) => (s -> a) -> m a
- hasks :: (MonadHReader m, HGettable (MHRElements m) s) => (s -> a) -> m a
- hview :: (MonadHReader m, HGettable (MHRElements m) s) => Getting a s a -> m a
- hviews :: (MonadHReader m, HGettable (MHRElements m) s) => LensLike' (Const r) s a -> (a -> r) -> m r
- hiview :: (MonadHReader m, HGettable (MHRElements m) s) => IndexedGetting i (i, a) s a -> m (i, a)
- hperform :: (MonadHReader m, HGettable (MHRElements m) r) => (s -> r -> m a) -> IndexPreservingAction m s a
- hperforml :: (MonadHReader m, HGettable (MHRElements m) r) => (r -> s -> m a) -> IndexPreservingAction m s a
Documentation
hreader :: (MonadHReader m, HGettable (MHRElements m) s) => (s -> a) -> m a Source #
hasks :: (MonadHReader m, HGettable (MHRElements m) s) => (s -> a) -> m a Source #
hview :: (MonadHReader m, HGettable (MHRElements m) s) => Getting a s a -> m a Source #
hviews :: (MonadHReader m, HGettable (MHRElements m) s) => LensLike' (Const r) s a -> (a -> r) -> m r Source #
hiview :: (MonadHReader m, HGettable (MHRElements m) s) => IndexedGetting i (i, a) s a -> m (i, a) Source #
hperform :: (MonadHReader m, HGettable (MHRElements m) r) => (s -> r -> m a) -> IndexPreservingAction m s a Source #
It actually semantically similar to a mix of hask and act
, performing
the monadic action on s
taken from the optic composition on the left and r
from HReader on the right.
@
type A = Int type B = Int
data R = R { _baz :: B }
makeLenses ''R
foo :: IO Int foo = runHReaderT (HSCons (3::A) HSNil) f where f :: HReaderT '[Int] IO B f = R 3 ^! baz . hperform g . baz g :: B -> A -> HReaderT '[Int] IO R g = x y -> pure (R (x * y)) @
hperforml :: (MonadHReader m, HGettable (MHRElements m) r) => (r -> s -> m a) -> IndexPreservingAction m s a Source #
Flipped version of hperform