module Control.Effect.RWS.Lazy
(
evalRWS'
, execRWS'
, runRWS'
, evalRWS
, execRWS
, runRWS
) where
import Control.Monad.Trans.RWS.Lazy (RWST, runRWST)
import Control.Effect.Machinery (EachVia, G, runVia)
import Control.Effect.Reader (Reader, Reader')
import Control.Effect.RWS (RWS, RWS')
import Control.Effect.State (State, State')
import Control.Effect.Writer (Writer, Writer')
evalRWS'
:: forall tag r w s m a. Functor m
=> r
-> s
-> ('[RWS' tag r w s, Reader' tag r, Writer' tag w, State' tag s] `EachVia` RWST r w s) m a
-> m (w, a)
evalRWS' r s = fmap reorder . (\m -> runRWST m r s) . runVia
where
reorder (a, _, w) = (w, a)
{-# INLINE evalRWS' #-}
evalRWS :: Functor m => r -> s -> ('[RWS r w s, Reader r, Writer w, State s] `EachVia` RWST r w s) m a -> m (w, a)
evalRWS = evalRWS' @G
{-# INLINE evalRWS #-}
execRWS'
:: forall tag r w s m a. Functor m
=> r
-> s
-> ('[RWS' tag r w s, Reader' tag r, Writer' tag w, State' tag s] `EachVia` RWST r w s) m a
-> m (w, s)
execRWS' r s = fmap reorder . (\m -> runRWST m r s) . runVia
where
reorder (_, s', w) = (w, s')
{-# INLINE execRWS' #-}
execRWS :: Functor m => r -> s -> ('[RWS r w s, Reader r, Writer w, State s] `EachVia` RWST r w s) m a -> m (w, s)
execRWS = execRWS' @G
{-# INLINE execRWS #-}
runRWS'
:: forall tag r w s m a. Functor m
=> r
-> s
-> ('[RWS' tag r w s, Reader' tag r, Writer' tag w, State' tag s] `EachVia` RWST r w s) m a
-> m (w, s, a)
runRWS' r s = fmap reorder . (\m -> runRWST m r s) . runVia
where
reorder (a, s', w) = (w, s', a)
{-# INLINE runRWS' #-}
runRWS :: Functor m => r -> s -> ('[RWS r w s, Reader r, Writer w, State s] `EachVia` RWST r w s) m a -> m (w, s, a)
runRWS = runRWS' @G
{-# INLINE runRWS #-}