{-# LANGUAGE TemplateHaskell #-}
module Control.Effect.Writer.Lazy
(
execWriter'
, runWriter'
, execWriter
, runWriter
) where
import Data.Tuple (swap)
import Control.Monad.Trans.Writer.Lazy (WriterT, execWriterT, runWriterT)
import Control.Effect.Writer (Writer, Writer')
import Control.Effect.Machinery (Via, makeUntagged, runVia)
execWriter' :: forall tag w m a. Monad m
=> (Writer' tag w `Via` WriterT w) m a
-> m w
execWriter' :: Via (Writer' tag w) (WriterT w) m a -> m w
execWriter' = WriterT w m a -> m w
forall (m :: * -> *) w a. Monad m => WriterT w m a -> m w
execWriterT (WriterT w m a -> m w)
-> (Via (Writer' tag w) (WriterT w) m a -> WriterT w m a)
-> Via (Writer' tag w) (WriterT w) m a
-> m w
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Via (Writer' tag w) (WriterT w) m a -> WriterT w m a
forall (effs :: [Effect]) (t :: Transformer) (m :: * -> *) a.
EachVia effs t m a -> t m a
runVia
{-# INLINE execWriter' #-}
runWriter' :: forall tag w m a. Functor m
=> (Writer' tag w `Via` WriterT w) m a
-> m (w, a)
runWriter' :: Via (Writer' tag w) (WriterT w) m a -> m (w, a)
runWriter' = ((a, w) -> (w, a)) -> m (a, w) -> m (w, a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a, w) -> (w, a)
forall a b. (a, b) -> (b, a)
swap (m (a, w) -> m (w, a))
-> (Via (Writer' tag w) (WriterT w) m a -> m (a, w))
-> Via (Writer' tag w) (WriterT w) m a
-> m (w, a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WriterT w m a -> m (a, w)
forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
runWriterT (WriterT w m a -> m (a, w))
-> (Via (Writer' tag w) (WriterT w) m a -> WriterT w m a)
-> Via (Writer' tag w) (WriterT w) m a
-> m (a, w)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Via (Writer' tag w) (WriterT w) m a -> WriterT w m a
forall (effs :: [Effect]) (t :: Transformer) (m :: * -> *) a.
EachVia effs t m a -> t m a
runVia
{-# INLINE runWriter' #-}
makeUntagged ['execWriter', 'runWriter']