profunctor-optics-0.0.0.3: An optics library compatible with the typeclasses in 'profunctors'.

Safe HaskellSafe
LanguageHaskell2010

Data.Profunctor.Optic.Zoom

Synopsis

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 # 
Instance details

Defined in Data.Profunctor.Optic.Zoom

type Zoomed (IdentityT m) = Zoomed m
type Zoomed (ReaderT e m) Source # 
Instance details

Defined in Data.Profunctor.Optic.Zoom

type Zoomed (ReaderT e m) = Zoomed m
type Zoomed (StateT s z) Source # 
Instance details

Defined in Data.Profunctor.Optic.Zoom

type Zoomed (StateT s z) = StateTRep z
type Zoomed (StateT s z) Source # 
Instance details

Defined in Data.Profunctor.Optic.Zoom

type Zoomed (StateT s z) = StateTRep z
type Zoomed (RWST r w s z) Source # 
Instance details

Defined in Data.Profunctor.Optic.Zoom

type Zoomed (RWST r w s z) = RWSTRep w z
type Zoomed (RWST r w s z) Source # 
Instance details

Defined in Data.Profunctor.Optic.Zoom

type Zoomed (RWST r w s z) = RWSTRep w z

class (MonadState s m, MonadState t n) => Zoom m n s t | m -> s, n -> t, m t -> n, n s -> m where Source #

Methods

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 # 
Instance details

Defined in Data.Profunctor.Optic.Zoom

Methods

zoom :: Optic' (Star (Zoomed (IdentityT m) c)) t s -> IdentityT m c -> IdentityT n c Source #

Zoom m n s t => Zoom (ReaderT e m) (ReaderT e n) s t Source # 
Instance details

Defined in Data.Profunctor.Optic.Zoom

Methods

zoom :: Optic' (Star (Zoomed (ReaderT e m) c)) t s -> ReaderT e m c -> ReaderT e n c Source #

Monad z => Zoom (StateT s z) (StateT t z) s t Source # 
Instance details

Defined in Data.Profunctor.Optic.Zoom

Methods

zoom :: Optic' (Star (Zoomed (StateT s z) c)) t s -> StateT s z c -> StateT t z c Source #

Monad z => Zoom (StateT s z) (StateT t z) s t Source # 
Instance details

Defined in Data.Profunctor.Optic.Zoom

Methods

zoom :: Optic' (Star (Zoomed (StateT s z) c)) t s -> StateT s z c -> StateT t z c Source #

(Monoid w, Monad z) => Zoom (RWST r w s z) (RWST r w t z) s t Source # 
Instance details

Defined in Data.Profunctor.Optic.Zoom

Methods

zoom :: Optic' (Star (Zoomed (RWST r w s z) c)) t s -> RWST r w s z c -> RWST r w t z c Source #

(Monoid w, Monad z) => Zoom (RWST r w s z) (RWST r w t z) s t Source # 
Instance details

Defined in Data.Profunctor.Optic.Zoom

Methods

zoom :: Optic' (Star (Zoomed (RWST r w s z) c)) t s -> RWST r w s z c -> RWST r w t z c Source #

newtype StateTRep m s a Source #

Constructors

StateTRep 

Fields

Instances
Monad m => Functor (StateTRep m s) Source # 
Instance details

Defined in Data.Profunctor.Optic.Zoom

Methods

fmap :: (a -> b) -> StateTRep m s a -> StateTRep m s b #

(<$) :: a -> StateTRep m s b -> StateTRep m s a #

(Monad m, Monoid s) => Applicative (StateTRep m s) Source # 
Instance details

Defined in Data.Profunctor.Optic.Zoom

Methods

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 # 
Instance details

Defined in Data.Profunctor.Optic.Zoom

Methods

(<.>) :: StateTRep m s (a -> b) -> StateTRep m s a -> StateTRep m s b #

(.>) :: StateTRep m s a -> StateTRep m s b -> StateTRep m s b #

(<.) :: StateTRep m s a -> StateTRep m s b -> StateTRep m s a #

liftF2 :: (a -> b -> c) -> StateTRep m s a -> StateTRep m s b -> StateTRep m s c #

newtype RWSTRep w m s a Source #

Constructors

RWSTRep 

Fields

Instances
Monad m => Functor (RWSTRep w m s) Source # 
Instance details

Defined in Data.Profunctor.Optic.Zoom

Methods

fmap :: (a -> b) -> RWSTRep w m s a -> RWSTRep w m s b #

(<$) :: a -> RWSTRep w m s b -> RWSTRep w m s a #

(Monad m, Monoid s, Monoid w) => Applicative (RWSTRep w m s) Source # 
Instance details

Defined in Data.Profunctor.Optic.Zoom

Methods

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 # 
Instance details

Defined in Data.Profunctor.Optic.Zoom

Methods

(<.>) :: RWSTRep w m s (a -> b) -> RWSTRep w m s a -> RWSTRep w m s b #

(.>) :: 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 #

liftF2 :: (a -> b -> c) -> RWSTRep w m s a -> RWSTRep w m s b -> RWSTRep w m s c #