Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type family Zoomed (m :: * -> *) :: * -> * -> *
- class (MonadState s m, MonadState t n) => Zoom m n s t | m -> s, n -> t, m t -> n, n s -> m where
- newtype StateTRep m s a = StateTRep {
- unStateTRep :: m (s, a)
- newtype RWSTRep w m s a = RWSTRep {
- unRWSTRep :: m (s, a, w)
Documentation
>>>
:set -XNoOverloadedStrings
>>>
:set -XTypeApplications
>>>
:set -XFlexibleContexts
>>>
:set -XFlexibleInstances
>>>
:set -XRankNTypes
>>>
import Control.Monad.State
>>>
:load Data.Profunctor.Optic
type family Zoomed (m :: * -> *) :: * -> * -> * Source #
Instances
type Zoomed (IdentityT m) Source # | |
Defined in Data.Profunctor.Optic.Zoom | |
type Zoomed (ReaderT e m) Source # | |
Defined in Data.Profunctor.Optic.Zoom | |
type Zoomed (StateT s z) Source # | |
Defined in Data.Profunctor.Optic.Zoom | |
type Zoomed (StateT s z) Source # | |
Defined in Data.Profunctor.Optic.Zoom | |
type Zoomed (RWST r w s z) Source # | |
Defined in Data.Profunctor.Optic.Zoom | |
type Zoomed (RWST r w s z) Source # | |
Defined in Data.Profunctor.Optic.Zoom |
class (MonadState s m, MonadState t n) => Zoom m n s t | m -> s, n -> t, m t -> n, n s -> m where Source #
zoom :: Optic' (Star (Zoomed m c)) t s -> m c -> n c infixr 2 Source #
Run a monadic action in a larger State
than it was defined in.
Used to lift actions into a State
Monad
with a larger State
type.
>>>
flip evalState (1,"foo") $ zoom first' $ use id
1
>>>
flip evalState [Right "foo", Right "bar"] $ zoom traversed $ use right'
"foobar"
>>>
flip execState (1,"foo") $ zoom first' $ id .= 2
(2,"foo")
>>>
flip execState [(1,"foo"), (2,"foo")] $ zoom traversed $ second' ..= (<>"bar")
[(1,"foobar"),(2,"foobar")]
>>>
flip execState [Left "foo", Right "bar"] $ zoom traversed $ right' ..= (<>"baz")
[Left "foo",Right "barbaz"]
>>>
flip evalState ("foo","bar") $ zoom both (use id)
"foobar"
Instances
Zoom m n s t => Zoom (IdentityT m) (IdentityT n) s t Source # | |
Zoom m n s t => Zoom (ReaderT e m) (ReaderT e n) s t Source # | |
Monad z => Zoom (StateT s z) (StateT t z) s t Source # | |
Monad z => Zoom (StateT s z) (StateT t z) s t Source # | |
(Monoid w, Monad z) => Zoom (RWST r w s z) (RWST r w t z) s t Source # | |
(Monoid w, Monad z) => Zoom (RWST r w s z) (RWST r w t z) s t Source # | |
newtype StateTRep m s a Source #
StateTRep | |
|
Instances
Monad m => Functor (StateTRep m s) Source # | |
(Monad m, Monoid s) => Applicative (StateTRep m s) Source # | |
Defined in Data.Profunctor.Optic.Zoom pure :: a -> StateTRep m s a # (<*>) :: StateTRep m s (a -> b) -> StateTRep m s a -> StateTRep m s b # liftA2 :: (a -> b -> c) -> StateTRep m s a -> StateTRep m s b -> StateTRep m s c # (*>) :: StateTRep m s a -> StateTRep m s b -> StateTRep m s b # (<*) :: StateTRep m s a -> StateTRep m s b -> StateTRep m s a # | |
(Monad m, Semigroup s) => Apply (StateTRep m s) Source # | |
Defined in Data.Profunctor.Optic.Zoom |
newtype RWSTRep w m s a Source #
Instances
Monad m => Functor (RWSTRep w m s) Source # | |
(Monad m, Monoid s, Monoid w) => Applicative (RWSTRep w m s) Source # | |
Defined in Data.Profunctor.Optic.Zoom pure :: a -> RWSTRep w m s a # (<*>) :: RWSTRep w m s (a -> b) -> RWSTRep w m s a -> RWSTRep w m s b # liftA2 :: (a -> b -> c) -> RWSTRep w m s a -> RWSTRep w m s b -> RWSTRep w m s c # (*>) :: RWSTRep w m s a -> RWSTRep w m s b -> RWSTRep w m s b # (<*) :: RWSTRep w m s a -> RWSTRep w m s b -> RWSTRep w m s a # | |
(Monad m, Semigroup s, Semigroup w) => Apply (RWSTRep w m s) Source # | |
Defined in Data.Profunctor.Optic.Zoom |