{-# LANGUAGE FunctionalDependencies #-}
module Control.Monad.Action
(
Action (..),
Actionable,
actionable,
UpdateT (..),
runUpdateT,
MonadUpdate (..),
)
where
import Acc (Acc)
import Control.Monad.Trans (MonadTrans (lift))
import Control.Monad.Trans.Except (ExceptT)
import Control.Monad.Trans.Maybe (MaybeT)
import Control.Monad.Trans.RWS.CPS (RWST)
import Control.Monad.Trans.Reader (ReaderT)
import Control.Monad.Trans.State.Strict (StateT)
import Control.Monad.Trans.Writer.CPS (WriterT)
import Data.Functor (void)
import Data.Kind (Type)
import Data.Monoid (Endo, appEndo)
class (Monoid a) => Action (a :: Type) where
type StateOf a :: Type
act :: a -> Endo (StateOf a)
newtype Actionable a = Actionable (Acc a)
deriving
(
NonEmpty (Actionable a) -> Actionable a
Actionable a -> Actionable a -> Actionable a
(Actionable a -> Actionable a -> Actionable a)
-> (NonEmpty (Actionable a) -> Actionable a)
-> (forall b. Integral b => b -> Actionable a -> Actionable a)
-> Semigroup (Actionable a)
forall b. Integral b => b -> Actionable a -> Actionable a
forall a. NonEmpty (Actionable a) -> Actionable a
forall a. Actionable a -> Actionable a -> Actionable a
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
forall a b. Integral b => b -> Actionable a -> Actionable a
$c<> :: forall a. Actionable a -> Actionable a -> Actionable a
<> :: Actionable a -> Actionable a -> Actionable a
$csconcat :: forall a. NonEmpty (Actionable a) -> Actionable a
sconcat :: NonEmpty (Actionable a) -> Actionable a
$cstimes :: forall a b. Integral b => b -> Actionable a -> Actionable a
stimes :: forall b. Integral b => b -> Actionable a -> Actionable a
Semigroup,
Semigroup (Actionable a)
Actionable a
Semigroup (Actionable a) =>
Actionable a
-> (Actionable a -> Actionable a -> Actionable a)
-> ([Actionable a] -> Actionable a)
-> Monoid (Actionable a)
[Actionable a] -> Actionable a
Actionable a -> Actionable a -> Actionable a
forall a. Semigroup (Actionable a)
forall a. Actionable a
forall a.
Semigroup a =>
a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
forall a. [Actionable a] -> Actionable a
forall a. Actionable a -> Actionable a -> Actionable a
$cmempty :: forall a. Actionable a
mempty :: Actionable a
$cmappend :: forall a. Actionable a -> Actionable a -> Actionable a
mappend :: Actionable a -> Actionable a -> Actionable a
$cmconcat :: forall a. [Actionable a] -> Actionable a
mconcat :: [Actionable a] -> Actionable a
Monoid
)
via Acc a
deriving
(
(forall m. Monoid m => Actionable m -> m)
-> (forall m a. Monoid m => (a -> m) -> Actionable a -> m)
-> (forall m a. Monoid m => (a -> m) -> Actionable a -> m)
-> (forall a b. (a -> b -> b) -> b -> Actionable a -> b)
-> (forall a b. (a -> b -> b) -> b -> Actionable a -> b)
-> (forall b a. (b -> a -> b) -> b -> Actionable a -> b)
-> (forall b a. (b -> a -> b) -> b -> Actionable a -> b)
-> (forall a. (a -> a -> a) -> Actionable a -> a)
-> (forall a. (a -> a -> a) -> Actionable a -> a)
-> (forall a. Actionable a -> [a])
-> (forall a. Actionable a -> Bool)
-> (forall a. Actionable a -> Int)
-> (forall a. Eq a => a -> Actionable a -> Bool)
-> (forall a. Ord a => Actionable a -> a)
-> (forall a. Ord a => Actionable a -> a)
-> (forall a. Num a => Actionable a -> a)
-> (forall a. Num a => Actionable a -> a)
-> Foldable Actionable
forall a. Eq a => a -> Actionable a -> Bool
forall a. Num a => Actionable a -> a
forall a. Ord a => Actionable a -> a
forall m. Monoid m => Actionable m -> m
forall a. Actionable a -> Bool
forall a. Actionable a -> Int
forall a. Actionable a -> [a]
forall a. (a -> a -> a) -> Actionable a -> a
forall m a. Monoid m => (a -> m) -> Actionable a -> m
forall b a. (b -> a -> b) -> b -> Actionable a -> b
forall a b. (a -> b -> b) -> b -> Actionable a -> b
forall (t :: Type -> Type).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall m. Monoid m => Actionable m -> m
fold :: forall m. Monoid m => Actionable m -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Actionable a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> Actionable a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Actionable a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> Actionable a -> m
$cfoldr :: forall a b. (a -> b -> b) -> b -> Actionable a -> b
foldr :: forall a b. (a -> b -> b) -> b -> Actionable a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Actionable a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> Actionable a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Actionable a -> b
foldl :: forall b a. (b -> a -> b) -> b -> Actionable a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Actionable a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> Actionable a -> b
$cfoldr1 :: forall a. (a -> a -> a) -> Actionable a -> a
foldr1 :: forall a. (a -> a -> a) -> Actionable a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Actionable a -> a
foldl1 :: forall a. (a -> a -> a) -> Actionable a -> a
$ctoList :: forall a. Actionable a -> [a]
toList :: forall a. Actionable a -> [a]
$cnull :: forall a. Actionable a -> Bool
null :: forall a. Actionable a -> Bool
$clength :: forall a. Actionable a -> Int
length :: forall a. Actionable a -> Int
$celem :: forall a. Eq a => a -> Actionable a -> Bool
elem :: forall a. Eq a => a -> Actionable a -> Bool
$cmaximum :: forall a. Ord a => Actionable a -> a
maximum :: forall a. Ord a => Actionable a -> a
$cminimum :: forall a. Ord a => Actionable a -> a
minimum :: forall a. Ord a => Actionable a -> a
$csum :: forall a. Num a => Actionable a -> a
sum :: forall a. Num a => Actionable a -> a
$cproduct :: forall a. Num a => Actionable a -> a
product :: forall a. Num a => Actionable a -> a
Foldable
)
via Acc
actionable :: a -> Actionable a
actionable :: forall a. a -> Actionable a
actionable = Acc a -> Actionable a
forall a. Acc a -> Actionable a
Actionable (Acc a -> Actionable a) -> (a -> Acc a) -> a -> Actionable a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Acc a
forall a. a -> Acc a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure
newtype UpdateT (act :: Type) (m :: Type -> Type) (a :: Type)
= UpdateT (StateOf act -> m (act, a))
deriving stock
(
(forall a b. (a -> b) -> UpdateT act m a -> UpdateT act m b)
-> (forall a b. a -> UpdateT act m b -> UpdateT act m a)
-> Functor (UpdateT act m)
forall a b. a -> UpdateT act m b -> UpdateT act m a
forall a b. (a -> b) -> UpdateT act m a -> UpdateT act m b
forall act (m :: Type -> Type) a b.
Functor m =>
a -> UpdateT act m b -> UpdateT act m a
forall act (m :: Type -> Type) a b.
Functor m =>
(a -> b) -> UpdateT act m a -> UpdateT act m b
forall (f :: Type -> Type).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall act (m :: Type -> Type) a b.
Functor m =>
(a -> b) -> UpdateT act m a -> UpdateT act m b
fmap :: forall a b. (a -> b) -> UpdateT act m a -> UpdateT act m b
$c<$ :: forall act (m :: Type -> Type) a b.
Functor m =>
a -> UpdateT act m b -> UpdateT act m a
<$ :: forall a b. a -> UpdateT act m b -> UpdateT act m a
Functor
)
instance (Action act, Monad m) => Applicative (UpdateT act m) where
{-# INLINEABLE pure #-}
pure :: forall a. a -> UpdateT act m a
pure a
x = (StateOf act -> m (act, a)) -> UpdateT act m a
forall act (m :: Type -> Type) a.
(StateOf act -> m (act, a)) -> UpdateT act m a
UpdateT ((StateOf act -> m (act, a)) -> UpdateT act m a)
-> (StateOf act -> m (act, a)) -> UpdateT act m a
forall a b. (a -> b) -> a -> b
$ \StateOf act
_ -> (act, a) -> m (act, a)
forall a. a -> m a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (act
forall a. Monoid a => a
mempty, a
x)
{-# INLINEABLE (<*>) #-}
UpdateT StateOf act -> m (act, a -> b)
fs <*> :: forall a b.
UpdateT act m (a -> b) -> UpdateT act m a -> UpdateT act m b
<*> UpdateT StateOf act -> m (act, a)
xs = (StateOf act -> m (act, b)) -> UpdateT act m b
forall act (m :: Type -> Type) a.
(StateOf act -> m (act, a)) -> UpdateT act m a
UpdateT ((StateOf act -> m (act, b)) -> UpdateT act m b)
-> (StateOf act -> m (act, b)) -> UpdateT act m b
forall a b. (a -> b) -> a -> b
$ \StateOf act
s -> do
(act
act1, a -> b
f) <- StateOf act -> m (act, a -> b)
fs StateOf act
s
let s' :: StateOf act
s' = Endo (StateOf act) -> StateOf act -> StateOf act
forall a. Endo a -> a -> a
appEndo (act -> Endo (StateOf act)
forall a. Action a => a -> Endo (StateOf a)
act act
act1) StateOf act
s
(act
act2, a
x) <- StateOf act -> m (act, a)
xs StateOf act
s'
(act, b) -> m (act, b)
forall a. a -> m a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (act
act1 act -> act -> act
forall a. Semigroup a => a -> a -> a
<> act
act2, a -> b
f a
x)
instance (Action act, Monad m) => Monad (UpdateT act m) where
{-# INLINEABLE (>>=) #-}
UpdateT StateOf act -> m (act, a)
xs >>= :: forall a b.
UpdateT act m a -> (a -> UpdateT act m b) -> UpdateT act m b
>>= a -> UpdateT act m b
f = (StateOf act -> m (act, b)) -> UpdateT act m b
forall act (m :: Type -> Type) a.
(StateOf act -> m (act, a)) -> UpdateT act m a
UpdateT ((StateOf act -> m (act, b)) -> UpdateT act m b)
-> (StateOf act -> m (act, b)) -> UpdateT act m b
forall a b. (a -> b) -> a -> b
$ \StateOf act
s -> do
(act
act1, a
x) <- StateOf act -> m (act, a)
xs StateOf act
s
let s' :: StateOf act
s' = Endo (StateOf act) -> StateOf act -> StateOf act
forall a. Endo a -> a -> a
appEndo (act -> Endo (StateOf act)
forall a. Action a => a -> Endo (StateOf a)
act act
act1) StateOf act
s
let (UpdateT StateOf act -> m (act, b)
applied) = a -> UpdateT act m b
f a
x
(act
act2, b
y) <- StateOf act -> m (act, b)
applied StateOf act
s'
(act, b) -> m (act, b)
forall a. a -> m a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (act
act1 act -> act -> act
forall a. Semigroup a => a -> a -> a
<> act
act2, b
y)
instance (Action act) => MonadTrans (UpdateT act) where
{-# INLINEABLE lift #-}
lift :: forall (m :: Type -> Type) a. Monad m => m a -> UpdateT act m a
lift m a
comp = (StateOf act -> m (act, a)) -> UpdateT act m a
forall act (m :: Type -> Type) a.
(StateOf act -> m (act, a)) -> UpdateT act m a
UpdateT ((StateOf act -> m (act, a)) -> UpdateT act m a)
-> (StateOf act -> m (act, a)) -> UpdateT act m a
forall a b. (a -> b) -> a -> b
$ \StateOf act
_ -> (act
forall a. Monoid a => a
mempty,) (a -> (act, a)) -> m a -> m (act, a)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> m a
comp
runUpdateT ::
forall (act :: Type) (m :: Type -> Type) (a :: Type).
(Functor m, Action act) =>
UpdateT act m a ->
StateOf act ->
m (StateOf act, act, a)
runUpdateT :: forall act (m :: Type -> Type) a.
(Functor m, Action act) =>
UpdateT act m a -> StateOf act -> m (StateOf act, act, a)
runUpdateT (UpdateT StateOf act -> m (act, a)
comp) StateOf act
s =
(\(act
act1, a
res) -> (Endo (StateOf act) -> StateOf act -> StateOf act
forall a. Endo a -> a -> a
appEndo (act -> Endo (StateOf act)
forall a. Action a => a -> Endo (StateOf a)
act act
act1) StateOf act
s, act
act1, a
res)) ((act, a) -> (StateOf act, act, a))
-> m (act, a) -> m (StateOf act, act, a)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> StateOf act -> m (act, a)
comp StateOf act
s
class (Action act, Monad m) => MonadUpdate act m | m -> act where
send :: act -> m (StateOf act)
{-# INLINEABLE update #-}
update :: act -> m ()
update = m (StateOf act) -> m ()
forall (f :: Type -> Type) a. Functor f => f a -> f ()
void (m (StateOf act) -> m ())
-> (act -> m (StateOf act)) -> act -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. act -> m (StateOf act)
forall act (m :: Type -> Type).
MonadUpdate act m =>
act -> m (StateOf act)
send
{-# INLINEABLE request #-}
request :: m (StateOf act)
request = act -> m (StateOf act)
forall act (m :: Type -> Type).
MonadUpdate act m =>
act -> m (StateOf act)
send (act
forall a. Monoid a => a
mempty :: act)
{-# MINIMAL send #-}
instance (Action act, Monad m) => MonadUpdate act (UpdateT act m) where
{-# INLINEABLE send #-}
send :: act -> UpdateT act m (StateOf act)
send act
x = (StateOf act -> m (act, StateOf act))
-> UpdateT act m (StateOf act)
forall act (m :: Type -> Type) a.
(StateOf act -> m (act, a)) -> UpdateT act m a
UpdateT ((StateOf act -> m (act, StateOf act))
-> UpdateT act m (StateOf act))
-> (StateOf act -> m (act, StateOf act))
-> UpdateT act m (StateOf act)
forall a b. (a -> b) -> a -> b
$ \StateOf act
s -> (act, StateOf act) -> m (act, StateOf act)
forall a. a -> m a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (act
x, Endo (StateOf act) -> StateOf act -> StateOf act
forall a. Endo a -> a -> a
appEndo (act -> Endo (StateOf act)
forall a. Action a => a -> Endo (StateOf a)
act act
x) StateOf act
s)
instance (MonadUpdate act m) => MonadUpdate act (ReaderT r m) where
{-# INLINEABLE send #-}
send :: act -> ReaderT r m (StateOf act)
send = m (StateOf act) -> ReaderT r m (StateOf act)
forall (m :: Type -> Type) a. Monad m => m a -> ReaderT r m a
forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (StateOf act) -> ReaderT r m (StateOf act))
-> (act -> m (StateOf act)) -> act -> ReaderT r m (StateOf act)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. act -> m (StateOf act)
forall act (m :: Type -> Type).
MonadUpdate act m =>
act -> m (StateOf act)
send
{-# INLINEABLE update #-}
update :: act -> ReaderT r m ()
update = m () -> ReaderT r m ()
forall (m :: Type -> Type) a. Monad m => m a -> ReaderT r m a
forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT r m ()) -> (act -> m ()) -> act -> ReaderT r m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. act -> m ()
forall act (m :: Type -> Type). MonadUpdate act m => act -> m ()
update
{-# INLINEABLE request #-}
request :: ReaderT r m (StateOf act)
request = m (StateOf act) -> ReaderT r m (StateOf act)
forall (m :: Type -> Type) a. Monad m => m a -> ReaderT r m a
forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (StateOf act)
forall act (m :: Type -> Type).
MonadUpdate act m =>
m (StateOf act)
request
instance (MonadUpdate act m) => MonadUpdate act (MaybeT m) where
{-# INLINEABLE send #-}
send :: act -> MaybeT m (StateOf act)
send = m (StateOf act) -> MaybeT m (StateOf act)
forall (m :: Type -> Type) a. Monad m => m a -> MaybeT m a
forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (StateOf act) -> MaybeT m (StateOf act))
-> (act -> m (StateOf act)) -> act -> MaybeT m (StateOf act)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. act -> m (StateOf act)
forall act (m :: Type -> Type).
MonadUpdate act m =>
act -> m (StateOf act)
send
{-# INLINEABLE update #-}
update :: act -> MaybeT m ()
update = m () -> MaybeT m ()
forall (m :: Type -> Type) a. Monad m => m a -> MaybeT m a
forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> MaybeT m ()) -> (act -> m ()) -> act -> MaybeT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. act -> m ()
forall act (m :: Type -> Type). MonadUpdate act m => act -> m ()
update
{-# INLINEABLE request #-}
request :: MaybeT m (StateOf act)
request = m (StateOf act) -> MaybeT m (StateOf act)
forall (m :: Type -> Type) a. Monad m => m a -> MaybeT m a
forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (StateOf act)
forall act (m :: Type -> Type).
MonadUpdate act m =>
m (StateOf act)
request
instance (MonadUpdate act m) => MonadUpdate act (StateT s m) where
{-# INLINEABLE send #-}
send :: act -> StateT s m (StateOf act)
send = m (StateOf act) -> StateT s m (StateOf act)
forall (m :: Type -> Type) a. Monad m => m a -> StateT s m a
forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (StateOf act) -> StateT s m (StateOf act))
-> (act -> m (StateOf act)) -> act -> StateT s m (StateOf act)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. act -> m (StateOf act)
forall act (m :: Type -> Type).
MonadUpdate act m =>
act -> m (StateOf act)
send
{-# INLINEABLE update #-}
update :: act -> StateT s m ()
update = m () -> StateT s m ()
forall (m :: Type -> Type) a. Monad m => m a -> StateT s m a
forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ()) -> (act -> m ()) -> act -> StateT s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. act -> m ()
forall act (m :: Type -> Type). MonadUpdate act m => act -> m ()
update
{-# INLINEABLE request #-}
request :: StateT s m (StateOf act)
request = m (StateOf act) -> StateT s m (StateOf act)
forall (m :: Type -> Type) a. Monad m => m a -> StateT s m a
forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (StateOf act)
forall act (m :: Type -> Type).
MonadUpdate act m =>
m (StateOf act)
request
instance (MonadUpdate act m) => MonadUpdate act (WriterT w m) where
{-# INLINEABLE send #-}
send :: act -> WriterT w m (StateOf act)
send = m (StateOf act) -> WriterT w m (StateOf act)
forall (m :: Type -> Type) a. Monad m => m a -> WriterT w m a
forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (StateOf act) -> WriterT w m (StateOf act))
-> (act -> m (StateOf act)) -> act -> WriterT w m (StateOf act)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. act -> m (StateOf act)
forall act (m :: Type -> Type).
MonadUpdate act m =>
act -> m (StateOf act)
send
{-# INLINEABLE update #-}
update :: act -> WriterT w m ()
update = m () -> WriterT w m ()
forall (m :: Type -> Type) a. Monad m => m a -> WriterT w m a
forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> WriterT w m ()) -> (act -> m ()) -> act -> WriterT w m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. act -> m ()
forall act (m :: Type -> Type). MonadUpdate act m => act -> m ()
update
{-# INLINEABLE request #-}
request :: WriterT w m (StateOf act)
request = m (StateOf act) -> WriterT w m (StateOf act)
forall (m :: Type -> Type) a. Monad m => m a -> WriterT w m a
forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (StateOf act)
forall act (m :: Type -> Type).
MonadUpdate act m =>
m (StateOf act)
request
instance (MonadUpdate act m) => MonadUpdate act (RWST r w s m) where
{-# INLINEABLE send #-}
send :: act -> RWST r w s m (StateOf act)
send = m (StateOf act) -> RWST r w s m (StateOf act)
forall (m :: Type -> Type) a. Monad m => m a -> RWST r w s m a
forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (StateOf act) -> RWST r w s m (StateOf act))
-> (act -> m (StateOf act)) -> act -> RWST r w s m (StateOf act)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. act -> m (StateOf act)
forall act (m :: Type -> Type).
MonadUpdate act m =>
act -> m (StateOf act)
send
{-# INLINEABLE update #-}
update :: act -> RWST r w s m ()
update = m () -> RWST r w s m ()
forall (m :: Type -> Type) a. Monad m => m a -> RWST r w s m a
forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> RWST r w s m ())
-> (act -> m ()) -> act -> RWST r w s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. act -> m ()
forall act (m :: Type -> Type). MonadUpdate act m => act -> m ()
update
{-# INLINEABLE request #-}
request :: RWST r w s m (StateOf act)
request = m (StateOf act) -> RWST r w s m (StateOf act)
forall (m :: Type -> Type) a. Monad m => m a -> RWST r w s m a
forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (StateOf act)
forall act (m :: Type -> Type).
MonadUpdate act m =>
m (StateOf act)
request
instance (MonadUpdate act m) => MonadUpdate act (ExceptT e m) where
{-# INLINEABLE send #-}
send :: act -> ExceptT e m (StateOf act)
send = m (StateOf act) -> ExceptT e m (StateOf act)
forall (m :: Type -> Type) a. Monad m => m a -> ExceptT e m a
forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (StateOf act) -> ExceptT e m (StateOf act))
-> (act -> m (StateOf act)) -> act -> ExceptT e m (StateOf act)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. act -> m (StateOf act)
forall act (m :: Type -> Type).
MonadUpdate act m =>
act -> m (StateOf act)
send
{-# INLINEABLE update #-}
update :: act -> ExceptT e m ()
update = m () -> ExceptT e m ()
forall (m :: Type -> Type) a. Monad m => m a -> ExceptT e m a
forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ExceptT e m ()) -> (act -> m ()) -> act -> ExceptT e m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. act -> m ()
forall act (m :: Type -> Type). MonadUpdate act m => act -> m ()
update
{-# INLINEABLE request #-}
request :: ExceptT e m (StateOf act)
request = m (StateOf act) -> ExceptT e m (StateOf act)
forall (m :: Type -> Type) a. Monad m => m a -> ExceptT e m a
forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (StateOf act)
forall act (m :: Type -> Type).
MonadUpdate act m =>
m (StateOf act)
request