{-# LANGUAGE DerivingVia #-}
{-# OPTIONS_HADDOCK not-home #-}
module Control.Effect.Internal.Writer where

import Data.Coerce
import Data.Tuple (swap)

import Control.Applicative
import Control.Monad

import Control.Effect
import Control.Effect.Bracket
import Control.Effect.Type.ListenPrim
import Control.Effect.Type.WriterPrim

import Control.Effect.Carrier

import Control.Monad.Trans.Control hiding (embed)
import qualified Control.Monad.Catch as C

import Control.Monad.Trans.Writer.CPS (WriterT, writerT, runWriterT)
import qualified Control.Monad.Trans.Writer.CPS as W
import qualified Control.Monad.Trans.Writer.Lazy as LW

import Control.Effect.Internal.Utils

-- | An effect for arbitrary output.
data Tell o :: Effect where
  Tell :: o -> Tell o m ()

-- | An effect for hearing what a computation
-- has to 'Control.Effect.Writer.tell'.
data Listen o :: Effect where
  Listen :: m a -> Listen o m (o, a)

-- | An effect for altering what a computation
-- 'Control.Effect.Writer.tell's.
newtype Pass o :: Effect where
  Pass :: m (o -> o, a) -> Pass o m a

newtype TellC o m a = TellC {
    TellC o m a -> WriterT o m a
unTellC :: WriterT o m a
  }
  deriving ( a -> TellC o m b -> TellC o m a
(a -> b) -> TellC o m a -> TellC o m b
(forall a b. (a -> b) -> TellC o m a -> TellC o m b)
-> (forall a b. a -> TellC o m b -> TellC o m a)
-> Functor (TellC o m)
forall a b. a -> TellC o m b -> TellC o m a
forall a b. (a -> b) -> TellC o m a -> TellC o m b
forall o (m :: * -> *) a b.
Functor m =>
a -> TellC o m b -> TellC o m a
forall o (m :: * -> *) a b.
Functor m =>
(a -> b) -> TellC o m a -> TellC o m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> TellC o m b -> TellC o m a
$c<$ :: forall o (m :: * -> *) a b.
Functor m =>
a -> TellC o m b -> TellC o m a
fmap :: (a -> b) -> TellC o m a -> TellC o m b
$cfmap :: forall o (m :: * -> *) a b.
Functor m =>
(a -> b) -> TellC o m a -> TellC o m b
Functor, Functor (TellC o m)
a -> TellC o m a
Functor (TellC o m)
-> (forall a. a -> TellC o m a)
-> (forall a b. TellC o m (a -> b) -> TellC o m a -> TellC o m b)
-> (forall a b c.
    (a -> b -> c) -> TellC o m a -> TellC o m b -> TellC o m c)
-> (forall a b. TellC o m a -> TellC o m b -> TellC o m b)
-> (forall a b. TellC o m a -> TellC o m b -> TellC o m a)
-> Applicative (TellC o m)
TellC o m a -> TellC o m b -> TellC o m b
TellC o m a -> TellC o m b -> TellC o m a
TellC o m (a -> b) -> TellC o m a -> TellC o m b
(a -> b -> c) -> TellC o m a -> TellC o m b -> TellC o m c
forall a. a -> TellC o m a
forall a b. TellC o m a -> TellC o m b -> TellC o m a
forall a b. TellC o m a -> TellC o m b -> TellC o m b
forall a b. TellC o m (a -> b) -> TellC o m a -> TellC o m b
forall a b c.
(a -> b -> c) -> TellC o m a -> TellC o m b -> TellC o m c
forall o (m :: * -> *). Monad m => Functor (TellC o m)
forall o (m :: * -> *) a. Monad m => a -> TellC o m a
forall o (m :: * -> *) a b.
Monad m =>
TellC o m a -> TellC o m b -> TellC o m a
forall o (m :: * -> *) a b.
Monad m =>
TellC o m a -> TellC o m b -> TellC o m b
forall o (m :: * -> *) a b.
Monad m =>
TellC o m (a -> b) -> TellC o m a -> TellC o m b
forall o (m :: * -> *) a b c.
Monad m =>
(a -> b -> c) -> TellC o m a -> TellC o m b -> TellC o m c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
<* :: TellC o m a -> TellC o m b -> TellC o m a
$c<* :: forall o (m :: * -> *) a b.
Monad m =>
TellC o m a -> TellC o m b -> TellC o m a
*> :: TellC o m a -> TellC o m b -> TellC o m b
$c*> :: forall o (m :: * -> *) a b.
Monad m =>
TellC o m a -> TellC o m b -> TellC o m b
liftA2 :: (a -> b -> c) -> TellC o m a -> TellC o m b -> TellC o m c
$cliftA2 :: forall o (m :: * -> *) a b c.
Monad m =>
(a -> b -> c) -> TellC o m a -> TellC o m b -> TellC o m c
<*> :: TellC o m (a -> b) -> TellC o m a -> TellC o m b
$c<*> :: forall o (m :: * -> *) a b.
Monad m =>
TellC o m (a -> b) -> TellC o m a -> TellC o m b
pure :: a -> TellC o m a
$cpure :: forall o (m :: * -> *) a. Monad m => a -> TellC o m a
$cp1Applicative :: forall o (m :: * -> *). Monad m => Functor (TellC o m)
Applicative, Applicative (TellC o m)
a -> TellC o m a
Applicative (TellC o m)
-> (forall a b. TellC o m a -> (a -> TellC o m b) -> TellC o m b)
-> (forall a b. TellC o m a -> TellC o m b -> TellC o m b)
-> (forall a. a -> TellC o m a)
-> Monad (TellC o m)
TellC o m a -> (a -> TellC o m b) -> TellC o m b
TellC o m a -> TellC o m b -> TellC o m b
forall a. a -> TellC o m a
forall a b. TellC o m a -> TellC o m b -> TellC o m b
forall a b. TellC o m a -> (a -> TellC o m b) -> TellC o m b
forall o (m :: * -> *). Monad m => Applicative (TellC o m)
forall o (m :: * -> *) a. Monad m => a -> TellC o m a
forall o (m :: * -> *) a b.
Monad m =>
TellC o m a -> TellC o m b -> TellC o m b
forall o (m :: * -> *) a b.
Monad m =>
TellC o m a -> (a -> TellC o m b) -> TellC o m b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> TellC o m a
$creturn :: forall o (m :: * -> *) a. Monad m => a -> TellC o m a
>> :: TellC o m a -> TellC o m b -> TellC o m b
$c>> :: forall o (m :: * -> *) a b.
Monad m =>
TellC o m a -> TellC o m b -> TellC o m b
>>= :: TellC o m a -> (a -> TellC o m b) -> TellC o m b
$c>>= :: forall o (m :: * -> *) a b.
Monad m =>
TellC o m a -> (a -> TellC o m b) -> TellC o m b
$cp1Monad :: forall o (m :: * -> *). Monad m => Applicative (TellC o m)
Monad
           , Applicative (TellC o m)
TellC o m a
Applicative (TellC o m)
-> (forall a. TellC o m a)
-> (forall a. TellC o m a -> TellC o m a -> TellC o m a)
-> (forall a. TellC o m a -> TellC o m [a])
-> (forall a. TellC o m a -> TellC o m [a])
-> Alternative (TellC o m)
TellC o m a -> TellC o m a -> TellC o m a
TellC o m a -> TellC o m [a]
TellC o m a -> TellC o m [a]
forall a. TellC o m a
forall a. TellC o m a -> TellC o m [a]
forall a. TellC o m a -> TellC o m a -> TellC o m a
forall o (m :: * -> *). MonadPlus m => Applicative (TellC o m)
forall o (m :: * -> *) a. MonadPlus m => TellC o m a
forall o (m :: * -> *) a.
MonadPlus m =>
TellC o m a -> TellC o m [a]
forall o (m :: * -> *) a.
MonadPlus m =>
TellC o m a -> TellC o m a -> TellC o m a
forall (f :: * -> *).
Applicative f
-> (forall a. f a)
-> (forall a. f a -> f a -> f a)
-> (forall a. f a -> f [a])
-> (forall a. f a -> f [a])
-> Alternative f
many :: TellC o m a -> TellC o m [a]
$cmany :: forall o (m :: * -> *) a.
MonadPlus m =>
TellC o m a -> TellC o m [a]
some :: TellC o m a -> TellC o m [a]
$csome :: forall o (m :: * -> *) a.
MonadPlus m =>
TellC o m a -> TellC o m [a]
<|> :: TellC o m a -> TellC o m a -> TellC o m a
$c<|> :: forall o (m :: * -> *) a.
MonadPlus m =>
TellC o m a -> TellC o m a -> TellC o m a
empty :: TellC o m a
$cempty :: forall o (m :: * -> *) a. MonadPlus m => TellC o m a
$cp1Alternative :: forall o (m :: * -> *). MonadPlus m => Applicative (TellC o m)
Alternative, Monad (TellC o m)
Alternative (TellC o m)
TellC o m a
Alternative (TellC o m)
-> Monad (TellC o m)
-> (forall a. TellC o m a)
-> (forall a. TellC o m a -> TellC o m a -> TellC o m a)
-> MonadPlus (TellC o m)
TellC o m a -> TellC o m a -> TellC o m a
forall a. TellC o m a
forall a. TellC o m a -> TellC o m a -> TellC o m a
forall o (m :: * -> *). MonadPlus m => Monad (TellC o m)
forall o (m :: * -> *). MonadPlus m => Alternative (TellC o m)
forall o (m :: * -> *) a. MonadPlus m => TellC o m a
forall o (m :: * -> *) a.
MonadPlus m =>
TellC o m a -> TellC o m a -> TellC o m a
forall (m :: * -> *).
Alternative m
-> Monad m
-> (forall a. m a)
-> (forall a. m a -> m a -> m a)
-> MonadPlus m
mplus :: TellC o m a -> TellC o m a -> TellC o m a
$cmplus :: forall o (m :: * -> *) a.
MonadPlus m =>
TellC o m a -> TellC o m a -> TellC o m a
mzero :: TellC o m a
$cmzero :: forall o (m :: * -> *) a. MonadPlus m => TellC o m a
$cp2MonadPlus :: forall o (m :: * -> *). MonadPlus m => Monad (TellC o m)
$cp1MonadPlus :: forall o (m :: * -> *). MonadPlus m => Alternative (TellC o m)
MonadPlus
           , Monad (TellC o m)
Monad (TellC o m)
-> (forall a. (a -> TellC o m a) -> TellC o m a)
-> MonadFix (TellC o m)
(a -> TellC o m a) -> TellC o m a
forall a. (a -> TellC o m a) -> TellC o m a
forall o (m :: * -> *). MonadFix m => Monad (TellC o m)
forall o (m :: * -> *) a.
MonadFix m =>
(a -> TellC o m a) -> TellC o m a
forall (m :: * -> *).
Monad m -> (forall a. (a -> m a) -> m a) -> MonadFix m
mfix :: (a -> TellC o m a) -> TellC o m a
$cmfix :: forall o (m :: * -> *) a.
MonadFix m =>
(a -> TellC o m a) -> TellC o m a
$cp1MonadFix :: forall o (m :: * -> *). MonadFix m => Monad (TellC o m)
MonadFix, Monad (TellC o m)
Monad (TellC o m)
-> (forall a. String -> TellC o m a) -> MonadFail (TellC o m)
String -> TellC o m a
forall a. String -> TellC o m a
forall o (m :: * -> *). MonadFail m => Monad (TellC o m)
forall o (m :: * -> *) a. MonadFail m => String -> TellC o m a
forall (m :: * -> *).
Monad m -> (forall a. String -> m a) -> MonadFail m
fail :: String -> TellC o m a
$cfail :: forall o (m :: * -> *) a. MonadFail m => String -> TellC o m a
$cp1MonadFail :: forall o (m :: * -> *). MonadFail m => Monad (TellC o m)
MonadFail, Monad (TellC o m)
Monad (TellC o m)
-> (forall a. IO a -> TellC o m a) -> MonadIO (TellC o m)
IO a -> TellC o m a
forall a. IO a -> TellC o m a
forall o (m :: * -> *). MonadIO m => Monad (TellC o m)
forall o (m :: * -> *) a. MonadIO m => IO a -> TellC o m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
liftIO :: IO a -> TellC o m a
$cliftIO :: forall o (m :: * -> *) a. MonadIO m => IO a -> TellC o m a
$cp1MonadIO :: forall o (m :: * -> *). MonadIO m => Monad (TellC o m)
MonadIO
           )
       via WriterT o m
  deriving m a -> TellC o m a
(forall (m :: * -> *) a. Monad m => m a -> TellC o m a)
-> MonadTrans (TellC o)
forall o (m :: * -> *) a. Monad m => m a -> TellC o m a
forall (m :: * -> *) a. Monad m => m a -> TellC o m a
forall (t :: (* -> *) -> * -> *).
(forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
lift :: m a -> TellC o m a
$clift :: forall o (m :: * -> *) a. Monad m => m a -> TellC o m a
MonadTrans via (WriterT o)

instance MonadThrow m => MonadThrow (TellC o m) where
  throwM :: e -> TellC o m a
throwM = m a -> TellC o m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> TellC o m a) -> (e -> m a) -> e -> TellC o m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> m a
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
C.throwM
  {-# INLINEABLE throwM #-}

instance (Monoid o, MonadCatch m) => MonadCatch (TellC o m) where
  catch :: TellC o m a -> (e -> TellC o m a) -> TellC o m a
catch (TellC WriterT o m a
m) e -> TellC o m a
h = WriterT o m a -> TellC o m a
forall o (m :: * -> *) a. WriterT o m a -> TellC o m a
TellC (WriterT o m a -> TellC o m a) -> WriterT o m a -> TellC o m a
forall a b. (a -> b) -> a -> b
$ m (a, o) -> WriterT o m a
forall (m :: * -> *) w a.
(Functor m, Monoid w) =>
m (a, w) -> WriterT w m a
writerT (m (a, o) -> WriterT o m a) -> m (a, o) -> WriterT o m a
forall a b. (a -> b) -> a -> b
$
    WriterT o m a -> m (a, o)
forall w (m :: * -> *) a. Monoid w => WriterT w m a -> m (a, w)
runWriterT WriterT o m a
m m (a, o) -> (e -> m (a, o)) -> m (a, o)
forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
m a -> (e -> m a) -> m a
`C.catch` (WriterT o m a -> m (a, o)
forall w (m :: * -> *) a. Monoid w => WriterT w m a -> m (a, w)
runWriterT (WriterT o m a -> m (a, o))
-> (e -> WriterT o m a) -> e -> m (a, o)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TellC o m a -> WriterT o m a
forall o (m :: * -> *) a. TellC o m a -> WriterT o m a
unTellC (TellC o m a -> WriterT o m a)
-> (e -> TellC o m a) -> e -> WriterT o m a
forall c b a. Coercible c b => (b -> c) -> (a -> b) -> a -> c
#. e -> TellC o m a
h)
  {-# INLINEABLE catch #-}

instance (Monoid o, MonadMask m) => MonadMask (TellC o m) where
  mask :: ((forall a. TellC o m a -> TellC o m a) -> TellC o m b)
-> TellC o m b
mask (forall a. TellC o m a -> TellC o m a) -> TellC o m b
main = WriterT o m b -> TellC o m b
forall o (m :: * -> *) a. WriterT o m a -> TellC o m a
TellC (WriterT o m b -> TellC o m b) -> WriterT o m b -> TellC o m b
forall a b. (a -> b) -> a -> b
$ m (b, o) -> WriterT o m b
forall (m :: * -> *) w a.
(Functor m, Monoid w) =>
m (a, w) -> WriterT w m a
writerT (m (b, o) -> WriterT o m b) -> m (b, o) -> WriterT o m b
forall a b. (a -> b) -> a -> b
$ ((forall a. m a -> m a) -> m (b, o)) -> m (b, o)
forall (m :: * -> *) b.
MonadMask m =>
((forall a. m a -> m a) -> m b) -> m b
C.mask (((forall a. m a -> m a) -> m (b, o)) -> m (b, o))
-> ((forall a. m a -> m a) -> m (b, o)) -> m (b, o)
forall a b. (a -> b) -> a -> b
$ \forall a. m a -> m a
restore ->
    WriterT o m b -> m (b, o)
forall w (m :: * -> *) a. Monoid w => WriterT w m a -> m (a, w)
runWriterT (TellC o m b -> WriterT o m b
forall o (m :: * -> *) a. TellC o m a -> WriterT o m a
unTellC ((forall a. TellC o m a -> TellC o m a) -> TellC o m b
main (WriterT o m a -> TellC o m a
forall o (m :: * -> *) a. WriterT o m a -> TellC o m a
TellC (WriterT o m a -> TellC o m a)
-> (WriterT o m a -> WriterT o m a) -> WriterT o m a -> TellC o m a
forall c b a. Coercible c b => (b -> c) -> (a -> b) -> a -> c
#. (m (a, o) -> m (a, o)) -> WriterT o m a -> WriterT o m a
forall (n :: * -> *) w w' (m :: * -> *) a b.
(Monad n, Monoid w, Monoid w') =>
(m (a, w) -> n (b, w')) -> WriterT w m a -> WriterT w' n b
W.mapWriterT m (a, o) -> m (a, o)
forall a. m a -> m a
restore (WriterT o m a -> TellC o m a)
-> (TellC o m a -> WriterT o m a) -> TellC o m a -> TellC o m a
forall b a c. Coercible b a => (b -> c) -> (a -> b) -> a -> c
.# TellC o m a -> WriterT o m a
forall o (m :: * -> *) a. TellC o m a -> WriterT o m a
unTellC)))
  {-# INLINEABLE mask #-}

  uninterruptibleMask :: ((forall a. TellC o m a -> TellC o m a) -> TellC o m b)
-> TellC o m b
uninterruptibleMask (forall a. TellC o m a -> TellC o m a) -> TellC o m b
main = WriterT o m b -> TellC o m b
forall o (m :: * -> *) a. WriterT o m a -> TellC o m a
TellC (WriterT o m b -> TellC o m b) -> WriterT o m b -> TellC o m b
forall a b. (a -> b) -> a -> b
$ m (b, o) -> WriterT o m b
forall (m :: * -> *) w a.
(Functor m, Monoid w) =>
m (a, w) -> WriterT w m a
writerT (m (b, o) -> WriterT o m b) -> m (b, o) -> WriterT o m b
forall a b. (a -> b) -> a -> b
$ ((forall a. m a -> m a) -> m (b, o)) -> m (b, o)
forall (m :: * -> *) b.
MonadMask m =>
((forall a. m a -> m a) -> m b) -> m b
C.uninterruptibleMask (((forall a. m a -> m a) -> m (b, o)) -> m (b, o))
-> ((forall a. m a -> m a) -> m (b, o)) -> m (b, o)
forall a b. (a -> b) -> a -> b
$ \forall a. m a -> m a
restore ->
    WriterT o m b -> m (b, o)
forall w (m :: * -> *) a. Monoid w => WriterT w m a -> m (a, w)
runWriterT (TellC o m b -> WriterT o m b
forall o (m :: * -> *) a. TellC o m a -> WriterT o m a
unTellC ((forall a. TellC o m a -> TellC o m a) -> TellC o m b
main (WriterT o m a -> TellC o m a
forall o (m :: * -> *) a. WriterT o m a -> TellC o m a
TellC (WriterT o m a -> TellC o m a)
-> (WriterT o m a -> WriterT o m a) -> WriterT o m a -> TellC o m a
forall c b a. Coercible c b => (b -> c) -> (a -> b) -> a -> c
#. (m (a, o) -> m (a, o)) -> WriterT o m a -> WriterT o m a
forall (n :: * -> *) w w' (m :: * -> *) a b.
(Monad n, Monoid w, Monoid w') =>
(m (a, w) -> n (b, w')) -> WriterT w m a -> WriterT w' n b
W.mapWriterT m (a, o) -> m (a, o)
forall a. m a -> m a
restore (WriterT o m a -> TellC o m a)
-> (TellC o m a -> WriterT o m a) -> TellC o m a -> TellC o m a
forall b a c. Coercible b a => (b -> c) -> (a -> b) -> a -> c
.# TellC o m a -> WriterT o m a
forall o (m :: * -> *) a. TellC o m a -> WriterT o m a
unTellC)))
  {-# INLINEABLE uninterruptibleMask #-}

  generalBracket :: TellC o m a
-> (a -> ExitCase b -> TellC o m c)
-> (a -> TellC o m b)
-> TellC o m (b, c)
generalBracket TellC o m a
acquire a -> ExitCase b -> TellC o m c
release a -> TellC o m b
use =
    (Bracket (WriterT o m) (b, c) -> WriterT o m (b, c))
-> Bracket (TellC o m) (b, c) -> TellC o m (b, c)
forall (n :: * -> *) (m :: * -> *) (e :: (* -> *) -> * -> *) a b.
(Coercible n m, RepresentationalEff e) =>
(e m a -> m b) -> e n a -> n b
coerceAlg
      ((forall x. Bracket m x -> m x)
-> Bracket (WriterT o m) (b, c) -> WriterT o m (b, c)
forall (t :: (* -> *) -> * -> *) (e :: (* -> *) -> * -> *)
       (m :: * -> *) a.
(ThreadsEff t e, Monad m) =>
(forall x. e m x -> m x) -> e (t m) a -> t m a
threadEff @(WriterT o) @_ @m
        (\(GeneralBracket a r u) -> m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c)
forall (m :: * -> *) a b c.
MonadMask m =>
m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c)
C.generalBracket m a
a a -> ExitCase b -> m c
r a -> m b
u)
      )
      (TellC o m a
-> (a -> ExitCase b -> TellC o m c)
-> (a -> TellC o m b)
-> Bracket (TellC o m) (b, c)
forall (m :: * -> *) a b c.
m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> Bracket m (b, c)
GeneralBracket TellC o m a
acquire a -> ExitCase b -> TellC o m c
release a -> TellC o m b
use)
  {-# INLINEABLE generalBracket #-}

instance MonadBase b m => MonadBase b (TellC o m) where
  liftBase :: b α -> TellC o m α
liftBase = m α -> TellC o m α
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m α -> TellC o m α) -> (b α -> m α) -> b α -> TellC o m α
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b α -> m α
forall (b :: * -> *) (m :: * -> *) α. MonadBase b m => b α -> m α
liftBase
  {-# INLINEABLE liftBase #-}

instance ( MonadBaseControl b m
         , Monoid o
         )
        => MonadBaseControl b (TellC o m) where
  type StM (TellC o m) a = StM m (a, o)

  liftBaseWith :: (RunInBase (TellC o m) b -> b a) -> TellC o m a
liftBaseWith = (RunInBase (TellC o m) b -> b a) -> TellC o m a
forall (t :: (* -> *) -> * -> *) (b :: * -> *) (m :: * -> *) a.
(MonadTransControl t, MonadBaseControl b m) =>
(RunInBaseDefault t m b -> b a) -> t m a
defaultLiftBaseWith
  {-# INLINEABLE liftBaseWith #-}

  restoreM :: StM (TellC o m) a -> TellC o m a
restoreM = StM (TellC o m) a -> TellC o m a
forall (t :: (* -> *) -> * -> *) (b :: * -> *) (m :: * -> *) a.
(MonadTransControl t, MonadBaseControl b m) =>
ComposeSt t m a -> t m a
defaultRestoreM
  {-# INLINEABLE restoreM #-}

instance Monoid o => MonadTransControl (TellC o) where
  type StT (TellC o) a = (a, o)

  liftWith :: (Run (TellC o) -> m a) -> TellC o m a
liftWith Run (TellC o) -> m a
main = m a -> TellC o m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Run (TellC o) -> m a
main (WriterT o n b -> n (b, o)
forall w (m :: * -> *) a. Monoid w => WriterT w m a -> m (a, w)
runWriterT (WriterT o n b -> n (b, o))
-> (TellC o n b -> WriterT o n b) -> TellC o n b -> n (b, o)
forall b a c. Coercible b a => (b -> c) -> (a -> b) -> a -> c
.# TellC o n b -> WriterT o n b
forall o (m :: * -> *) a. TellC o m a -> WriterT o m a
unTellC))
  {-# INLINEABLE liftWith #-}

  restoreT :: m (StT (TellC o) a) -> TellC o m a
restoreT = WriterT o m a -> TellC o m a
forall o (m :: * -> *) a. WriterT o m a -> TellC o m a
TellC (WriterT o m a -> TellC o m a)
-> (m (a, o) -> WriterT o m a) -> m (a, o) -> TellC o m a
forall c b a. Coercible c b => (b -> c) -> (a -> b) -> a -> c
#. m (a, o) -> WriterT o m a
forall (m :: * -> *) w a.
(Functor m, Monoid w) =>
m (a, w) -> WriterT w m a
writerT
  {-# INLINEABLE restoreT #-}

instance ( Carrier m
         , Monoid o
         , Threads (WriterT o) (Prims m)
         )
      => Carrier (TellC o m) where
  type Derivs (TellC o m) = Tell o ': Derivs m
  type Prims  (TellC o m) = Prims m

  algPrims :: Algebra' (Prims (TellC o m)) (TellC o m) a
algPrims = (Union (Prims m) (WriterT o m) a -> WriterT o m a)
-> Union (Prims m) (TellC o m) a -> TellC o m a
forall (n :: * -> *) (m :: * -> *) (e :: (* -> *) -> * -> *) a b.
(Coercible n m, RepresentationalEff e) =>
(e m a -> m b) -> e n a -> n b
coerceAlg (Algebra (Prims m) m -> Algebra (Prims m) (WriterT o m)
forall (t :: (* -> *) -> * -> *) (p :: [(* -> *) -> * -> *])
       (m :: * -> *).
(Threads t p, Monad m) =>
Algebra p m -> Algebra p (t m)
thread @(WriterT o) (Carrier m => Algebra (Prims m) m
forall (m :: * -> *) a. Carrier m => Algebra' (Prims m) m a
algPrims @m))
  {-# INLINEABLE algPrims #-}

  reformulate :: Reformulation'
  (Derivs (TellC o m)) (Prims (TellC o m)) (TellC o m) z a
reformulate forall x. TellC o m x -> z x
n Algebra (Prims (TellC o m)) z
alg = Algebra' (Derivs m) z a
-> (Tell o z a -> z a) -> Algebra' (Tell o : Derivs m) z a
forall (e :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *])
       (m :: * -> *) a.
RepresentationalEff e =>
Algebra' r m a -> (e m a -> m a) -> Algebra' (e : r) m a
powerAlg (Reformulation' (Derivs m) (Prims m) m z a
forall (m :: * -> *) (z :: * -> *) a.
(Carrier m, Monad z) =>
Reformulation' (Derivs m) (Prims m) m z a
reformulate (TellC o m x -> z x
forall x. TellC o m x -> z x
n (TellC o m x -> z x) -> (m x -> TellC o m x) -> m x -> z x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m x -> TellC o m x
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift) forall x. Union (Prims m) z x -> z x
Algebra (Prims (TellC o m)) z
alg) ((Tell o z a -> z a) -> Algebra' (Tell o : Derivs m) z a)
-> (Tell o z a -> z a) -> Algebra' (Tell o : Derivs m) z a
forall a b. (a -> b) -> a -> b
$ \case
    Tell o
o -> TellC o m () -> z ()
forall x. TellC o m x -> z x
n (WriterT o m () -> TellC o m ()
forall o (m :: * -> *) a. WriterT o m a -> TellC o m a
TellC (o -> WriterT o m ()
forall w (m :: * -> *). (Monoid w, Monad m) => w -> WriterT w m ()
W.tell o
o))
  {-# INLINEABLE reformulate #-}


newtype ListenC o m a = ListenC {
    ListenC o m a -> WriterT o m a
unListenC :: WriterT o m a
  }
  deriving ( a -> ListenC o m b -> ListenC o m a
(a -> b) -> ListenC o m a -> ListenC o m b
(forall a b. (a -> b) -> ListenC o m a -> ListenC o m b)
-> (forall a b. a -> ListenC o m b -> ListenC o m a)
-> Functor (ListenC o m)
forall a b. a -> ListenC o m b -> ListenC o m a
forall a b. (a -> b) -> ListenC o m a -> ListenC o m b
forall o (m :: * -> *) a b.
Functor m =>
a -> ListenC o m b -> ListenC o m a
forall o (m :: * -> *) a b.
Functor m =>
(a -> b) -> ListenC o m a -> ListenC o m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> ListenC o m b -> ListenC o m a
$c<$ :: forall o (m :: * -> *) a b.
Functor m =>
a -> ListenC o m b -> ListenC o m a
fmap :: (a -> b) -> ListenC o m a -> ListenC o m b
$cfmap :: forall o (m :: * -> *) a b.
Functor m =>
(a -> b) -> ListenC o m a -> ListenC o m b
Functor, Functor (ListenC o m)
a -> ListenC o m a
Functor (ListenC o m)
-> (forall a. a -> ListenC o m a)
-> (forall a b.
    ListenC o m (a -> b) -> ListenC o m a -> ListenC o m b)
-> (forall a b c.
    (a -> b -> c) -> ListenC o m a -> ListenC o m b -> ListenC o m c)
-> (forall a b. ListenC o m a -> ListenC o m b -> ListenC o m b)
-> (forall a b. ListenC o m a -> ListenC o m b -> ListenC o m a)
-> Applicative (ListenC o m)
ListenC o m a -> ListenC o m b -> ListenC o m b
ListenC o m a -> ListenC o m b -> ListenC o m a
ListenC o m (a -> b) -> ListenC o m a -> ListenC o m b
(a -> b -> c) -> ListenC o m a -> ListenC o m b -> ListenC o m c
forall a. a -> ListenC o m a
forall a b. ListenC o m a -> ListenC o m b -> ListenC o m a
forall a b. ListenC o m a -> ListenC o m b -> ListenC o m b
forall a b. ListenC o m (a -> b) -> ListenC o m a -> ListenC o m b
forall a b c.
(a -> b -> c) -> ListenC o m a -> ListenC o m b -> ListenC o m c
forall o (m :: * -> *). Monad m => Functor (ListenC o m)
forall o (m :: * -> *) a. Monad m => a -> ListenC o m a
forall o (m :: * -> *) a b.
Monad m =>
ListenC o m a -> ListenC o m b -> ListenC o m a
forall o (m :: * -> *) a b.
Monad m =>
ListenC o m a -> ListenC o m b -> ListenC o m b
forall o (m :: * -> *) a b.
Monad m =>
ListenC o m (a -> b) -> ListenC o m a -> ListenC o m b
forall o (m :: * -> *) a b c.
Monad m =>
(a -> b -> c) -> ListenC o m a -> ListenC o m b -> ListenC o m c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
<* :: ListenC o m a -> ListenC o m b -> ListenC o m a
$c<* :: forall o (m :: * -> *) a b.
Monad m =>
ListenC o m a -> ListenC o m b -> ListenC o m a
*> :: ListenC o m a -> ListenC o m b -> ListenC o m b
$c*> :: forall o (m :: * -> *) a b.
Monad m =>
ListenC o m a -> ListenC o m b -> ListenC o m b
liftA2 :: (a -> b -> c) -> ListenC o m a -> ListenC o m b -> ListenC o m c
$cliftA2 :: forall o (m :: * -> *) a b c.
Monad m =>
(a -> b -> c) -> ListenC o m a -> ListenC o m b -> ListenC o m c
<*> :: ListenC o m (a -> b) -> ListenC o m a -> ListenC o m b
$c<*> :: forall o (m :: * -> *) a b.
Monad m =>
ListenC o m (a -> b) -> ListenC o m a -> ListenC o m b
pure :: a -> ListenC o m a
$cpure :: forall o (m :: * -> *) a. Monad m => a -> ListenC o m a
$cp1Applicative :: forall o (m :: * -> *). Monad m => Functor (ListenC o m)
Applicative, Applicative (ListenC o m)
a -> ListenC o m a
Applicative (ListenC o m)
-> (forall a b.
    ListenC o m a -> (a -> ListenC o m b) -> ListenC o m b)
-> (forall a b. ListenC o m a -> ListenC o m b -> ListenC o m b)
-> (forall a. a -> ListenC o m a)
-> Monad (ListenC o m)
ListenC o m a -> (a -> ListenC o m b) -> ListenC o m b
ListenC o m a -> ListenC o m b -> ListenC o m b
forall a. a -> ListenC o m a
forall a b. ListenC o m a -> ListenC o m b -> ListenC o m b
forall a b. ListenC o m a -> (a -> ListenC o m b) -> ListenC o m b
forall o (m :: * -> *). Monad m => Applicative (ListenC o m)
forall o (m :: * -> *) a. Monad m => a -> ListenC o m a
forall o (m :: * -> *) a b.
Monad m =>
ListenC o m a -> ListenC o m b -> ListenC o m b
forall o (m :: * -> *) a b.
Monad m =>
ListenC o m a -> (a -> ListenC o m b) -> ListenC o m b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> ListenC o m a
$creturn :: forall o (m :: * -> *) a. Monad m => a -> ListenC o m a
>> :: ListenC o m a -> ListenC o m b -> ListenC o m b
$c>> :: forall o (m :: * -> *) a b.
Monad m =>
ListenC o m a -> ListenC o m b -> ListenC o m b
>>= :: ListenC o m a -> (a -> ListenC o m b) -> ListenC o m b
$c>>= :: forall o (m :: * -> *) a b.
Monad m =>
ListenC o m a -> (a -> ListenC o m b) -> ListenC o m b
$cp1Monad :: forall o (m :: * -> *). Monad m => Applicative (ListenC o m)
Monad
           , Applicative (ListenC o m)
ListenC o m a
Applicative (ListenC o m)
-> (forall a. ListenC o m a)
-> (forall a. ListenC o m a -> ListenC o m a -> ListenC o m a)
-> (forall a. ListenC o m a -> ListenC o m [a])
-> (forall a. ListenC o m a -> ListenC o m [a])
-> Alternative (ListenC o m)
ListenC o m a -> ListenC o m a -> ListenC o m a
ListenC o m a -> ListenC o m [a]
ListenC o m a -> ListenC o m [a]
forall a. ListenC o m a
forall a. ListenC o m a -> ListenC o m [a]
forall a. ListenC o m a -> ListenC o m a -> ListenC o m a
forall o (m :: * -> *). MonadPlus m => Applicative (ListenC o m)
forall o (m :: * -> *) a. MonadPlus m => ListenC o m a
forall o (m :: * -> *) a.
MonadPlus m =>
ListenC o m a -> ListenC o m [a]
forall o (m :: * -> *) a.
MonadPlus m =>
ListenC o m a -> ListenC o m a -> ListenC o m a
forall (f :: * -> *).
Applicative f
-> (forall a. f a)
-> (forall a. f a -> f a -> f a)
-> (forall a. f a -> f [a])
-> (forall a. f a -> f [a])
-> Alternative f
many :: ListenC o m a -> ListenC o m [a]
$cmany :: forall o (m :: * -> *) a.
MonadPlus m =>
ListenC o m a -> ListenC o m [a]
some :: ListenC o m a -> ListenC o m [a]
$csome :: forall o (m :: * -> *) a.
MonadPlus m =>
ListenC o m a -> ListenC o m [a]
<|> :: ListenC o m a -> ListenC o m a -> ListenC o m a
$c<|> :: forall o (m :: * -> *) a.
MonadPlus m =>
ListenC o m a -> ListenC o m a -> ListenC o m a
empty :: ListenC o m a
$cempty :: forall o (m :: * -> *) a. MonadPlus m => ListenC o m a
$cp1Alternative :: forall o (m :: * -> *). MonadPlus m => Applicative (ListenC o m)
Alternative, Monad (ListenC o m)
Alternative (ListenC o m)
ListenC o m a
Alternative (ListenC o m)
-> Monad (ListenC o m)
-> (forall a. ListenC o m a)
-> (forall a. ListenC o m a -> ListenC o m a -> ListenC o m a)
-> MonadPlus (ListenC o m)
ListenC o m a -> ListenC o m a -> ListenC o m a
forall a. ListenC o m a
forall a. ListenC o m a -> ListenC o m a -> ListenC o m a
forall o (m :: * -> *). MonadPlus m => Monad (ListenC o m)
forall o (m :: * -> *). MonadPlus m => Alternative (ListenC o m)
forall o (m :: * -> *) a. MonadPlus m => ListenC o m a
forall o (m :: * -> *) a.
MonadPlus m =>
ListenC o m a -> ListenC o m a -> ListenC o m a
forall (m :: * -> *).
Alternative m
-> Monad m
-> (forall a. m a)
-> (forall a. m a -> m a -> m a)
-> MonadPlus m
mplus :: ListenC o m a -> ListenC o m a -> ListenC o m a
$cmplus :: forall o (m :: * -> *) a.
MonadPlus m =>
ListenC o m a -> ListenC o m a -> ListenC o m a
mzero :: ListenC o m a
$cmzero :: forall o (m :: * -> *) a. MonadPlus m => ListenC o m a
$cp2MonadPlus :: forall o (m :: * -> *). MonadPlus m => Monad (ListenC o m)
$cp1MonadPlus :: forall o (m :: * -> *). MonadPlus m => Alternative (ListenC o m)
MonadPlus
           , Monad (ListenC o m)
Monad (ListenC o m)
-> (forall a. (a -> ListenC o m a) -> ListenC o m a)
-> MonadFix (ListenC o m)
(a -> ListenC o m a) -> ListenC o m a
forall a. (a -> ListenC o m a) -> ListenC o m a
forall o (m :: * -> *). MonadFix m => Monad (ListenC o m)
forall o (m :: * -> *) a.
MonadFix m =>
(a -> ListenC o m a) -> ListenC o m a
forall (m :: * -> *).
Monad m -> (forall a. (a -> m a) -> m a) -> MonadFix m
mfix :: (a -> ListenC o m a) -> ListenC o m a
$cmfix :: forall o (m :: * -> *) a.
MonadFix m =>
(a -> ListenC o m a) -> ListenC o m a
$cp1MonadFix :: forall o (m :: * -> *). MonadFix m => Monad (ListenC o m)
MonadFix, Monad (ListenC o m)
Monad (ListenC o m)
-> (forall a. String -> ListenC o m a) -> MonadFail (ListenC o m)
String -> ListenC o m a
forall a. String -> ListenC o m a
forall o (m :: * -> *). MonadFail m => Monad (ListenC o m)
forall o (m :: * -> *) a. MonadFail m => String -> ListenC o m a
forall (m :: * -> *).
Monad m -> (forall a. String -> m a) -> MonadFail m
fail :: String -> ListenC o m a
$cfail :: forall o (m :: * -> *) a. MonadFail m => String -> ListenC o m a
$cp1MonadFail :: forall o (m :: * -> *). MonadFail m => Monad (ListenC o m)
MonadFail, Monad (ListenC o m)
Monad (ListenC o m)
-> (forall a. IO a -> ListenC o m a) -> MonadIO (ListenC o m)
IO a -> ListenC o m a
forall a. IO a -> ListenC o m a
forall o (m :: * -> *). MonadIO m => Monad (ListenC o m)
forall o (m :: * -> *) a. MonadIO m => IO a -> ListenC o m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
liftIO :: IO a -> ListenC o m a
$cliftIO :: forall o (m :: * -> *) a. MonadIO m => IO a -> ListenC o m a
$cp1MonadIO :: forall o (m :: * -> *). MonadIO m => Monad (ListenC o m)
MonadIO
           , Monad (ListenC o m)
e -> ListenC o m a
Monad (ListenC o m)
-> (forall e a. Exception e => e -> ListenC o m a)
-> MonadThrow (ListenC o m)
forall e a. Exception e => e -> ListenC o m a
forall o (m :: * -> *). MonadThrow m => Monad (ListenC o m)
forall o (m :: * -> *) e a.
(MonadThrow m, Exception e) =>
e -> ListenC o m a
forall (m :: * -> *).
Monad m -> (forall e a. Exception e => e -> m a) -> MonadThrow m
throwM :: e -> ListenC o m a
$cthrowM :: forall o (m :: * -> *) e a.
(MonadThrow m, Exception e) =>
e -> ListenC o m a
$cp1MonadThrow :: forall o (m :: * -> *). MonadThrow m => Monad (ListenC o m)
MonadThrow, MonadThrow (ListenC o m)
MonadThrow (ListenC o m)
-> (forall e a.
    Exception e =>
    ListenC o m a -> (e -> ListenC o m a) -> ListenC o m a)
-> MonadCatch (ListenC o m)
ListenC o m a -> (e -> ListenC o m a) -> ListenC o m a
forall e a.
Exception e =>
ListenC o m a -> (e -> ListenC o m a) -> ListenC o m a
forall o (m :: * -> *).
(Monoid o, MonadCatch m) =>
MonadThrow (ListenC o m)
forall o (m :: * -> *) e a.
(Monoid o, MonadCatch m, Exception e) =>
ListenC o m a -> (e -> ListenC o m a) -> ListenC o m a
forall (m :: * -> *).
MonadThrow m
-> (forall e a. Exception e => m a -> (e -> m a) -> m a)
-> MonadCatch m
catch :: ListenC o m a -> (e -> ListenC o m a) -> ListenC o m a
$ccatch :: forall o (m :: * -> *) e a.
(Monoid o, MonadCatch m, Exception e) =>
ListenC o m a -> (e -> ListenC o m a) -> ListenC o m a
$cp1MonadCatch :: forall o (m :: * -> *).
(Monoid o, MonadCatch m) =>
MonadThrow (ListenC o m)
MonadCatch, MonadCatch (ListenC o m)
MonadCatch (ListenC o m)
-> (forall b.
    ((forall a. ListenC o m a -> ListenC o m a) -> ListenC o m b)
    -> ListenC o m b)
-> (forall b.
    ((forall a. ListenC o m a -> ListenC o m a) -> ListenC o m b)
    -> ListenC o m b)
-> (forall a b c.
    ListenC o m a
    -> (a -> ExitCase b -> ListenC o m c)
    -> (a -> ListenC o m b)
    -> ListenC o m (b, c))
-> MonadMask (ListenC o m)
ListenC o m a
-> (a -> ExitCase b -> ListenC o m c)
-> (a -> ListenC o m b)
-> ListenC o m (b, c)
((forall a. ListenC o m a -> ListenC o m a) -> ListenC o m b)
-> ListenC o m b
((forall a. ListenC o m a -> ListenC o m a) -> ListenC o m b)
-> ListenC o m b
forall b.
((forall a. ListenC o m a -> ListenC o m a) -> ListenC o m b)
-> ListenC o m b
forall a b c.
ListenC o m a
-> (a -> ExitCase b -> ListenC o m c)
-> (a -> ListenC o m b)
-> ListenC o m (b, c)
forall o (m :: * -> *).
(Monoid o, MonadMask m) =>
MonadCatch (ListenC o m)
forall o (m :: * -> *) b.
(Monoid o, MonadMask m) =>
((forall a. ListenC o m a -> ListenC o m a) -> ListenC o m b)
-> ListenC o m b
forall o (m :: * -> *) a b c.
(Monoid o, MonadMask m) =>
ListenC o m a
-> (a -> ExitCase b -> ListenC o m c)
-> (a -> ListenC o m b)
-> ListenC o m (b, c)
forall (m :: * -> *).
MonadCatch m
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall a b c.
    m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c))
-> MonadMask m
generalBracket :: ListenC o m a
-> (a -> ExitCase b -> ListenC o m c)
-> (a -> ListenC o m b)
-> ListenC o m (b, c)
$cgeneralBracket :: forall o (m :: * -> *) a b c.
(Monoid o, MonadMask m) =>
ListenC o m a
-> (a -> ExitCase b -> ListenC o m c)
-> (a -> ListenC o m b)
-> ListenC o m (b, c)
uninterruptibleMask :: ((forall a. ListenC o m a -> ListenC o m a) -> ListenC o m b)
-> ListenC o m b
$cuninterruptibleMask :: forall o (m :: * -> *) b.
(Monoid o, MonadMask m) =>
((forall a. ListenC o m a -> ListenC o m a) -> ListenC o m b)
-> ListenC o m b
mask :: ((forall a. ListenC o m a -> ListenC o m a) -> ListenC o m b)
-> ListenC o m b
$cmask :: forall o (m :: * -> *) b.
(Monoid o, MonadMask m) =>
((forall a. ListenC o m a -> ListenC o m a) -> ListenC o m b)
-> ListenC o m b
$cp1MonadMask :: forall o (m :: * -> *).
(Monoid o, MonadMask m) =>
MonadCatch (ListenC o m)
MonadMask
           , MonadBase b, MonadBaseControl b
           )
       via TellC o m
  deriving (m a -> ListenC o m a
(forall (m :: * -> *) a. Monad m => m a -> ListenC o m a)
-> MonadTrans (ListenC o)
forall o (m :: * -> *) a. Monad m => m a -> ListenC o m a
forall (m :: * -> *) a. Monad m => m a -> ListenC o m a
forall (t :: (* -> *) -> * -> *).
(forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
lift :: m a -> ListenC o m a
$clift :: forall o (m :: * -> *) a. Monad m => m a -> ListenC o m a
MonadTrans, MonadTrans (ListenC o)
m (StT (ListenC o) a) -> ListenC o m a
MonadTrans (ListenC o)
-> (forall (m :: * -> *) a.
    Monad m =>
    (Run (ListenC o) -> m a) -> ListenC o m a)
-> (forall (m :: * -> *) a.
    Monad m =>
    m (StT (ListenC o) a) -> ListenC o m a)
-> MonadTransControl (ListenC o)
(Run (ListenC o) -> m a) -> ListenC o m a
forall o. Monoid o => MonadTrans (ListenC o)
forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
m (StT (ListenC o) a) -> ListenC o m a
forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
(Run (ListenC o) -> m a) -> ListenC o m a
forall (m :: * -> *) a.
Monad m =>
m (StT (ListenC o) a) -> ListenC o m a
forall (m :: * -> *) a.
Monad m =>
(Run (ListenC o) -> m a) -> ListenC o m a
forall (t :: (* -> *) -> * -> *).
MonadTrans t
-> (forall (m :: * -> *) a. Monad m => (Run t -> m a) -> t m a)
-> (forall (m :: * -> *) a. Monad m => m (StT t a) -> t m a)
-> MonadTransControl t
restoreT :: m (StT (ListenC o) a) -> ListenC o m a
$crestoreT :: forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
m (StT (ListenC o) a) -> ListenC o m a
liftWith :: (Run (ListenC o) -> m a) -> ListenC o m a
$cliftWith :: forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
(Run (ListenC o) -> m a) -> ListenC o m a
$cp1MonadTransControl :: forall o. Monoid o => MonadTrans (ListenC o)
MonadTransControl) via (TellC o)

instance ( Carrier m
         , Monoid o
         , Threads (WriterT o) (Prims m)
         )
      => Carrier (ListenC o m) where
  type Derivs (ListenC o m) = Listen o ': Tell o ': Derivs m
  type Prims  (ListenC o m) = ListenPrim o ': Prims m

  algPrims :: Algebra' (Prims (ListenC o m)) (ListenC o m) a
algPrims =
    Algebra' (Prims m) (ListenC o m) a
-> (ListenPrim o (ListenC o m) a -> ListenC o m a)
-> Algebra' (ListenPrim o : Prims m) (ListenC o m) a
forall (e :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *])
       (m :: * -> *) a.
RepresentationalEff e =>
Algebra' r m a -> (e m a -> m a) -> Algebra' (e : r) m a
powerAlg (
      Algebra' (Prims m) (TellC o m) a
-> Algebra' (Prims m) (ListenC o m) a
coerce (forall a.
Carrier (TellC o m) =>
Algebra' (Prims (TellC o m)) (TellC o m) a
forall (m :: * -> *) a. Carrier m => Algebra' (Prims m) m a
algPrims @(TellC o m))
    ) ((ListenPrim o (ListenC o m) a -> ListenC o m a)
 -> Algebra' (ListenPrim o : Prims m) (ListenC o m) a)
-> (ListenPrim o (ListenC o m) a -> ListenC o m a)
-> Algebra' (ListenPrim o : Prims m) (ListenC o m) a
forall a b. (a -> b) -> a -> b
$ \case
        ListenPrimTell o
o -> WriterT o m () -> ListenC o m ()
forall o (m :: * -> *) a. WriterT o m a -> ListenC o m a
ListenC (WriterT o m () -> ListenC o m ())
-> WriterT o m () -> ListenC o m ()
forall a b. (a -> b) -> a -> b
$ o -> WriterT o m ()
forall w (m :: * -> *). (Monoid w, Monad m) => w -> WriterT w m ()
W.tell o
o
        ListenPrimListen (ListenC m) -> WriterT o m (o, a) -> ListenC o m (o, a)
forall o (m :: * -> *) a. WriterT o m a -> ListenC o m a
ListenC (WriterT o m (o, a) -> ListenC o m (o, a))
-> WriterT o m (o, a) -> ListenC o m (o, a)
forall a b. (a -> b) -> a -> b
$ do
          (a
a, o
o) <- WriterT o m a -> WriterT o m (a, o)
forall w (m :: * -> *) a.
(Monoid w, Monad m) =>
WriterT w m a -> WriterT w m (a, w)
W.listen WriterT o m a
m
          (o, a) -> WriterT o m (o, a)
forall (m :: * -> *) a. Monad m => a -> m a
return (o
o, a
a)
  {-# INLINEABLE algPrims #-}

  reformulate :: Reformulation'
  (Derivs (ListenC o m)) (Prims (ListenC o m)) (ListenC o m) z a
reformulate forall x. ListenC o m x -> z x
n Algebra (Prims (ListenC o m)) z
alg =
    Algebra' (Tell o : Derivs m) z a
-> (Listen o z a -> z a)
-> Algebra' (Listen o : Tell o : Derivs m) z a
forall (e :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *])
       (m :: * -> *) a.
RepresentationalEff e =>
Algebra' r m a -> (e m a -> m a) -> Algebra' (e : r) m a
powerAlg (
      Reformulation' (Tell o : Derivs m) (Prims m) (TellC o m) z a
-> Reformulation' (Tell o : Derivs m) (Prims m) (ListenC o m) z a
forall (m :: * -> *) (n :: * -> *) (r :: [(* -> *) -> * -> *])
       (p :: [(* -> *) -> * -> *]) (z :: * -> *) a.
Coercible m n =>
Reformulation' r p m z a -> Reformulation' r p n z a
coerceReform (forall (z :: * -> *) a.
(Carrier (TellC o m), Monad z) =>
Reformulation'
  (Derivs (TellC o m)) (Prims (TellC o m)) (TellC o m) z a
forall (m :: * -> *) (z :: * -> *) a.
(Carrier m, Monad z) =>
Reformulation' (Derivs m) (Prims m) m z a
reformulate @(TellC o m)) forall x. ListenC o m x -> z x
n (Algebra' (ListenPrim o : Prims m) z x -> Algebra' (Prims m) z x
forall (e :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *])
       (m :: * -> *) a.
Algebra' (e : r) m a -> Algebra' r m a
weakenAlg Algebra' (ListenPrim o : Prims m) z x
Algebra (Prims (ListenC o m)) z
alg)
    ) ((Listen o z a -> z a)
 -> Algebra' (Listen o : Tell o : Derivs m) z a)
-> (Listen o z a -> z a)
-> Algebra' (Listen o : Tell o : Derivs m) z a
forall a b. (a -> b) -> a -> b
$ \case
      Listen z a
m -> (Union (ListenPrim o : Prims m) z (o, a) -> z a
Algebra (Prims (ListenC o m)) z
alg (Union (ListenPrim o : Prims m) z (o, a) -> z a)
-> (ListenPrim o z (o, a)
    -> Union (ListenPrim o : Prims m) z (o, a))
-> ListenPrim o z (o, a)
-> z a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ListenPrim o z (o, a) -> Union (ListenPrim o : Prims m) z (o, a)
forall (e :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *])
       (m :: * -> *) a.
Member e r =>
e m a -> Union r m a
inj) (ListenPrim o z (o, a) -> z a) -> ListenPrim o z (o, a) -> z a
forall a b. (a -> b) -> a -> b
$ z a -> ListenPrim o z (o, a)
forall (m :: * -> *) a o. m a -> ListenPrim o m (o, a)
ListenPrimListen z a
m
  {-# INLINEABLE reformulate #-}


newtype WriterC o m a = WriterC {
    WriterC o m a -> WriterT o m a
unWriterC :: WriterT o m a
  }
  deriving ( a -> WriterC o m b -> WriterC o m a
(a -> b) -> WriterC o m a -> WriterC o m b
(forall a b. (a -> b) -> WriterC o m a -> WriterC o m b)
-> (forall a b. a -> WriterC o m b -> WriterC o m a)
-> Functor (WriterC o m)
forall a b. a -> WriterC o m b -> WriterC o m a
forall a b. (a -> b) -> WriterC o m a -> WriterC o m b
forall o (m :: * -> *) a b.
Functor m =>
a -> WriterC o m b -> WriterC o m a
forall o (m :: * -> *) a b.
Functor m =>
(a -> b) -> WriterC o m a -> WriterC o m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> WriterC o m b -> WriterC o m a
$c<$ :: forall o (m :: * -> *) a b.
Functor m =>
a -> WriterC o m b -> WriterC o m a
fmap :: (a -> b) -> WriterC o m a -> WriterC o m b
$cfmap :: forall o (m :: * -> *) a b.
Functor m =>
(a -> b) -> WriterC o m a -> WriterC o m b
Functor, Functor (WriterC o m)
a -> WriterC o m a
Functor (WriterC o m)
-> (forall a. a -> WriterC o m a)
-> (forall a b.
    WriterC o m (a -> b) -> WriterC o m a -> WriterC o m b)
-> (forall a b c.
    (a -> b -> c) -> WriterC o m a -> WriterC o m b -> WriterC o m c)
-> (forall a b. WriterC o m a -> WriterC o m b -> WriterC o m b)
-> (forall a b. WriterC o m a -> WriterC o m b -> WriterC o m a)
-> Applicative (WriterC o m)
WriterC o m a -> WriterC o m b -> WriterC o m b
WriterC o m a -> WriterC o m b -> WriterC o m a
WriterC o m (a -> b) -> WriterC o m a -> WriterC o m b
(a -> b -> c) -> WriterC o m a -> WriterC o m b -> WriterC o m c
forall a. a -> WriterC o m a
forall a b. WriterC o m a -> WriterC o m b -> WriterC o m a
forall a b. WriterC o m a -> WriterC o m b -> WriterC o m b
forall a b. WriterC o m (a -> b) -> WriterC o m a -> WriterC o m b
forall a b c.
(a -> b -> c) -> WriterC o m a -> WriterC o m b -> WriterC o m c
forall o (m :: * -> *). Monad m => Functor (WriterC o m)
forall o (m :: * -> *) a. Monad m => a -> WriterC o m a
forall o (m :: * -> *) a b.
Monad m =>
WriterC o m a -> WriterC o m b -> WriterC o m a
forall o (m :: * -> *) a b.
Monad m =>
WriterC o m a -> WriterC o m b -> WriterC o m b
forall o (m :: * -> *) a b.
Monad m =>
WriterC o m (a -> b) -> WriterC o m a -> WriterC o m b
forall o (m :: * -> *) a b c.
Monad m =>
(a -> b -> c) -> WriterC o m a -> WriterC o m b -> WriterC o m c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
<* :: WriterC o m a -> WriterC o m b -> WriterC o m a
$c<* :: forall o (m :: * -> *) a b.
Monad m =>
WriterC o m a -> WriterC o m b -> WriterC o m a
*> :: WriterC o m a -> WriterC o m b -> WriterC o m b
$c*> :: forall o (m :: * -> *) a b.
Monad m =>
WriterC o m a -> WriterC o m b -> WriterC o m b
liftA2 :: (a -> b -> c) -> WriterC o m a -> WriterC o m b -> WriterC o m c
$cliftA2 :: forall o (m :: * -> *) a b c.
Monad m =>
(a -> b -> c) -> WriterC o m a -> WriterC o m b -> WriterC o m c
<*> :: WriterC o m (a -> b) -> WriterC o m a -> WriterC o m b
$c<*> :: forall o (m :: * -> *) a b.
Monad m =>
WriterC o m (a -> b) -> WriterC o m a -> WriterC o m b
pure :: a -> WriterC o m a
$cpure :: forall o (m :: * -> *) a. Monad m => a -> WriterC o m a
$cp1Applicative :: forall o (m :: * -> *). Monad m => Functor (WriterC o m)
Applicative, Applicative (WriterC o m)
a -> WriterC o m a
Applicative (WriterC o m)
-> (forall a b.
    WriterC o m a -> (a -> WriterC o m b) -> WriterC o m b)
-> (forall a b. WriterC o m a -> WriterC o m b -> WriterC o m b)
-> (forall a. a -> WriterC o m a)
-> Monad (WriterC o m)
WriterC o m a -> (a -> WriterC o m b) -> WriterC o m b
WriterC o m a -> WriterC o m b -> WriterC o m b
forall a. a -> WriterC o m a
forall a b. WriterC o m a -> WriterC o m b -> WriterC o m b
forall a b. WriterC o m a -> (a -> WriterC o m b) -> WriterC o m b
forall o (m :: * -> *). Monad m => Applicative (WriterC o m)
forall o (m :: * -> *) a. Monad m => a -> WriterC o m a
forall o (m :: * -> *) a b.
Monad m =>
WriterC o m a -> WriterC o m b -> WriterC o m b
forall o (m :: * -> *) a b.
Monad m =>
WriterC o m a -> (a -> WriterC o m b) -> WriterC o m b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> WriterC o m a
$creturn :: forall o (m :: * -> *) a. Monad m => a -> WriterC o m a
>> :: WriterC o m a -> WriterC o m b -> WriterC o m b
$c>> :: forall o (m :: * -> *) a b.
Monad m =>
WriterC o m a -> WriterC o m b -> WriterC o m b
>>= :: WriterC o m a -> (a -> WriterC o m b) -> WriterC o m b
$c>>= :: forall o (m :: * -> *) a b.
Monad m =>
WriterC o m a -> (a -> WriterC o m b) -> WriterC o m b
$cp1Monad :: forall o (m :: * -> *). Monad m => Applicative (WriterC o m)
Monad
           , Applicative (WriterC o m)
WriterC o m a
Applicative (WriterC o m)
-> (forall a. WriterC o m a)
-> (forall a. WriterC o m a -> WriterC o m a -> WriterC o m a)
-> (forall a. WriterC o m a -> WriterC o m [a])
-> (forall a. WriterC o m a -> WriterC o m [a])
-> Alternative (WriterC o m)
WriterC o m a -> WriterC o m a -> WriterC o m a
WriterC o m a -> WriterC o m [a]
WriterC o m a -> WriterC o m [a]
forall a. WriterC o m a
forall a. WriterC o m a -> WriterC o m [a]
forall a. WriterC o m a -> WriterC o m a -> WriterC o m a
forall o (m :: * -> *). MonadPlus m => Applicative (WriterC o m)
forall o (m :: * -> *) a. MonadPlus m => WriterC o m a
forall o (m :: * -> *) a.
MonadPlus m =>
WriterC o m a -> WriterC o m [a]
forall o (m :: * -> *) a.
MonadPlus m =>
WriterC o m a -> WriterC o m a -> WriterC o m a
forall (f :: * -> *).
Applicative f
-> (forall a. f a)
-> (forall a. f a -> f a -> f a)
-> (forall a. f a -> f [a])
-> (forall a. f a -> f [a])
-> Alternative f
many :: WriterC o m a -> WriterC o m [a]
$cmany :: forall o (m :: * -> *) a.
MonadPlus m =>
WriterC o m a -> WriterC o m [a]
some :: WriterC o m a -> WriterC o m [a]
$csome :: forall o (m :: * -> *) a.
MonadPlus m =>
WriterC o m a -> WriterC o m [a]
<|> :: WriterC o m a -> WriterC o m a -> WriterC o m a
$c<|> :: forall o (m :: * -> *) a.
MonadPlus m =>
WriterC o m a -> WriterC o m a -> WriterC o m a
empty :: WriterC o m a
$cempty :: forall o (m :: * -> *) a. MonadPlus m => WriterC o m a
$cp1Alternative :: forall o (m :: * -> *). MonadPlus m => Applicative (WriterC o m)
Alternative, Monad (WriterC o m)
Alternative (WriterC o m)
WriterC o m a
Alternative (WriterC o m)
-> Monad (WriterC o m)
-> (forall a. WriterC o m a)
-> (forall a. WriterC o m a -> WriterC o m a -> WriterC o m a)
-> MonadPlus (WriterC o m)
WriterC o m a -> WriterC o m a -> WriterC o m a
forall a. WriterC o m a
forall a. WriterC o m a -> WriterC o m a -> WriterC o m a
forall o (m :: * -> *). MonadPlus m => Monad (WriterC o m)
forall o (m :: * -> *). MonadPlus m => Alternative (WriterC o m)
forall o (m :: * -> *) a. MonadPlus m => WriterC o m a
forall o (m :: * -> *) a.
MonadPlus m =>
WriterC o m a -> WriterC o m a -> WriterC o m a
forall (m :: * -> *).
Alternative m
-> Monad m
-> (forall a. m a)
-> (forall a. m a -> m a -> m a)
-> MonadPlus m
mplus :: WriterC o m a -> WriterC o m a -> WriterC o m a
$cmplus :: forall o (m :: * -> *) a.
MonadPlus m =>
WriterC o m a -> WriterC o m a -> WriterC o m a
mzero :: WriterC o m a
$cmzero :: forall o (m :: * -> *) a. MonadPlus m => WriterC o m a
$cp2MonadPlus :: forall o (m :: * -> *). MonadPlus m => Monad (WriterC o m)
$cp1MonadPlus :: forall o (m :: * -> *). MonadPlus m => Alternative (WriterC o m)
MonadPlus
           , Monad (WriterC o m)
Monad (WriterC o m)
-> (forall a. (a -> WriterC o m a) -> WriterC o m a)
-> MonadFix (WriterC o m)
(a -> WriterC o m a) -> WriterC o m a
forall a. (a -> WriterC o m a) -> WriterC o m a
forall o (m :: * -> *). MonadFix m => Monad (WriterC o m)
forall o (m :: * -> *) a.
MonadFix m =>
(a -> WriterC o m a) -> WriterC o m a
forall (m :: * -> *).
Monad m -> (forall a. (a -> m a) -> m a) -> MonadFix m
mfix :: (a -> WriterC o m a) -> WriterC o m a
$cmfix :: forall o (m :: * -> *) a.
MonadFix m =>
(a -> WriterC o m a) -> WriterC o m a
$cp1MonadFix :: forall o (m :: * -> *). MonadFix m => Monad (WriterC o m)
MonadFix, Monad (WriterC o m)
Monad (WriterC o m)
-> (forall a. String -> WriterC o m a) -> MonadFail (WriterC o m)
String -> WriterC o m a
forall a. String -> WriterC o m a
forall o (m :: * -> *). MonadFail m => Monad (WriterC o m)
forall o (m :: * -> *) a. MonadFail m => String -> WriterC o m a
forall (m :: * -> *).
Monad m -> (forall a. String -> m a) -> MonadFail m
fail :: String -> WriterC o m a
$cfail :: forall o (m :: * -> *) a. MonadFail m => String -> WriterC o m a
$cp1MonadFail :: forall o (m :: * -> *). MonadFail m => Monad (WriterC o m)
MonadFail, Monad (WriterC o m)
Monad (WriterC o m)
-> (forall a. IO a -> WriterC o m a) -> MonadIO (WriterC o m)
IO a -> WriterC o m a
forall a. IO a -> WriterC o m a
forall o (m :: * -> *). MonadIO m => Monad (WriterC o m)
forall o (m :: * -> *) a. MonadIO m => IO a -> WriterC o m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
liftIO :: IO a -> WriterC o m a
$cliftIO :: forall o (m :: * -> *) a. MonadIO m => IO a -> WriterC o m a
$cp1MonadIO :: forall o (m :: * -> *). MonadIO m => Monad (WriterC o m)
MonadIO
           , Monad (WriterC o m)
e -> WriterC o m a
Monad (WriterC o m)
-> (forall e a. Exception e => e -> WriterC o m a)
-> MonadThrow (WriterC o m)
forall e a. Exception e => e -> WriterC o m a
forall o (m :: * -> *). MonadThrow m => Monad (WriterC o m)
forall o (m :: * -> *) e a.
(MonadThrow m, Exception e) =>
e -> WriterC o m a
forall (m :: * -> *).
Monad m -> (forall e a. Exception e => e -> m a) -> MonadThrow m
throwM :: e -> WriterC o m a
$cthrowM :: forall o (m :: * -> *) e a.
(MonadThrow m, Exception e) =>
e -> WriterC o m a
$cp1MonadThrow :: forall o (m :: * -> *). MonadThrow m => Monad (WriterC o m)
MonadThrow, MonadThrow (WriterC o m)
MonadThrow (WriterC o m)
-> (forall e a.
    Exception e =>
    WriterC o m a -> (e -> WriterC o m a) -> WriterC o m a)
-> MonadCatch (WriterC o m)
WriterC o m a -> (e -> WriterC o m a) -> WriterC o m a
forall e a.
Exception e =>
WriterC o m a -> (e -> WriterC o m a) -> WriterC o m a
forall o (m :: * -> *).
(Monoid o, MonadCatch m) =>
MonadThrow (WriterC o m)
forall o (m :: * -> *) e a.
(Monoid o, MonadCatch m, Exception e) =>
WriterC o m a -> (e -> WriterC o m a) -> WriterC o m a
forall (m :: * -> *).
MonadThrow m
-> (forall e a. Exception e => m a -> (e -> m a) -> m a)
-> MonadCatch m
catch :: WriterC o m a -> (e -> WriterC o m a) -> WriterC o m a
$ccatch :: forall o (m :: * -> *) e a.
(Monoid o, MonadCatch m, Exception e) =>
WriterC o m a -> (e -> WriterC o m a) -> WriterC o m a
$cp1MonadCatch :: forall o (m :: * -> *).
(Monoid o, MonadCatch m) =>
MonadThrow (WriterC o m)
MonadCatch, MonadCatch (WriterC o m)
MonadCatch (WriterC o m)
-> (forall b.
    ((forall a. WriterC o m a -> WriterC o m a) -> WriterC o m b)
    -> WriterC o m b)
-> (forall b.
    ((forall a. WriterC o m a -> WriterC o m a) -> WriterC o m b)
    -> WriterC o m b)
-> (forall a b c.
    WriterC o m a
    -> (a -> ExitCase b -> WriterC o m c)
    -> (a -> WriterC o m b)
    -> WriterC o m (b, c))
-> MonadMask (WriterC o m)
WriterC o m a
-> (a -> ExitCase b -> WriterC o m c)
-> (a -> WriterC o m b)
-> WriterC o m (b, c)
((forall a. WriterC o m a -> WriterC o m a) -> WriterC o m b)
-> WriterC o m b
((forall a. WriterC o m a -> WriterC o m a) -> WriterC o m b)
-> WriterC o m b
forall b.
((forall a. WriterC o m a -> WriterC o m a) -> WriterC o m b)
-> WriterC o m b
forall a b c.
WriterC o m a
-> (a -> ExitCase b -> WriterC o m c)
-> (a -> WriterC o m b)
-> WriterC o m (b, c)
forall o (m :: * -> *).
(Monoid o, MonadMask m) =>
MonadCatch (WriterC o m)
forall o (m :: * -> *) b.
(Monoid o, MonadMask m) =>
((forall a. WriterC o m a -> WriterC o m a) -> WriterC o m b)
-> WriterC o m b
forall o (m :: * -> *) a b c.
(Monoid o, MonadMask m) =>
WriterC o m a
-> (a -> ExitCase b -> WriterC o m c)
-> (a -> WriterC o m b)
-> WriterC o m (b, c)
forall (m :: * -> *).
MonadCatch m
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall a b c.
    m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c))
-> MonadMask m
generalBracket :: WriterC o m a
-> (a -> ExitCase b -> WriterC o m c)
-> (a -> WriterC o m b)
-> WriterC o m (b, c)
$cgeneralBracket :: forall o (m :: * -> *) a b c.
(Monoid o, MonadMask m) =>
WriterC o m a
-> (a -> ExitCase b -> WriterC o m c)
-> (a -> WriterC o m b)
-> WriterC o m (b, c)
uninterruptibleMask :: ((forall a. WriterC o m a -> WriterC o m a) -> WriterC o m b)
-> WriterC o m b
$cuninterruptibleMask :: forall o (m :: * -> *) b.
(Monoid o, MonadMask m) =>
((forall a. WriterC o m a -> WriterC o m a) -> WriterC o m b)
-> WriterC o m b
mask :: ((forall a. WriterC o m a -> WriterC o m a) -> WriterC o m b)
-> WriterC o m b
$cmask :: forall o (m :: * -> *) b.
(Monoid o, MonadMask m) =>
((forall a. WriterC o m a -> WriterC o m a) -> WriterC o m b)
-> WriterC o m b
$cp1MonadMask :: forall o (m :: * -> *).
(Monoid o, MonadMask m) =>
MonadCatch (WriterC o m)
MonadMask
           , MonadBase b, MonadBaseControl b
           )
       via TellC o m
  deriving (m a -> WriterC o m a
(forall (m :: * -> *) a. Monad m => m a -> WriterC o m a)
-> MonadTrans (WriterC o)
forall o (m :: * -> *) a. Monad m => m a -> WriterC o m a
forall (m :: * -> *) a. Monad m => m a -> WriterC o m a
forall (t :: (* -> *) -> * -> *).
(forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
lift :: m a -> WriterC o m a
$clift :: forall o (m :: * -> *) a. Monad m => m a -> WriterC o m a
MonadTrans, MonadTrans (WriterC o)
m (StT (WriterC o) a) -> WriterC o m a
MonadTrans (WriterC o)
-> (forall (m :: * -> *) a.
    Monad m =>
    (Run (WriterC o) -> m a) -> WriterC o m a)
-> (forall (m :: * -> *) a.
    Monad m =>
    m (StT (WriterC o) a) -> WriterC o m a)
-> MonadTransControl (WriterC o)
(Run (WriterC o) -> m a) -> WriterC o m a
forall o. Monoid o => MonadTrans (WriterC o)
forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
m (StT (WriterC o) a) -> WriterC o m a
forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
(Run (WriterC o) -> m a) -> WriterC o m a
forall (m :: * -> *) a.
Monad m =>
m (StT (WriterC o) a) -> WriterC o m a
forall (m :: * -> *) a.
Monad m =>
(Run (WriterC o) -> m a) -> WriterC o m a
forall (t :: (* -> *) -> * -> *).
MonadTrans t
-> (forall (m :: * -> *) a. Monad m => (Run t -> m a) -> t m a)
-> (forall (m :: * -> *) a. Monad m => m (StT t a) -> t m a)
-> MonadTransControl t
restoreT :: m (StT (WriterC o) a) -> WriterC o m a
$crestoreT :: forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
m (StT (WriterC o) a) -> WriterC o m a
liftWith :: (Run (WriterC o) -> m a) -> WriterC o m a
$cliftWith :: forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
(Run (WriterC o) -> m a) -> WriterC o m a
$cp1MonadTransControl :: forall o. Monoid o => MonadTrans (WriterC o)
MonadTransControl) via (TellC o)

instance ( Carrier m
         , Monoid o
         , Threads (WriterT o) (Prims m)
         )
      => Carrier (WriterC o m) where
  type Derivs (WriterC o m) = Pass o ': Listen o ': Tell o ': Derivs m
  type Prims  (WriterC o m) = WriterPrim o ': Prims m

  algPrims :: Algebra' (Prims (WriterC o m)) (WriterC o m) a
algPrims =
    Algebra' (ListenPrim o : Prims m) (WriterC o m) a
-> (WriterC o m (o -> o, a) -> WriterC o m a)
-> Algebra' (WriterPrim o : Prims m) (WriterC o m) a
forall o (p :: [(* -> *) -> * -> *]) (m :: * -> *) a.
Algebra' (ListenPrim o : p) m a
-> (m (o -> o, a) -> m a) -> Algebra' (WriterPrim o : p) m a
algListenPrimIntoWriterPrim (
      Algebra' (ListenPrim o : Prims m) (ListenC o m) a
-> Algebra' (ListenPrim o : Prims m) (WriterC o m) a
coerce (forall a.
Carrier (ListenC o m) =>
Algebra' (Prims (ListenC o m)) (ListenC o m) a
forall (m :: * -> *) a. Carrier m => Algebra' (Prims m) m a
algPrims @(ListenC o m))
    ) ((WriterC o m (o -> o, a) -> WriterC o m a)
 -> Algebra' (WriterPrim o : Prims m) (WriterC o m) a)
-> (WriterC o m (o -> o, a) -> WriterC o m a)
-> Algebra' (WriterPrim o : Prims m) (WriterC o m) a
forall a b. (a -> b) -> a -> b
$ \(WriterC WriterT o m (o -> o, a)
m) -> WriterT o m a -> WriterC o m a
forall o (m :: * -> *) a. WriterT o m a -> WriterC o m a
WriterC (WriterT o m a -> WriterC o m a) -> WriterT o m a -> WriterC o m a
forall a b. (a -> b) -> a -> b
$ WriterT o m (a, o -> o) -> WriterT o m a
forall w w' (m :: * -> *) a.
(Monoid w, Monoid w', Monad m) =>
WriterT w m (a, w -> w') -> WriterT w' m a
W.pass (WriterT o m (a, o -> o) -> WriterT o m a)
-> WriterT o m (a, o -> o) -> WriterT o m a
forall a b. (a -> b) -> a -> b
$ do
      (o -> o
f, a
a) <- WriterT o m (o -> o, a)
m
      (a, o -> o) -> WriterT o m (a, o -> o)
forall (m :: * -> *) a. Monad m => a -> m a
return (a
a, o -> o
f)
  {-# INLINEABLE algPrims #-}

  reformulate :: Reformulation'
  (Derivs (WriterC o m)) (Prims (WriterC o m)) (WriterC o m) z a
reformulate forall x. WriterC o m x -> z x
n Algebra (Prims (WriterC o m)) z
alg =
    Algebra' (Listen o : Tell o : Derivs m) z a
-> (Pass o z a -> z a)
-> Algebra' (Pass o : Listen o : Tell o : Derivs m) z a
forall (e :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *])
       (m :: * -> *) a.
RepresentationalEff e =>
Algebra' r m a -> (e m a -> m a) -> Algebra' (e : r) m a
powerAlg (
    Algebra' (Tell o : Derivs m) z a
-> (Listen o z a -> z a)
-> Algebra' (Listen o : Tell o : Derivs m) z a
forall (e :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *])
       (m :: * -> *) a.
RepresentationalEff e =>
Algebra' r m a -> (e m a -> m a) -> Algebra' (e : r) m a
powerAlg (
      Reformulation' (Tell o : Derivs m) (Prims m) (TellC o m) z a
-> Reformulation' (Tell o : Derivs m) (Prims m) (WriterC o m) z a
forall (m :: * -> *) (n :: * -> *) (r :: [(* -> *) -> * -> *])
       (p :: [(* -> *) -> * -> *]) (z :: * -> *) a.
Coercible m n =>
Reformulation' r p m z a -> Reformulation' r p n z a
coerceReform (forall (z :: * -> *) a.
(Carrier (TellC o m), Monad z) =>
Reformulation'
  (Derivs (TellC o m)) (Prims (TellC o m)) (TellC o m) z a
forall (m :: * -> *) (z :: * -> *) a.
(Carrier m, Monad z) =>
Reformulation' (Derivs m) (Prims m) m z a
reformulate @(TellC o m)) forall x. WriterC o m x -> z x
n (Algebra' (WriterPrim o : Prims m) z x -> Algebra' (Prims m) z x
forall (e :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *])
       (m :: * -> *) a.
Algebra' (e : r) m a -> Algebra' r m a
weakenAlg Algebra' (WriterPrim o : Prims m) z x
Algebra (Prims (WriterC o m)) z
alg)
    ) ((Listen o z a -> z a)
 -> Algebra' (Listen o : Tell o : Derivs m) z a)
-> (Listen o z a -> z a)
-> Algebra' (Listen o : Tell o : Derivs m) z a
forall a b. (a -> b) -> a -> b
$ \case
      Listen z a
m -> (Union (WriterPrim o : Prims m) z (o, a) -> z a
Algebra (Prims (WriterC o m)) z
alg (Union (WriterPrim o : Prims m) z (o, a) -> z a)
-> (WriterPrim o z (o, a)
    -> Union (WriterPrim o : Prims m) z (o, a))
-> WriterPrim o z (o, a)
-> z a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WriterPrim o z (o, a) -> Union (WriterPrim o : Prims m) z (o, a)
forall (e :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *])
       (m :: * -> *) a.
Member e r =>
e m a -> Union r m a
inj) (WriterPrim o z (o, a) -> z a) -> WriterPrim o z (o, a) -> z a
forall a b. (a -> b) -> a -> b
$ z a -> WriterPrim o z (o, a)
forall (m :: * -> *) a o. m a -> WriterPrim o m (o, a)
WriterPrimListen z a
m
    ) ((Pass o z a -> z a)
 -> Algebra' (Pass o : Listen o : Tell o : Derivs m) z a)
-> (Pass o z a -> z a)
-> Algebra' (Pass o : Listen o : Tell o : Derivs m) z a
forall a b. (a -> b) -> a -> b
$ \case
      Pass z (o -> o, a)
m -> (Union (WriterPrim o : Prims m) z a -> z a
Algebra (Prims (WriterC o m)) z
alg (Union (WriterPrim o : Prims m) z a -> z a)
-> (WriterPrim o z a -> Union (WriterPrim o : Prims m) z a)
-> WriterPrim o z a
-> z a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WriterPrim o z a -> Union (WriterPrim o : Prims m) z a
forall (e :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *])
       (m :: * -> *) a.
Member e r =>
e m a -> Union r m a
inj) (WriterPrim o z a -> z a) -> WriterPrim o z a -> z a
forall a b. (a -> b) -> a -> b
$ z (o -> o, a) -> WriterPrim o z a
forall (m :: * -> *) o a. m (o -> o, a) -> WriterPrim o m a
WriterPrimPass z (o -> o, a)
m
  {-# INLINEABLE reformulate #-}


newtype TellLazyC o m a = TellLazyC {
    TellLazyC o m a -> WriterT o m a
unTellLazyC :: LW.WriterT o m a
  }
  deriving ( a -> TellLazyC o m b -> TellLazyC o m a
(a -> b) -> TellLazyC o m a -> TellLazyC o m b
(forall a b. (a -> b) -> TellLazyC o m a -> TellLazyC o m b)
-> (forall a b. a -> TellLazyC o m b -> TellLazyC o m a)
-> Functor (TellLazyC o m)
forall a b. a -> TellLazyC o m b -> TellLazyC o m a
forall a b. (a -> b) -> TellLazyC o m a -> TellLazyC o m b
forall o (m :: * -> *) a b.
Functor m =>
a -> TellLazyC o m b -> TellLazyC o m a
forall o (m :: * -> *) a b.
Functor m =>
(a -> b) -> TellLazyC o m a -> TellLazyC o m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> TellLazyC o m b -> TellLazyC o m a
$c<$ :: forall o (m :: * -> *) a b.
Functor m =>
a -> TellLazyC o m b -> TellLazyC o m a
fmap :: (a -> b) -> TellLazyC o m a -> TellLazyC o m b
$cfmap :: forall o (m :: * -> *) a b.
Functor m =>
(a -> b) -> TellLazyC o m a -> TellLazyC o m b
Functor, Functor (TellLazyC o m)
a -> TellLazyC o m a
Functor (TellLazyC o m)
-> (forall a. a -> TellLazyC o m a)
-> (forall a b.
    TellLazyC o m (a -> b) -> TellLazyC o m a -> TellLazyC o m b)
-> (forall a b c.
    (a -> b -> c)
    -> TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m c)
-> (forall a b.
    TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m b)
-> (forall a b.
    TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m a)
-> Applicative (TellLazyC o m)
TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m b
TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m a
TellLazyC o m (a -> b) -> TellLazyC o m a -> TellLazyC o m b
(a -> b -> c)
-> TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m c
forall a. a -> TellLazyC o m a
forall a b. TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m a
forall a b. TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m b
forall a b.
TellLazyC o m (a -> b) -> TellLazyC o m a -> TellLazyC o m b
forall a b c.
(a -> b -> c)
-> TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m c
forall o (m :: * -> *).
(Monoid o, Applicative m) =>
Functor (TellLazyC o m)
forall o (m :: * -> *) a.
(Monoid o, Applicative m) =>
a -> TellLazyC o m a
forall o (m :: * -> *) a b.
(Monoid o, Applicative m) =>
TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m a
forall o (m :: * -> *) a b.
(Monoid o, Applicative m) =>
TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m b
forall o (m :: * -> *) a b.
(Monoid o, Applicative m) =>
TellLazyC o m (a -> b) -> TellLazyC o m a -> TellLazyC o m b
forall o (m :: * -> *) a b c.
(Monoid o, Applicative m) =>
(a -> b -> c)
-> TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
<* :: TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m a
$c<* :: forall o (m :: * -> *) a b.
(Monoid o, Applicative m) =>
TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m a
*> :: TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m b
$c*> :: forall o (m :: * -> *) a b.
(Monoid o, Applicative m) =>
TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m b
liftA2 :: (a -> b -> c)
-> TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m c
$cliftA2 :: forall o (m :: * -> *) a b c.
(Monoid o, Applicative m) =>
(a -> b -> c)
-> TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m c
<*> :: TellLazyC o m (a -> b) -> TellLazyC o m a -> TellLazyC o m b
$c<*> :: forall o (m :: * -> *) a b.
(Monoid o, Applicative m) =>
TellLazyC o m (a -> b) -> TellLazyC o m a -> TellLazyC o m b
pure :: a -> TellLazyC o m a
$cpure :: forall o (m :: * -> *) a.
(Monoid o, Applicative m) =>
a -> TellLazyC o m a
$cp1Applicative :: forall o (m :: * -> *).
(Monoid o, Applicative m) =>
Functor (TellLazyC o m)
Applicative, Applicative (TellLazyC o m)
a -> TellLazyC o m a
Applicative (TellLazyC o m)
-> (forall a b.
    TellLazyC o m a -> (a -> TellLazyC o m b) -> TellLazyC o m b)
-> (forall a b.
    TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m b)
-> (forall a. a -> TellLazyC o m a)
-> Monad (TellLazyC o m)
TellLazyC o m a -> (a -> TellLazyC o m b) -> TellLazyC o m b
TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m b
forall a. a -> TellLazyC o m a
forall a b. TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m b
forall a b.
TellLazyC o m a -> (a -> TellLazyC o m b) -> TellLazyC o m b
forall o (m :: * -> *).
(Monoid o, Monad m) =>
Applicative (TellLazyC o m)
forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
a -> TellLazyC o m a
forall o (m :: * -> *) a b.
(Monoid o, Monad m) =>
TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m b
forall o (m :: * -> *) a b.
(Monoid o, Monad m) =>
TellLazyC o m a -> (a -> TellLazyC o m b) -> TellLazyC o m b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> TellLazyC o m a
$creturn :: forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
a -> TellLazyC o m a
>> :: TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m b
$c>> :: forall o (m :: * -> *) a b.
(Monoid o, Monad m) =>
TellLazyC o m a -> TellLazyC o m b -> TellLazyC o m b
>>= :: TellLazyC o m a -> (a -> TellLazyC o m b) -> TellLazyC o m b
$c>>= :: forall o (m :: * -> *) a b.
(Monoid o, Monad m) =>
TellLazyC o m a -> (a -> TellLazyC o m b) -> TellLazyC o m b
$cp1Monad :: forall o (m :: * -> *).
(Monoid o, Monad m) =>
Applicative (TellLazyC o m)
Monad
           , Applicative (TellLazyC o m)
TellLazyC o m a
Applicative (TellLazyC o m)
-> (forall a. TellLazyC o m a)
-> (forall a.
    TellLazyC o m a -> TellLazyC o m a -> TellLazyC o m a)
-> (forall a. TellLazyC o m a -> TellLazyC o m [a])
-> (forall a. TellLazyC o m a -> TellLazyC o m [a])
-> Alternative (TellLazyC o m)
TellLazyC o m a -> TellLazyC o m a -> TellLazyC o m a
TellLazyC o m a -> TellLazyC o m [a]
TellLazyC o m a -> TellLazyC o m [a]
forall a. TellLazyC o m a
forall a. TellLazyC o m a -> TellLazyC o m [a]
forall a. TellLazyC o m a -> TellLazyC o m a -> TellLazyC o m a
forall o (m :: * -> *).
(Monoid o, Alternative m) =>
Applicative (TellLazyC o m)
forall o (m :: * -> *) a.
(Monoid o, Alternative m) =>
TellLazyC o m a
forall o (m :: * -> *) a.
(Monoid o, Alternative m) =>
TellLazyC o m a -> TellLazyC o m [a]
forall o (m :: * -> *) a.
(Monoid o, Alternative m) =>
TellLazyC o m a -> TellLazyC o m a -> TellLazyC o m a
forall (f :: * -> *).
Applicative f
-> (forall a. f a)
-> (forall a. f a -> f a -> f a)
-> (forall a. f a -> f [a])
-> (forall a. f a -> f [a])
-> Alternative f
many :: TellLazyC o m a -> TellLazyC o m [a]
$cmany :: forall o (m :: * -> *) a.
(Monoid o, Alternative m) =>
TellLazyC o m a -> TellLazyC o m [a]
some :: TellLazyC o m a -> TellLazyC o m [a]
$csome :: forall o (m :: * -> *) a.
(Monoid o, Alternative m) =>
TellLazyC o m a -> TellLazyC o m [a]
<|> :: TellLazyC o m a -> TellLazyC o m a -> TellLazyC o m a
$c<|> :: forall o (m :: * -> *) a.
(Monoid o, Alternative m) =>
TellLazyC o m a -> TellLazyC o m a -> TellLazyC o m a
empty :: TellLazyC o m a
$cempty :: forall o (m :: * -> *) a.
(Monoid o, Alternative m) =>
TellLazyC o m a
$cp1Alternative :: forall o (m :: * -> *).
(Monoid o, Alternative m) =>
Applicative (TellLazyC o m)
Alternative, Monad (TellLazyC o m)
Alternative (TellLazyC o m)
TellLazyC o m a
Alternative (TellLazyC o m)
-> Monad (TellLazyC o m)
-> (forall a. TellLazyC o m a)
-> (forall a.
    TellLazyC o m a -> TellLazyC o m a -> TellLazyC o m a)
-> MonadPlus (TellLazyC o m)
TellLazyC o m a -> TellLazyC o m a -> TellLazyC o m a
forall a. TellLazyC o m a
forall a. TellLazyC o m a -> TellLazyC o m a -> TellLazyC o m a
forall o (m :: * -> *).
(Monoid o, MonadPlus m) =>
Monad (TellLazyC o m)
forall o (m :: * -> *).
(Monoid o, MonadPlus m) =>
Alternative (TellLazyC o m)
forall o (m :: * -> *) a.
(Monoid o, MonadPlus m) =>
TellLazyC o m a
forall o (m :: * -> *) a.
(Monoid o, MonadPlus m) =>
TellLazyC o m a -> TellLazyC o m a -> TellLazyC o m a
forall (m :: * -> *).
Alternative m
-> Monad m
-> (forall a. m a)
-> (forall a. m a -> m a -> m a)
-> MonadPlus m
mplus :: TellLazyC o m a -> TellLazyC o m a -> TellLazyC o m a
$cmplus :: forall o (m :: * -> *) a.
(Monoid o, MonadPlus m) =>
TellLazyC o m a -> TellLazyC o m a -> TellLazyC o m a
mzero :: TellLazyC o m a
$cmzero :: forall o (m :: * -> *) a.
(Monoid o, MonadPlus m) =>
TellLazyC o m a
$cp2MonadPlus :: forall o (m :: * -> *).
(Monoid o, MonadPlus m) =>
Monad (TellLazyC o m)
$cp1MonadPlus :: forall o (m :: * -> *).
(Monoid o, MonadPlus m) =>
Alternative (TellLazyC o m)
MonadPlus
           , Monad (TellLazyC o m)
e -> TellLazyC o m a
Monad (TellLazyC o m)
-> (forall e a. Exception e => e -> TellLazyC o m a)
-> MonadThrow (TellLazyC o m)
forall e a. Exception e => e -> TellLazyC o m a
forall o (m :: * -> *).
(Monoid o, MonadThrow m) =>
Monad (TellLazyC o m)
forall o (m :: * -> *) e a.
(Monoid o, MonadThrow m, Exception e) =>
e -> TellLazyC o m a
forall (m :: * -> *).
Monad m -> (forall e a. Exception e => e -> m a) -> MonadThrow m
throwM :: e -> TellLazyC o m a
$cthrowM :: forall o (m :: * -> *) e a.
(Monoid o, MonadThrow m, Exception e) =>
e -> TellLazyC o m a
$cp1MonadThrow :: forall o (m :: * -> *).
(Monoid o, MonadThrow m) =>
Monad (TellLazyC o m)
MonadThrow, MonadThrow (TellLazyC o m)
MonadThrow (TellLazyC o m)
-> (forall e a.
    Exception e =>
    TellLazyC o m a -> (e -> TellLazyC o m a) -> TellLazyC o m a)
-> MonadCatch (TellLazyC o m)
TellLazyC o m a -> (e -> TellLazyC o m a) -> TellLazyC o m a
forall e a.
Exception e =>
TellLazyC o m a -> (e -> TellLazyC o m a) -> TellLazyC o m a
forall o (m :: * -> *).
(Monoid o, MonadCatch m) =>
MonadThrow (TellLazyC o m)
forall o (m :: * -> *) e a.
(Monoid o, MonadCatch m, Exception e) =>
TellLazyC o m a -> (e -> TellLazyC o m a) -> TellLazyC o m a
forall (m :: * -> *).
MonadThrow m
-> (forall e a. Exception e => m a -> (e -> m a) -> m a)
-> MonadCatch m
catch :: TellLazyC o m a -> (e -> TellLazyC o m a) -> TellLazyC o m a
$ccatch :: forall o (m :: * -> *) e a.
(Monoid o, MonadCatch m, Exception e) =>
TellLazyC o m a -> (e -> TellLazyC o m a) -> TellLazyC o m a
$cp1MonadCatch :: forall o (m :: * -> *).
(Monoid o, MonadCatch m) =>
MonadThrow (TellLazyC o m)
MonadCatch, MonadCatch (TellLazyC o m)
MonadCatch (TellLazyC o m)
-> (forall b.
    ((forall a. TellLazyC o m a -> TellLazyC o m a) -> TellLazyC o m b)
    -> TellLazyC o m b)
-> (forall b.
    ((forall a. TellLazyC o m a -> TellLazyC o m a) -> TellLazyC o m b)
    -> TellLazyC o m b)
-> (forall a b c.
    TellLazyC o m a
    -> (a -> ExitCase b -> TellLazyC o m c)
    -> (a -> TellLazyC o m b)
    -> TellLazyC o m (b, c))
-> MonadMask (TellLazyC o m)
TellLazyC o m a
-> (a -> ExitCase b -> TellLazyC o m c)
-> (a -> TellLazyC o m b)
-> TellLazyC o m (b, c)
((forall a. TellLazyC o m a -> TellLazyC o m a) -> TellLazyC o m b)
-> TellLazyC o m b
((forall a. TellLazyC o m a -> TellLazyC o m a) -> TellLazyC o m b)
-> TellLazyC o m b
forall b.
((forall a. TellLazyC o m a -> TellLazyC o m a) -> TellLazyC o m b)
-> TellLazyC o m b
forall a b c.
TellLazyC o m a
-> (a -> ExitCase b -> TellLazyC o m c)
-> (a -> TellLazyC o m b)
-> TellLazyC o m (b, c)
forall o (m :: * -> *).
(Monoid o, MonadMask m) =>
MonadCatch (TellLazyC o m)
forall o (m :: * -> *) b.
(Monoid o, MonadMask m) =>
((forall a. TellLazyC o m a -> TellLazyC o m a) -> TellLazyC o m b)
-> TellLazyC o m b
forall o (m :: * -> *) a b c.
(Monoid o, MonadMask m) =>
TellLazyC o m a
-> (a -> ExitCase b -> TellLazyC o m c)
-> (a -> TellLazyC o m b)
-> TellLazyC o m (b, c)
forall (m :: * -> *).
MonadCatch m
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall a b c.
    m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c))
-> MonadMask m
generalBracket :: TellLazyC o m a
-> (a -> ExitCase b -> TellLazyC o m c)
-> (a -> TellLazyC o m b)
-> TellLazyC o m (b, c)
$cgeneralBracket :: forall o (m :: * -> *) a b c.
(Monoid o, MonadMask m) =>
TellLazyC o m a
-> (a -> ExitCase b -> TellLazyC o m c)
-> (a -> TellLazyC o m b)
-> TellLazyC o m (b, c)
uninterruptibleMask :: ((forall a. TellLazyC o m a -> TellLazyC o m a) -> TellLazyC o m b)
-> TellLazyC o m b
$cuninterruptibleMask :: forall o (m :: * -> *) b.
(Monoid o, MonadMask m) =>
((forall a. TellLazyC o m a -> TellLazyC o m a) -> TellLazyC o m b)
-> TellLazyC o m b
mask :: ((forall a. TellLazyC o m a -> TellLazyC o m a) -> TellLazyC o m b)
-> TellLazyC o m b
$cmask :: forall o (m :: * -> *) b.
(Monoid o, MonadMask m) =>
((forall a. TellLazyC o m a -> TellLazyC o m a) -> TellLazyC o m b)
-> TellLazyC o m b
$cp1MonadMask :: forall o (m :: * -> *).
(Monoid o, MonadMask m) =>
MonadCatch (TellLazyC o m)
MonadMask
           , Monad (TellLazyC o m)
Monad (TellLazyC o m)
-> (forall a. (a -> TellLazyC o m a) -> TellLazyC o m a)
-> MonadFix (TellLazyC o m)
(a -> TellLazyC o m a) -> TellLazyC o m a
forall a. (a -> TellLazyC o m a) -> TellLazyC o m a
forall o (m :: * -> *).
(Monoid o, MonadFix m) =>
Monad (TellLazyC o m)
forall o (m :: * -> *) a.
(Monoid o, MonadFix m) =>
(a -> TellLazyC o m a) -> TellLazyC o m a
forall (m :: * -> *).
Monad m -> (forall a. (a -> m a) -> m a) -> MonadFix m
mfix :: (a -> TellLazyC o m a) -> TellLazyC o m a
$cmfix :: forall o (m :: * -> *) a.
(Monoid o, MonadFix m) =>
(a -> TellLazyC o m a) -> TellLazyC o m a
$cp1MonadFix :: forall o (m :: * -> *).
(Monoid o, MonadFix m) =>
Monad (TellLazyC o m)
MonadFix, Monad (TellLazyC o m)
Monad (TellLazyC o m)
-> (forall a. String -> TellLazyC o m a)
-> MonadFail (TellLazyC o m)
String -> TellLazyC o m a
forall a. String -> TellLazyC o m a
forall o (m :: * -> *).
(Monoid o, MonadFail m) =>
Monad (TellLazyC o m)
forall o (m :: * -> *) a.
(Monoid o, MonadFail m) =>
String -> TellLazyC o m a
forall (m :: * -> *).
Monad m -> (forall a. String -> m a) -> MonadFail m
fail :: String -> TellLazyC o m a
$cfail :: forall o (m :: * -> *) a.
(Monoid o, MonadFail m) =>
String -> TellLazyC o m a
$cp1MonadFail :: forall o (m :: * -> *).
(Monoid o, MonadFail m) =>
Monad (TellLazyC o m)
MonadFail, Monad (TellLazyC o m)
Monad (TellLazyC o m)
-> (forall a. IO a -> TellLazyC o m a) -> MonadIO (TellLazyC o m)
IO a -> TellLazyC o m a
forall a. IO a -> TellLazyC o m a
forall o (m :: * -> *).
(Monoid o, MonadIO m) =>
Monad (TellLazyC o m)
forall o (m :: * -> *) a.
(Monoid o, MonadIO m) =>
IO a -> TellLazyC o m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
liftIO :: IO a -> TellLazyC o m a
$cliftIO :: forall o (m :: * -> *) a.
(Monoid o, MonadIO m) =>
IO a -> TellLazyC o m a
$cp1MonadIO :: forall o (m :: * -> *).
(Monoid o, MonadIO m) =>
Monad (TellLazyC o m)
MonadIO
           , MonadBase b, MonadBaseControl b
           )
  deriving (m a -> TellLazyC o m a
(forall (m :: * -> *) a. Monad m => m a -> TellLazyC o m a)
-> MonadTrans (TellLazyC o)
forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
m a -> TellLazyC o m a
forall (m :: * -> *) a. Monad m => m a -> TellLazyC o m a
forall (t :: (* -> *) -> * -> *).
(forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
lift :: m a -> TellLazyC o m a
$clift :: forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
m a -> TellLazyC o m a
MonadTrans, MonadTrans (TellLazyC o)
m (StT (TellLazyC o) a) -> TellLazyC o m a
MonadTrans (TellLazyC o)
-> (forall (m :: * -> *) a.
    Monad m =>
    (Run (TellLazyC o) -> m a) -> TellLazyC o m a)
-> (forall (m :: * -> *) a.
    Monad m =>
    m (StT (TellLazyC o) a) -> TellLazyC o m a)
-> MonadTransControl (TellLazyC o)
(Run (TellLazyC o) -> m a) -> TellLazyC o m a
forall o. Monoid o => MonadTrans (TellLazyC o)
forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
m (StT (TellLazyC o) a) -> TellLazyC o m a
forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
(Run (TellLazyC o) -> m a) -> TellLazyC o m a
forall (m :: * -> *) a.
Monad m =>
m (StT (TellLazyC o) a) -> TellLazyC o m a
forall (m :: * -> *) a.
Monad m =>
(Run (TellLazyC o) -> m a) -> TellLazyC o m a
forall (t :: (* -> *) -> * -> *).
MonadTrans t
-> (forall (m :: * -> *) a. Monad m => (Run t -> m a) -> t m a)
-> (forall (m :: * -> *) a. Monad m => m (StT t a) -> t m a)
-> MonadTransControl t
restoreT :: m (StT (TellLazyC o) a) -> TellLazyC o m a
$crestoreT :: forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
m (StT (TellLazyC o) a) -> TellLazyC o m a
liftWith :: (Run (TellLazyC o) -> m a) -> TellLazyC o m a
$cliftWith :: forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
(Run (TellLazyC o) -> m a) -> TellLazyC o m a
$cp1MonadTransControl :: forall o. Monoid o => MonadTrans (TellLazyC o)
MonadTransControl)

instance ( Monoid o
         , Carrier m
         , Threads (LW.WriterT o) (Prims m)
         )
      => Carrier (TellLazyC o m) where
  type Derivs (TellLazyC o m) = Tell o ': Derivs m
  type Prims  (TellLazyC o m) = Prims m

  algPrims :: Algebra' (Prims (TellLazyC o m)) (TellLazyC o m) a
algPrims = (Union (Prims m) (WriterT o m) a -> WriterT o m a)
-> Algebra' (Prims m) (TellLazyC o m) a
coerce (Algebra (Prims m) m -> Algebra (Prims m) (WriterT o m)
forall (t :: (* -> *) -> * -> *) (p :: [(* -> *) -> * -> *])
       (m :: * -> *).
(Threads t p, Monad m) =>
Algebra p m -> Algebra p (t m)
thread @(LW.WriterT o) (Carrier m => Algebra (Prims m) m
forall (m :: * -> *) a. Carrier m => Algebra' (Prims m) m a
algPrims @m))
  {-# INLINEABLE algPrims #-}

  reformulate :: Reformulation'
  (Derivs (TellLazyC o m))
  (Prims (TellLazyC o m))
  (TellLazyC o m)
  z
  a
reformulate forall x. TellLazyC o m x -> z x
n Algebra (Prims (TellLazyC o m)) z
alg = Algebra' (Derivs m) z a
-> (Tell o z a -> z a) -> Algebra' (Tell o : Derivs m) z a
forall (e :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *])
       (m :: * -> *) a.
RepresentationalEff e =>
Algebra' r m a -> (e m a -> m a) -> Algebra' (e : r) m a
powerAlg (Reformulation' (Derivs m) (Prims m) m z a
forall (m :: * -> *) (z :: * -> *) a.
(Carrier m, Monad z) =>
Reformulation' (Derivs m) (Prims m) m z a
reformulate (TellLazyC o m x -> z x
forall x. TellLazyC o m x -> z x
n (TellLazyC o m x -> z x) -> (m x -> TellLazyC o m x) -> m x -> z x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m x -> TellLazyC o m x
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift) forall x. Union (Prims m) z x -> z x
Algebra (Prims (TellLazyC o m)) z
alg) ((Tell o z a -> z a) -> Algebra' (Tell o : Derivs m) z a)
-> (Tell o z a -> z a) -> Algebra' (Tell o : Derivs m) z a
forall a b. (a -> b) -> a -> b
$ \case
    Tell o
o -> TellLazyC o m () -> z ()
forall x. TellLazyC o m x -> z x
n (TellLazyC o m () -> z ()) -> TellLazyC o m () -> z ()
forall a b. (a -> b) -> a -> b
$ WriterT o m () -> TellLazyC o m ()
forall o (m :: * -> *) a. WriterT o m a -> TellLazyC o m a
TellLazyC (WriterT o m () -> TellLazyC o m ())
-> WriterT o m () -> TellLazyC o m ()
forall a b. (a -> b) -> a -> b
$ o -> WriterT o m ()
forall (m :: * -> *) w. Monad m => w -> WriterT w m ()
LW.tell o
o
  {-# INLINEABLE reformulate #-}

newtype ListenLazyC o m a = ListenLazyC {
    ListenLazyC o m a -> WriterT o m a
unListenLazyC :: LW.WriterT o m a
  }
  deriving ( a -> ListenLazyC o m b -> ListenLazyC o m a
(a -> b) -> ListenLazyC o m a -> ListenLazyC o m b
(forall a b. (a -> b) -> ListenLazyC o m a -> ListenLazyC o m b)
-> (forall a b. a -> ListenLazyC o m b -> ListenLazyC o m a)
-> Functor (ListenLazyC o m)
forall a b. a -> ListenLazyC o m b -> ListenLazyC o m a
forall a b. (a -> b) -> ListenLazyC o m a -> ListenLazyC o m b
forall o (m :: * -> *) a b.
Functor m =>
a -> ListenLazyC o m b -> ListenLazyC o m a
forall o (m :: * -> *) a b.
Functor m =>
(a -> b) -> ListenLazyC o m a -> ListenLazyC o m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> ListenLazyC o m b -> ListenLazyC o m a
$c<$ :: forall o (m :: * -> *) a b.
Functor m =>
a -> ListenLazyC o m b -> ListenLazyC o m a
fmap :: (a -> b) -> ListenLazyC o m a -> ListenLazyC o m b
$cfmap :: forall o (m :: * -> *) a b.
Functor m =>
(a -> b) -> ListenLazyC o m a -> ListenLazyC o m b
Functor, Functor (ListenLazyC o m)
a -> ListenLazyC o m a
Functor (ListenLazyC o m)
-> (forall a. a -> ListenLazyC o m a)
-> (forall a b.
    ListenLazyC o m (a -> b) -> ListenLazyC o m a -> ListenLazyC o m b)
-> (forall a b c.
    (a -> b -> c)
    -> ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m c)
-> (forall a b.
    ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m b)
-> (forall a b.
    ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m a)
-> Applicative (ListenLazyC o m)
ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m b
ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m a
ListenLazyC o m (a -> b) -> ListenLazyC o m a -> ListenLazyC o m b
(a -> b -> c)
-> ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m c
forall a. a -> ListenLazyC o m a
forall a b.
ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m a
forall a b.
ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m b
forall a b.
ListenLazyC o m (a -> b) -> ListenLazyC o m a -> ListenLazyC o m b
forall a b c.
(a -> b -> c)
-> ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m c
forall o (m :: * -> *).
(Monoid o, Applicative m) =>
Functor (ListenLazyC o m)
forall o (m :: * -> *) a.
(Monoid o, Applicative m) =>
a -> ListenLazyC o m a
forall o (m :: * -> *) a b.
(Monoid o, Applicative m) =>
ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m a
forall o (m :: * -> *) a b.
(Monoid o, Applicative m) =>
ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m b
forall o (m :: * -> *) a b.
(Monoid o, Applicative m) =>
ListenLazyC o m (a -> b) -> ListenLazyC o m a -> ListenLazyC o m b
forall o (m :: * -> *) a b c.
(Monoid o, Applicative m) =>
(a -> b -> c)
-> ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
<* :: ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m a
$c<* :: forall o (m :: * -> *) a b.
(Monoid o, Applicative m) =>
ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m a
*> :: ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m b
$c*> :: forall o (m :: * -> *) a b.
(Monoid o, Applicative m) =>
ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m b
liftA2 :: (a -> b -> c)
-> ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m c
$cliftA2 :: forall o (m :: * -> *) a b c.
(Monoid o, Applicative m) =>
(a -> b -> c)
-> ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m c
<*> :: ListenLazyC o m (a -> b) -> ListenLazyC o m a -> ListenLazyC o m b
$c<*> :: forall o (m :: * -> *) a b.
(Monoid o, Applicative m) =>
ListenLazyC o m (a -> b) -> ListenLazyC o m a -> ListenLazyC o m b
pure :: a -> ListenLazyC o m a
$cpure :: forall o (m :: * -> *) a.
(Monoid o, Applicative m) =>
a -> ListenLazyC o m a
$cp1Applicative :: forall o (m :: * -> *).
(Monoid o, Applicative m) =>
Functor (ListenLazyC o m)
Applicative, Applicative (ListenLazyC o m)
a -> ListenLazyC o m a
Applicative (ListenLazyC o m)
-> (forall a b.
    ListenLazyC o m a -> (a -> ListenLazyC o m b) -> ListenLazyC o m b)
-> (forall a b.
    ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m b)
-> (forall a. a -> ListenLazyC o m a)
-> Monad (ListenLazyC o m)
ListenLazyC o m a -> (a -> ListenLazyC o m b) -> ListenLazyC o m b
ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m b
forall a. a -> ListenLazyC o m a
forall a b.
ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m b
forall a b.
ListenLazyC o m a -> (a -> ListenLazyC o m b) -> ListenLazyC o m b
forall o (m :: * -> *).
(Monoid o, Monad m) =>
Applicative (ListenLazyC o m)
forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
a -> ListenLazyC o m a
forall o (m :: * -> *) a b.
(Monoid o, Monad m) =>
ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m b
forall o (m :: * -> *) a b.
(Monoid o, Monad m) =>
ListenLazyC o m a -> (a -> ListenLazyC o m b) -> ListenLazyC o m b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> ListenLazyC o m a
$creturn :: forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
a -> ListenLazyC o m a
>> :: ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m b
$c>> :: forall o (m :: * -> *) a b.
(Monoid o, Monad m) =>
ListenLazyC o m a -> ListenLazyC o m b -> ListenLazyC o m b
>>= :: ListenLazyC o m a -> (a -> ListenLazyC o m b) -> ListenLazyC o m b
$c>>= :: forall o (m :: * -> *) a b.
(Monoid o, Monad m) =>
ListenLazyC o m a -> (a -> ListenLazyC o m b) -> ListenLazyC o m b
$cp1Monad :: forall o (m :: * -> *).
(Monoid o, Monad m) =>
Applicative (ListenLazyC o m)
Monad
           , Applicative (ListenLazyC o m)
ListenLazyC o m a
Applicative (ListenLazyC o m)
-> (forall a. ListenLazyC o m a)
-> (forall a.
    ListenLazyC o m a -> ListenLazyC o m a -> ListenLazyC o m a)
-> (forall a. ListenLazyC o m a -> ListenLazyC o m [a])
-> (forall a. ListenLazyC o m a -> ListenLazyC o m [a])
-> Alternative (ListenLazyC o m)
ListenLazyC o m a -> ListenLazyC o m a -> ListenLazyC o m a
ListenLazyC o m a -> ListenLazyC o m [a]
ListenLazyC o m a -> ListenLazyC o m [a]
forall a. ListenLazyC o m a
forall a. ListenLazyC o m a -> ListenLazyC o m [a]
forall a.
ListenLazyC o m a -> ListenLazyC o m a -> ListenLazyC o m a
forall o (m :: * -> *).
(Monoid o, Alternative m) =>
Applicative (ListenLazyC o m)
forall o (m :: * -> *) a.
(Monoid o, Alternative m) =>
ListenLazyC o m a
forall o (m :: * -> *) a.
(Monoid o, Alternative m) =>
ListenLazyC o m a -> ListenLazyC o m [a]
forall o (m :: * -> *) a.
(Monoid o, Alternative m) =>
ListenLazyC o m a -> ListenLazyC o m a -> ListenLazyC o m a
forall (f :: * -> *).
Applicative f
-> (forall a. f a)
-> (forall a. f a -> f a -> f a)
-> (forall a. f a -> f [a])
-> (forall a. f a -> f [a])
-> Alternative f
many :: ListenLazyC o m a -> ListenLazyC o m [a]
$cmany :: forall o (m :: * -> *) a.
(Monoid o, Alternative m) =>
ListenLazyC o m a -> ListenLazyC o m [a]
some :: ListenLazyC o m a -> ListenLazyC o m [a]
$csome :: forall o (m :: * -> *) a.
(Monoid o, Alternative m) =>
ListenLazyC o m a -> ListenLazyC o m [a]
<|> :: ListenLazyC o m a -> ListenLazyC o m a -> ListenLazyC o m a
$c<|> :: forall o (m :: * -> *) a.
(Monoid o, Alternative m) =>
ListenLazyC o m a -> ListenLazyC o m a -> ListenLazyC o m a
empty :: ListenLazyC o m a
$cempty :: forall o (m :: * -> *) a.
(Monoid o, Alternative m) =>
ListenLazyC o m a
$cp1Alternative :: forall o (m :: * -> *).
(Monoid o, Alternative m) =>
Applicative (ListenLazyC o m)
Alternative, Monad (ListenLazyC o m)
Alternative (ListenLazyC o m)
ListenLazyC o m a
Alternative (ListenLazyC o m)
-> Monad (ListenLazyC o m)
-> (forall a. ListenLazyC o m a)
-> (forall a.
    ListenLazyC o m a -> ListenLazyC o m a -> ListenLazyC o m a)
-> MonadPlus (ListenLazyC o m)
ListenLazyC o m a -> ListenLazyC o m a -> ListenLazyC o m a
forall a. ListenLazyC o m a
forall a.
ListenLazyC o m a -> ListenLazyC o m a -> ListenLazyC o m a
forall o (m :: * -> *).
(Monoid o, MonadPlus m) =>
Monad (ListenLazyC o m)
forall o (m :: * -> *).
(Monoid o, MonadPlus m) =>
Alternative (ListenLazyC o m)
forall o (m :: * -> *) a.
(Monoid o, MonadPlus m) =>
ListenLazyC o m a
forall o (m :: * -> *) a.
(Monoid o, MonadPlus m) =>
ListenLazyC o m a -> ListenLazyC o m a -> ListenLazyC o m a
forall (m :: * -> *).
Alternative m
-> Monad m
-> (forall a. m a)
-> (forall a. m a -> m a -> m a)
-> MonadPlus m
mplus :: ListenLazyC o m a -> ListenLazyC o m a -> ListenLazyC o m a
$cmplus :: forall o (m :: * -> *) a.
(Monoid o, MonadPlus m) =>
ListenLazyC o m a -> ListenLazyC o m a -> ListenLazyC o m a
mzero :: ListenLazyC o m a
$cmzero :: forall o (m :: * -> *) a.
(Monoid o, MonadPlus m) =>
ListenLazyC o m a
$cp2MonadPlus :: forall o (m :: * -> *).
(Monoid o, MonadPlus m) =>
Monad (ListenLazyC o m)
$cp1MonadPlus :: forall o (m :: * -> *).
(Monoid o, MonadPlus m) =>
Alternative (ListenLazyC o m)
MonadPlus
           , Monad (ListenLazyC o m)
e -> ListenLazyC o m a
Monad (ListenLazyC o m)
-> (forall e a. Exception e => e -> ListenLazyC o m a)
-> MonadThrow (ListenLazyC o m)
forall e a. Exception e => e -> ListenLazyC o m a
forall o (m :: * -> *).
(Monoid o, MonadThrow m) =>
Monad (ListenLazyC o m)
forall o (m :: * -> *) e a.
(Monoid o, MonadThrow m, Exception e) =>
e -> ListenLazyC o m a
forall (m :: * -> *).
Monad m -> (forall e a. Exception e => e -> m a) -> MonadThrow m
throwM :: e -> ListenLazyC o m a
$cthrowM :: forall o (m :: * -> *) e a.
(Monoid o, MonadThrow m, Exception e) =>
e -> ListenLazyC o m a
$cp1MonadThrow :: forall o (m :: * -> *).
(Monoid o, MonadThrow m) =>
Monad (ListenLazyC o m)
MonadThrow, MonadThrow (ListenLazyC o m)
MonadThrow (ListenLazyC o m)
-> (forall e a.
    Exception e =>
    ListenLazyC o m a -> (e -> ListenLazyC o m a) -> ListenLazyC o m a)
-> MonadCatch (ListenLazyC o m)
ListenLazyC o m a -> (e -> ListenLazyC o m a) -> ListenLazyC o m a
forall e a.
Exception e =>
ListenLazyC o m a -> (e -> ListenLazyC o m a) -> ListenLazyC o m a
forall o (m :: * -> *).
(Monoid o, MonadCatch m) =>
MonadThrow (ListenLazyC o m)
forall o (m :: * -> *) e a.
(Monoid o, MonadCatch m, Exception e) =>
ListenLazyC o m a -> (e -> ListenLazyC o m a) -> ListenLazyC o m a
forall (m :: * -> *).
MonadThrow m
-> (forall e a. Exception e => m a -> (e -> m a) -> m a)
-> MonadCatch m
catch :: ListenLazyC o m a -> (e -> ListenLazyC o m a) -> ListenLazyC o m a
$ccatch :: forall o (m :: * -> *) e a.
(Monoid o, MonadCatch m, Exception e) =>
ListenLazyC o m a -> (e -> ListenLazyC o m a) -> ListenLazyC o m a
$cp1MonadCatch :: forall o (m :: * -> *).
(Monoid o, MonadCatch m) =>
MonadThrow (ListenLazyC o m)
MonadCatch, MonadCatch (ListenLazyC o m)
MonadCatch (ListenLazyC o m)
-> (forall b.
    ((forall a. ListenLazyC o m a -> ListenLazyC o m a)
     -> ListenLazyC o m b)
    -> ListenLazyC o m b)
-> (forall b.
    ((forall a. ListenLazyC o m a -> ListenLazyC o m a)
     -> ListenLazyC o m b)
    -> ListenLazyC o m b)
-> (forall a b c.
    ListenLazyC o m a
    -> (a -> ExitCase b -> ListenLazyC o m c)
    -> (a -> ListenLazyC o m b)
    -> ListenLazyC o m (b, c))
-> MonadMask (ListenLazyC o m)
ListenLazyC o m a
-> (a -> ExitCase b -> ListenLazyC o m c)
-> (a -> ListenLazyC o m b)
-> ListenLazyC o m (b, c)
((forall a. ListenLazyC o m a -> ListenLazyC o m a)
 -> ListenLazyC o m b)
-> ListenLazyC o m b
((forall a. ListenLazyC o m a -> ListenLazyC o m a)
 -> ListenLazyC o m b)
-> ListenLazyC o m b
forall b.
((forall a. ListenLazyC o m a -> ListenLazyC o m a)
 -> ListenLazyC o m b)
-> ListenLazyC o m b
forall a b c.
ListenLazyC o m a
-> (a -> ExitCase b -> ListenLazyC o m c)
-> (a -> ListenLazyC o m b)
-> ListenLazyC o m (b, c)
forall o (m :: * -> *).
(Monoid o, MonadMask m) =>
MonadCatch (ListenLazyC o m)
forall o (m :: * -> *) b.
(Monoid o, MonadMask m) =>
((forall a. ListenLazyC o m a -> ListenLazyC o m a)
 -> ListenLazyC o m b)
-> ListenLazyC o m b
forall o (m :: * -> *) a b c.
(Monoid o, MonadMask m) =>
ListenLazyC o m a
-> (a -> ExitCase b -> ListenLazyC o m c)
-> (a -> ListenLazyC o m b)
-> ListenLazyC o m (b, c)
forall (m :: * -> *).
MonadCatch m
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall a b c.
    m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c))
-> MonadMask m
generalBracket :: ListenLazyC o m a
-> (a -> ExitCase b -> ListenLazyC o m c)
-> (a -> ListenLazyC o m b)
-> ListenLazyC o m (b, c)
$cgeneralBracket :: forall o (m :: * -> *) a b c.
(Monoid o, MonadMask m) =>
ListenLazyC o m a
-> (a -> ExitCase b -> ListenLazyC o m c)
-> (a -> ListenLazyC o m b)
-> ListenLazyC o m (b, c)
uninterruptibleMask :: ((forall a. ListenLazyC o m a -> ListenLazyC o m a)
 -> ListenLazyC o m b)
-> ListenLazyC o m b
$cuninterruptibleMask :: forall o (m :: * -> *) b.
(Monoid o, MonadMask m) =>
((forall a. ListenLazyC o m a -> ListenLazyC o m a)
 -> ListenLazyC o m b)
-> ListenLazyC o m b
mask :: ((forall a. ListenLazyC o m a -> ListenLazyC o m a)
 -> ListenLazyC o m b)
-> ListenLazyC o m b
$cmask :: forall o (m :: * -> *) b.
(Monoid o, MonadMask m) =>
((forall a. ListenLazyC o m a -> ListenLazyC o m a)
 -> ListenLazyC o m b)
-> ListenLazyC o m b
$cp1MonadMask :: forall o (m :: * -> *).
(Monoid o, MonadMask m) =>
MonadCatch (ListenLazyC o m)
MonadMask
           , Monad (ListenLazyC o m)
Monad (ListenLazyC o m)
-> (forall a. (a -> ListenLazyC o m a) -> ListenLazyC o m a)
-> MonadFix (ListenLazyC o m)
(a -> ListenLazyC o m a) -> ListenLazyC o m a
forall a. (a -> ListenLazyC o m a) -> ListenLazyC o m a
forall o (m :: * -> *).
(Monoid o, MonadFix m) =>
Monad (ListenLazyC o m)
forall o (m :: * -> *) a.
(Monoid o, MonadFix m) =>
(a -> ListenLazyC o m a) -> ListenLazyC o m a
forall (m :: * -> *).
Monad m -> (forall a. (a -> m a) -> m a) -> MonadFix m
mfix :: (a -> ListenLazyC o m a) -> ListenLazyC o m a
$cmfix :: forall o (m :: * -> *) a.
(Monoid o, MonadFix m) =>
(a -> ListenLazyC o m a) -> ListenLazyC o m a
$cp1MonadFix :: forall o (m :: * -> *).
(Monoid o, MonadFix m) =>
Monad (ListenLazyC o m)
MonadFix, Monad (ListenLazyC o m)
Monad (ListenLazyC o m)
-> (forall a. String -> ListenLazyC o m a)
-> MonadFail (ListenLazyC o m)
String -> ListenLazyC o m a
forall a. String -> ListenLazyC o m a
forall o (m :: * -> *).
(Monoid o, MonadFail m) =>
Monad (ListenLazyC o m)
forall o (m :: * -> *) a.
(Monoid o, MonadFail m) =>
String -> ListenLazyC o m a
forall (m :: * -> *).
Monad m -> (forall a. String -> m a) -> MonadFail m
fail :: String -> ListenLazyC o m a
$cfail :: forall o (m :: * -> *) a.
(Monoid o, MonadFail m) =>
String -> ListenLazyC o m a
$cp1MonadFail :: forall o (m :: * -> *).
(Monoid o, MonadFail m) =>
Monad (ListenLazyC o m)
MonadFail, Monad (ListenLazyC o m)
Monad (ListenLazyC o m)
-> (forall a. IO a -> ListenLazyC o m a)
-> MonadIO (ListenLazyC o m)
IO a -> ListenLazyC o m a
forall a. IO a -> ListenLazyC o m a
forall o (m :: * -> *).
(Monoid o, MonadIO m) =>
Monad (ListenLazyC o m)
forall o (m :: * -> *) a.
(Monoid o, MonadIO m) =>
IO a -> ListenLazyC o m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
liftIO :: IO a -> ListenLazyC o m a
$cliftIO :: forall o (m :: * -> *) a.
(Monoid o, MonadIO m) =>
IO a -> ListenLazyC o m a
$cp1MonadIO :: forall o (m :: * -> *).
(Monoid o, MonadIO m) =>
Monad (ListenLazyC o m)
MonadIO
           , MonadBase b, MonadBaseControl b
           )
  deriving (m a -> ListenLazyC o m a
(forall (m :: * -> *) a. Monad m => m a -> ListenLazyC o m a)
-> MonadTrans (ListenLazyC o)
forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
m a -> ListenLazyC o m a
forall (m :: * -> *) a. Monad m => m a -> ListenLazyC o m a
forall (t :: (* -> *) -> * -> *).
(forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
lift :: m a -> ListenLazyC o m a
$clift :: forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
m a -> ListenLazyC o m a
MonadTrans, MonadTrans (ListenLazyC o)
m (StT (ListenLazyC o) a) -> ListenLazyC o m a
MonadTrans (ListenLazyC o)
-> (forall (m :: * -> *) a.
    Monad m =>
    (Run (ListenLazyC o) -> m a) -> ListenLazyC o m a)
-> (forall (m :: * -> *) a.
    Monad m =>
    m (StT (ListenLazyC o) a) -> ListenLazyC o m a)
-> MonadTransControl (ListenLazyC o)
(Run (ListenLazyC o) -> m a) -> ListenLazyC o m a
forall o. Monoid o => MonadTrans (ListenLazyC o)
forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
m (StT (ListenLazyC o) a) -> ListenLazyC o m a
forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
(Run (ListenLazyC o) -> m a) -> ListenLazyC o m a
forall (m :: * -> *) a.
Monad m =>
m (StT (ListenLazyC o) a) -> ListenLazyC o m a
forall (m :: * -> *) a.
Monad m =>
(Run (ListenLazyC o) -> m a) -> ListenLazyC o m a
forall (t :: (* -> *) -> * -> *).
MonadTrans t
-> (forall (m :: * -> *) a. Monad m => (Run t -> m a) -> t m a)
-> (forall (m :: * -> *) a. Monad m => m (StT t a) -> t m a)
-> MonadTransControl t
restoreT :: m (StT (ListenLazyC o) a) -> ListenLazyC o m a
$crestoreT :: forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
m (StT (ListenLazyC o) a) -> ListenLazyC o m a
liftWith :: (Run (ListenLazyC o) -> m a) -> ListenLazyC o m a
$cliftWith :: forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
(Run (ListenLazyC o) -> m a) -> ListenLazyC o m a
$cp1MonadTransControl :: forall o. Monoid o => MonadTrans (ListenLazyC o)
MonadTransControl)

instance ( Monoid o
         , Carrier m
         , Threads (LW.WriterT o) (Prims m)
         )
      => Carrier (ListenLazyC o m) where
  type Derivs (ListenLazyC o m) = Listen o ': Tell o ': Derivs m
  type Prims  (ListenLazyC o m) = ListenPrim o ': Prims m

  algPrims :: Algebra' (Prims (ListenLazyC o m)) (ListenLazyC o m) a
algPrims =
    Algebra' (Prims m) (ListenLazyC o m) a
-> (ListenPrim o (ListenLazyC o m) a -> ListenLazyC o m a)
-> Algebra' (ListenPrim o : Prims m) (ListenLazyC o m) a
forall (e :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *])
       (m :: * -> *) a.
RepresentationalEff e =>
Algebra' r m a -> (e m a -> m a) -> Algebra' (e : r) m a
powerAlg (
      Algebra' (Prims m) (TellLazyC o m) a
-> Algebra' (Prims m) (ListenLazyC o m) a
coerce (forall a.
Carrier (TellLazyC o m) =>
Algebra' (Prims (TellLazyC o m)) (TellLazyC o m) a
forall (m :: * -> *) a. Carrier m => Algebra' (Prims m) m a
algPrims @(TellLazyC o m))
    ) ((ListenPrim o (ListenLazyC o m) a -> ListenLazyC o m a)
 -> Algebra' (ListenPrim o : Prims m) (ListenLazyC o m) a)
-> (ListenPrim o (ListenLazyC o m) a -> ListenLazyC o m a)
-> Algebra' (ListenPrim o : Prims m) (ListenLazyC o m) a
forall a b. (a -> b) -> a -> b
$ \case
      ListenPrimTell o
o ->
        WriterT o m () -> ListenLazyC o m ()
forall o (m :: * -> *) a. WriterT o m a -> ListenLazyC o m a
ListenLazyC (WriterT o m () -> ListenLazyC o m ())
-> WriterT o m () -> ListenLazyC o m ()
forall a b. (a -> b) -> a -> b
$ o -> WriterT o m ()
forall (m :: * -> *) w. Monad m => w -> WriterT w m ()
LW.tell o
o
      ListenPrimListen (ListenLazyC m) ->
        WriterT o m (o, a) -> ListenLazyC o m (o, a)
forall o (m :: * -> *) a. WriterT o m a -> ListenLazyC o m a
ListenLazyC (WriterT o m (o, a) -> ListenLazyC o m (o, a))
-> WriterT o m (o, a) -> ListenLazyC o m (o, a)
forall a b. (a -> b) -> a -> b
$ (a, o) -> (o, a)
forall a b. (a, b) -> (b, a)
swap ((a, o) -> (o, a)) -> WriterT o m (a, o) -> WriterT o m (o, a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> WriterT o m a -> WriterT o m (a, o)
forall (m :: * -> *) w a.
Monad m =>
WriterT w m a -> WriterT w m (a, w)
LW.listen WriterT o m a
m
  {-# INLINEABLE algPrims #-}

  reformulate :: Reformulation'
  (Derivs (ListenLazyC o m))
  (Prims (ListenLazyC o m))
  (ListenLazyC o m)
  z
  a
reformulate forall x. ListenLazyC o m x -> z x
n Algebra (Prims (ListenLazyC o m)) z
alg =
    Algebra' (Tell o : Derivs m) z a
-> (Listen o z a -> z a)
-> Algebra' (Listen o : Tell o : Derivs m) z a
forall (e :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *])
       (m :: * -> *) a.
RepresentationalEff e =>
Algebra' r m a -> (e m a -> m a) -> Algebra' (e : r) m a
powerAlg (
      Reformulation' (Tell o : Derivs m) (Prims m) (TellLazyC o m) z a
-> Reformulation'
     (Tell o : Derivs m) (Prims m) (ListenLazyC o m) z a
forall (m :: * -> *) (n :: * -> *) (r :: [(* -> *) -> * -> *])
       (p :: [(* -> *) -> * -> *]) (z :: * -> *) a.
Coercible m n =>
Reformulation' r p m z a -> Reformulation' r p n z a
coerceReform (forall (z :: * -> *) a.
(Carrier (TellLazyC o m), Monad z) =>
Reformulation'
  (Derivs (TellLazyC o m))
  (Prims (TellLazyC o m))
  (TellLazyC o m)
  z
  a
forall (m :: * -> *) (z :: * -> *) a.
(Carrier m, Monad z) =>
Reformulation' (Derivs m) (Prims m) m z a
reformulate @(TellLazyC o m)) forall x. ListenLazyC o m x -> z x
n (Algebra' (ListenPrim o : Prims m) z x -> Algebra' (Prims m) z x
forall (e :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *])
       (m :: * -> *) a.
Algebra' (e : r) m a -> Algebra' r m a
weakenAlg Algebra' (ListenPrim o : Prims m) z x
Algebra (Prims (ListenLazyC o m)) z
alg)
    ) ((Listen o z a -> z a)
 -> Algebra' (Listen o : Tell o : Derivs m) z a)
-> (Listen o z a -> z a)
-> Algebra' (Listen o : Tell o : Derivs m) z a
forall a b. (a -> b) -> a -> b
$ \case
      Listen z a
m -> (Union (ListenPrim o : Prims m) z (o, a) -> z a
Algebra (Prims (ListenLazyC o m)) z
alg (Union (ListenPrim o : Prims m) z (o, a) -> z a)
-> (ListenPrim o z (o, a)
    -> Union (ListenPrim o : Prims m) z (o, a))
-> ListenPrim o z (o, a)
-> z a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ListenPrim o z (o, a) -> Union (ListenPrim o : Prims m) z (o, a)
forall (e :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *])
       (m :: * -> *) a.
Member e r =>
e m a -> Union r m a
inj) (ListenPrim o z (o, a) -> z a) -> ListenPrim o z (o, a) -> z a
forall a b. (a -> b) -> a -> b
$ z a -> ListenPrim o z (o, a)
forall (m :: * -> *) a o. m a -> ListenPrim o m (o, a)
ListenPrimListen z a
m
  {-# INLINEABLE reformulate #-}

newtype WriterLazyC o m a = WriterLazyC {
    WriterLazyC o m a -> WriterT o m a
_unWriterLazyC :: LW.WriterT o m a
  }
  deriving ( a -> WriterLazyC o m b -> WriterLazyC o m a
(a -> b) -> WriterLazyC o m a -> WriterLazyC o m b
(forall a b. (a -> b) -> WriterLazyC o m a -> WriterLazyC o m b)
-> (forall a b. a -> WriterLazyC o m b -> WriterLazyC o m a)
-> Functor (WriterLazyC o m)
forall a b. a -> WriterLazyC o m b -> WriterLazyC o m a
forall a b. (a -> b) -> WriterLazyC o m a -> WriterLazyC o m b
forall o (m :: * -> *) a b.
Functor m =>
a -> WriterLazyC o m b -> WriterLazyC o m a
forall o (m :: * -> *) a b.
Functor m =>
(a -> b) -> WriterLazyC o m a -> WriterLazyC o m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> WriterLazyC o m b -> WriterLazyC o m a
$c<$ :: forall o (m :: * -> *) a b.
Functor m =>
a -> WriterLazyC o m b -> WriterLazyC o m a
fmap :: (a -> b) -> WriterLazyC o m a -> WriterLazyC o m b
$cfmap :: forall o (m :: * -> *) a b.
Functor m =>
(a -> b) -> WriterLazyC o m a -> WriterLazyC o m b
Functor, Functor (WriterLazyC o m)
a -> WriterLazyC o m a
Functor (WriterLazyC o m)
-> (forall a. a -> WriterLazyC o m a)
-> (forall a b.
    WriterLazyC o m (a -> b) -> WriterLazyC o m a -> WriterLazyC o m b)
-> (forall a b c.
    (a -> b -> c)
    -> WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m c)
-> (forall a b.
    WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m b)
-> (forall a b.
    WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m a)
-> Applicative (WriterLazyC o m)
WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m b
WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m a
WriterLazyC o m (a -> b) -> WriterLazyC o m a -> WriterLazyC o m b
(a -> b -> c)
-> WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m c
forall a. a -> WriterLazyC o m a
forall a b.
WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m a
forall a b.
WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m b
forall a b.
WriterLazyC o m (a -> b) -> WriterLazyC o m a -> WriterLazyC o m b
forall a b c.
(a -> b -> c)
-> WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m c
forall o (m :: * -> *).
(Monoid o, Applicative m) =>
Functor (WriterLazyC o m)
forall o (m :: * -> *) a.
(Monoid o, Applicative m) =>
a -> WriterLazyC o m a
forall o (m :: * -> *) a b.
(Monoid o, Applicative m) =>
WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m a
forall o (m :: * -> *) a b.
(Monoid o, Applicative m) =>
WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m b
forall o (m :: * -> *) a b.
(Monoid o, Applicative m) =>
WriterLazyC o m (a -> b) -> WriterLazyC o m a -> WriterLazyC o m b
forall o (m :: * -> *) a b c.
(Monoid o, Applicative m) =>
(a -> b -> c)
-> WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
<* :: WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m a
$c<* :: forall o (m :: * -> *) a b.
(Monoid o, Applicative m) =>
WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m a
*> :: WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m b
$c*> :: forall o (m :: * -> *) a b.
(Monoid o, Applicative m) =>
WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m b
liftA2 :: (a -> b -> c)
-> WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m c
$cliftA2 :: forall o (m :: * -> *) a b c.
(Monoid o, Applicative m) =>
(a -> b -> c)
-> WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m c
<*> :: WriterLazyC o m (a -> b) -> WriterLazyC o m a -> WriterLazyC o m b
$c<*> :: forall o (m :: * -> *) a b.
(Monoid o, Applicative m) =>
WriterLazyC o m (a -> b) -> WriterLazyC o m a -> WriterLazyC o m b
pure :: a -> WriterLazyC o m a
$cpure :: forall o (m :: * -> *) a.
(Monoid o, Applicative m) =>
a -> WriterLazyC o m a
$cp1Applicative :: forall o (m :: * -> *).
(Monoid o, Applicative m) =>
Functor (WriterLazyC o m)
Applicative, Applicative (WriterLazyC o m)
a -> WriterLazyC o m a
Applicative (WriterLazyC o m)
-> (forall a b.
    WriterLazyC o m a -> (a -> WriterLazyC o m b) -> WriterLazyC o m b)
-> (forall a b.
    WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m b)
-> (forall a. a -> WriterLazyC o m a)
-> Monad (WriterLazyC o m)
WriterLazyC o m a -> (a -> WriterLazyC o m b) -> WriterLazyC o m b
WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m b
forall a. a -> WriterLazyC o m a
forall a b.
WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m b
forall a b.
WriterLazyC o m a -> (a -> WriterLazyC o m b) -> WriterLazyC o m b
forall o (m :: * -> *).
(Monoid o, Monad m) =>
Applicative (WriterLazyC o m)
forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
a -> WriterLazyC o m a
forall o (m :: * -> *) a b.
(Monoid o, Monad m) =>
WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m b
forall o (m :: * -> *) a b.
(Monoid o, Monad m) =>
WriterLazyC o m a -> (a -> WriterLazyC o m b) -> WriterLazyC o m b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> WriterLazyC o m a
$creturn :: forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
a -> WriterLazyC o m a
>> :: WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m b
$c>> :: forall o (m :: * -> *) a b.
(Monoid o, Monad m) =>
WriterLazyC o m a -> WriterLazyC o m b -> WriterLazyC o m b
>>= :: WriterLazyC o m a -> (a -> WriterLazyC o m b) -> WriterLazyC o m b
$c>>= :: forall o (m :: * -> *) a b.
(Monoid o, Monad m) =>
WriterLazyC o m a -> (a -> WriterLazyC o m b) -> WriterLazyC o m b
$cp1Monad :: forall o (m :: * -> *).
(Monoid o, Monad m) =>
Applicative (WriterLazyC o m)
Monad
           , Applicative (WriterLazyC o m)
WriterLazyC o m a
Applicative (WriterLazyC o m)
-> (forall a. WriterLazyC o m a)
-> (forall a.
    WriterLazyC o m a -> WriterLazyC o m a -> WriterLazyC o m a)
-> (forall a. WriterLazyC o m a -> WriterLazyC o m [a])
-> (forall a. WriterLazyC o m a -> WriterLazyC o m [a])
-> Alternative (WriterLazyC o m)
WriterLazyC o m a -> WriterLazyC o m a -> WriterLazyC o m a
WriterLazyC o m a -> WriterLazyC o m [a]
WriterLazyC o m a -> WriterLazyC o m [a]
forall a. WriterLazyC o m a
forall a. WriterLazyC o m a -> WriterLazyC o m [a]
forall a.
WriterLazyC o m a -> WriterLazyC o m a -> WriterLazyC o m a
forall o (m :: * -> *).
(Monoid o, Alternative m) =>
Applicative (WriterLazyC o m)
forall o (m :: * -> *) a.
(Monoid o, Alternative m) =>
WriterLazyC o m a
forall o (m :: * -> *) a.
(Monoid o, Alternative m) =>
WriterLazyC o m a -> WriterLazyC o m [a]
forall o (m :: * -> *) a.
(Monoid o, Alternative m) =>
WriterLazyC o m a -> WriterLazyC o m a -> WriterLazyC o m a
forall (f :: * -> *).
Applicative f
-> (forall a. f a)
-> (forall a. f a -> f a -> f a)
-> (forall a. f a -> f [a])
-> (forall a. f a -> f [a])
-> Alternative f
many :: WriterLazyC o m a -> WriterLazyC o m [a]
$cmany :: forall o (m :: * -> *) a.
(Monoid o, Alternative m) =>
WriterLazyC o m a -> WriterLazyC o m [a]
some :: WriterLazyC o m a -> WriterLazyC o m [a]
$csome :: forall o (m :: * -> *) a.
(Monoid o, Alternative m) =>
WriterLazyC o m a -> WriterLazyC o m [a]
<|> :: WriterLazyC o m a -> WriterLazyC o m a -> WriterLazyC o m a
$c<|> :: forall o (m :: * -> *) a.
(Monoid o, Alternative m) =>
WriterLazyC o m a -> WriterLazyC o m a -> WriterLazyC o m a
empty :: WriterLazyC o m a
$cempty :: forall o (m :: * -> *) a.
(Monoid o, Alternative m) =>
WriterLazyC o m a
$cp1Alternative :: forall o (m :: * -> *).
(Monoid o, Alternative m) =>
Applicative (WriterLazyC o m)
Alternative, Monad (WriterLazyC o m)
Alternative (WriterLazyC o m)
WriterLazyC o m a
Alternative (WriterLazyC o m)
-> Monad (WriterLazyC o m)
-> (forall a. WriterLazyC o m a)
-> (forall a.
    WriterLazyC o m a -> WriterLazyC o m a -> WriterLazyC o m a)
-> MonadPlus (WriterLazyC o m)
WriterLazyC o m a -> WriterLazyC o m a -> WriterLazyC o m a
forall a. WriterLazyC o m a
forall a.
WriterLazyC o m a -> WriterLazyC o m a -> WriterLazyC o m a
forall o (m :: * -> *).
(Monoid o, MonadPlus m) =>
Monad (WriterLazyC o m)
forall o (m :: * -> *).
(Monoid o, MonadPlus m) =>
Alternative (WriterLazyC o m)
forall o (m :: * -> *) a.
(Monoid o, MonadPlus m) =>
WriterLazyC o m a
forall o (m :: * -> *) a.
(Monoid o, MonadPlus m) =>
WriterLazyC o m a -> WriterLazyC o m a -> WriterLazyC o m a
forall (m :: * -> *).
Alternative m
-> Monad m
-> (forall a. m a)
-> (forall a. m a -> m a -> m a)
-> MonadPlus m
mplus :: WriterLazyC o m a -> WriterLazyC o m a -> WriterLazyC o m a
$cmplus :: forall o (m :: * -> *) a.
(Monoid o, MonadPlus m) =>
WriterLazyC o m a -> WriterLazyC o m a -> WriterLazyC o m a
mzero :: WriterLazyC o m a
$cmzero :: forall o (m :: * -> *) a.
(Monoid o, MonadPlus m) =>
WriterLazyC o m a
$cp2MonadPlus :: forall o (m :: * -> *).
(Monoid o, MonadPlus m) =>
Monad (WriterLazyC o m)
$cp1MonadPlus :: forall o (m :: * -> *).
(Monoid o, MonadPlus m) =>
Alternative (WriterLazyC o m)
MonadPlus
           , Monad (WriterLazyC o m)
e -> WriterLazyC o m a
Monad (WriterLazyC o m)
-> (forall e a. Exception e => e -> WriterLazyC o m a)
-> MonadThrow (WriterLazyC o m)
forall e a. Exception e => e -> WriterLazyC o m a
forall o (m :: * -> *).
(Monoid o, MonadThrow m) =>
Monad (WriterLazyC o m)
forall o (m :: * -> *) e a.
(Monoid o, MonadThrow m, Exception e) =>
e -> WriterLazyC o m a
forall (m :: * -> *).
Monad m -> (forall e a. Exception e => e -> m a) -> MonadThrow m
throwM :: e -> WriterLazyC o m a
$cthrowM :: forall o (m :: * -> *) e a.
(Monoid o, MonadThrow m, Exception e) =>
e -> WriterLazyC o m a
$cp1MonadThrow :: forall o (m :: * -> *).
(Monoid o, MonadThrow m) =>
Monad (WriterLazyC o m)
MonadThrow, MonadThrow (WriterLazyC o m)
MonadThrow (WriterLazyC o m)
-> (forall e a.
    Exception e =>
    WriterLazyC o m a -> (e -> WriterLazyC o m a) -> WriterLazyC o m a)
-> MonadCatch (WriterLazyC o m)
WriterLazyC o m a -> (e -> WriterLazyC o m a) -> WriterLazyC o m a
forall e a.
Exception e =>
WriterLazyC o m a -> (e -> WriterLazyC o m a) -> WriterLazyC o m a
forall o (m :: * -> *).
(Monoid o, MonadCatch m) =>
MonadThrow (WriterLazyC o m)
forall o (m :: * -> *) e a.
(Monoid o, MonadCatch m, Exception e) =>
WriterLazyC o m a -> (e -> WriterLazyC o m a) -> WriterLazyC o m a
forall (m :: * -> *).
MonadThrow m
-> (forall e a. Exception e => m a -> (e -> m a) -> m a)
-> MonadCatch m
catch :: WriterLazyC o m a -> (e -> WriterLazyC o m a) -> WriterLazyC o m a
$ccatch :: forall o (m :: * -> *) e a.
(Monoid o, MonadCatch m, Exception e) =>
WriterLazyC o m a -> (e -> WriterLazyC o m a) -> WriterLazyC o m a
$cp1MonadCatch :: forall o (m :: * -> *).
(Monoid o, MonadCatch m) =>
MonadThrow (WriterLazyC o m)
MonadCatch, MonadCatch (WriterLazyC o m)
MonadCatch (WriterLazyC o m)
-> (forall b.
    ((forall a. WriterLazyC o m a -> WriterLazyC o m a)
     -> WriterLazyC o m b)
    -> WriterLazyC o m b)
-> (forall b.
    ((forall a. WriterLazyC o m a -> WriterLazyC o m a)
     -> WriterLazyC o m b)
    -> WriterLazyC o m b)
-> (forall a b c.
    WriterLazyC o m a
    -> (a -> ExitCase b -> WriterLazyC o m c)
    -> (a -> WriterLazyC o m b)
    -> WriterLazyC o m (b, c))
-> MonadMask (WriterLazyC o m)
WriterLazyC o m a
-> (a -> ExitCase b -> WriterLazyC o m c)
-> (a -> WriterLazyC o m b)
-> WriterLazyC o m (b, c)
((forall a. WriterLazyC o m a -> WriterLazyC o m a)
 -> WriterLazyC o m b)
-> WriterLazyC o m b
((forall a. WriterLazyC o m a -> WriterLazyC o m a)
 -> WriterLazyC o m b)
-> WriterLazyC o m b
forall b.
((forall a. WriterLazyC o m a -> WriterLazyC o m a)
 -> WriterLazyC o m b)
-> WriterLazyC o m b
forall a b c.
WriterLazyC o m a
-> (a -> ExitCase b -> WriterLazyC o m c)
-> (a -> WriterLazyC o m b)
-> WriterLazyC o m (b, c)
forall o (m :: * -> *).
(Monoid o, MonadMask m) =>
MonadCatch (WriterLazyC o m)
forall o (m :: * -> *) b.
(Monoid o, MonadMask m) =>
((forall a. WriterLazyC o m a -> WriterLazyC o m a)
 -> WriterLazyC o m b)
-> WriterLazyC o m b
forall o (m :: * -> *) a b c.
(Monoid o, MonadMask m) =>
WriterLazyC o m a
-> (a -> ExitCase b -> WriterLazyC o m c)
-> (a -> WriterLazyC o m b)
-> WriterLazyC o m (b, c)
forall (m :: * -> *).
MonadCatch m
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall a b c.
    m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c))
-> MonadMask m
generalBracket :: WriterLazyC o m a
-> (a -> ExitCase b -> WriterLazyC o m c)
-> (a -> WriterLazyC o m b)
-> WriterLazyC o m (b, c)
$cgeneralBracket :: forall o (m :: * -> *) a b c.
(Monoid o, MonadMask m) =>
WriterLazyC o m a
-> (a -> ExitCase b -> WriterLazyC o m c)
-> (a -> WriterLazyC o m b)
-> WriterLazyC o m (b, c)
uninterruptibleMask :: ((forall a. WriterLazyC o m a -> WriterLazyC o m a)
 -> WriterLazyC o m b)
-> WriterLazyC o m b
$cuninterruptibleMask :: forall o (m :: * -> *) b.
(Monoid o, MonadMask m) =>
((forall a. WriterLazyC o m a -> WriterLazyC o m a)
 -> WriterLazyC o m b)
-> WriterLazyC o m b
mask :: ((forall a. WriterLazyC o m a -> WriterLazyC o m a)
 -> WriterLazyC o m b)
-> WriterLazyC o m b
$cmask :: forall o (m :: * -> *) b.
(Monoid o, MonadMask m) =>
((forall a. WriterLazyC o m a -> WriterLazyC o m a)
 -> WriterLazyC o m b)
-> WriterLazyC o m b
$cp1MonadMask :: forall o (m :: * -> *).
(Monoid o, MonadMask m) =>
MonadCatch (WriterLazyC o m)
MonadMask
           , Monad (WriterLazyC o m)
Monad (WriterLazyC o m)
-> (forall a. (a -> WriterLazyC o m a) -> WriterLazyC o m a)
-> MonadFix (WriterLazyC o m)
(a -> WriterLazyC o m a) -> WriterLazyC o m a
forall a. (a -> WriterLazyC o m a) -> WriterLazyC o m a
forall o (m :: * -> *).
(Monoid o, MonadFix m) =>
Monad (WriterLazyC o m)
forall o (m :: * -> *) a.
(Monoid o, MonadFix m) =>
(a -> WriterLazyC o m a) -> WriterLazyC o m a
forall (m :: * -> *).
Monad m -> (forall a. (a -> m a) -> m a) -> MonadFix m
mfix :: (a -> WriterLazyC o m a) -> WriterLazyC o m a
$cmfix :: forall o (m :: * -> *) a.
(Monoid o, MonadFix m) =>
(a -> WriterLazyC o m a) -> WriterLazyC o m a
$cp1MonadFix :: forall o (m :: * -> *).
(Monoid o, MonadFix m) =>
Monad (WriterLazyC o m)
MonadFix, Monad (WriterLazyC o m)
Monad (WriterLazyC o m)
-> (forall a. String -> WriterLazyC o m a)
-> MonadFail (WriterLazyC o m)
String -> WriterLazyC o m a
forall a. String -> WriterLazyC o m a
forall o (m :: * -> *).
(Monoid o, MonadFail m) =>
Monad (WriterLazyC o m)
forall o (m :: * -> *) a.
(Monoid o, MonadFail m) =>
String -> WriterLazyC o m a
forall (m :: * -> *).
Monad m -> (forall a. String -> m a) -> MonadFail m
fail :: String -> WriterLazyC o m a
$cfail :: forall o (m :: * -> *) a.
(Monoid o, MonadFail m) =>
String -> WriterLazyC o m a
$cp1MonadFail :: forall o (m :: * -> *).
(Monoid o, MonadFail m) =>
Monad (WriterLazyC o m)
MonadFail, Monad (WriterLazyC o m)
Monad (WriterLazyC o m)
-> (forall a. IO a -> WriterLazyC o m a)
-> MonadIO (WriterLazyC o m)
IO a -> WriterLazyC o m a
forall a. IO a -> WriterLazyC o m a
forall o (m :: * -> *).
(Monoid o, MonadIO m) =>
Monad (WriterLazyC o m)
forall o (m :: * -> *) a.
(Monoid o, MonadIO m) =>
IO a -> WriterLazyC o m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
liftIO :: IO a -> WriterLazyC o m a
$cliftIO :: forall o (m :: * -> *) a.
(Monoid o, MonadIO m) =>
IO a -> WriterLazyC o m a
$cp1MonadIO :: forall o (m :: * -> *).
(Monoid o, MonadIO m) =>
Monad (WriterLazyC o m)
MonadIO
           , MonadBase b, MonadBaseControl b
           )
  deriving (m a -> WriterLazyC o m a
(forall (m :: * -> *) a. Monad m => m a -> WriterLazyC o m a)
-> MonadTrans (WriterLazyC o)
forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
m a -> WriterLazyC o m a
forall (m :: * -> *) a. Monad m => m a -> WriterLazyC o m a
forall (t :: (* -> *) -> * -> *).
(forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
lift :: m a -> WriterLazyC o m a
$clift :: forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
m a -> WriterLazyC o m a
MonadTrans, MonadTrans (WriterLazyC o)
m (StT (WriterLazyC o) a) -> WriterLazyC o m a
MonadTrans (WriterLazyC o)
-> (forall (m :: * -> *) a.
    Monad m =>
    (Run (WriterLazyC o) -> m a) -> WriterLazyC o m a)
-> (forall (m :: * -> *) a.
    Monad m =>
    m (StT (WriterLazyC o) a) -> WriterLazyC o m a)
-> MonadTransControl (WriterLazyC o)
(Run (WriterLazyC o) -> m a) -> WriterLazyC o m a
forall o. Monoid o => MonadTrans (WriterLazyC o)
forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
m (StT (WriterLazyC o) a) -> WriterLazyC o m a
forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
(Run (WriterLazyC o) -> m a) -> WriterLazyC o m a
forall (m :: * -> *) a.
Monad m =>
m (StT (WriterLazyC o) a) -> WriterLazyC o m a
forall (m :: * -> *) a.
Monad m =>
(Run (WriterLazyC o) -> m a) -> WriterLazyC o m a
forall (t :: (* -> *) -> * -> *).
MonadTrans t
-> (forall (m :: * -> *) a. Monad m => (Run t -> m a) -> t m a)
-> (forall (m :: * -> *) a. Monad m => m (StT t a) -> t m a)
-> MonadTransControl t
restoreT :: m (StT (WriterLazyC o) a) -> WriterLazyC o m a
$crestoreT :: forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
m (StT (WriterLazyC o) a) -> WriterLazyC o m a
liftWith :: (Run (WriterLazyC o) -> m a) -> WriterLazyC o m a
$cliftWith :: forall o (m :: * -> *) a.
(Monoid o, Monad m) =>
(Run (WriterLazyC o) -> m a) -> WriterLazyC o m a
$cp1MonadTransControl :: forall o. Monoid o => MonadTrans (WriterLazyC o)
MonadTransControl)

instance ( Monoid o
         , Carrier m
         , Threads (LW.WriterT o) (Prims m)
         )
      => Carrier (WriterLazyC o m) where
  type Derivs (WriterLazyC o m) = Pass o ': Listen o ': Tell o ': Derivs m
  type Prims  (WriterLazyC o m) = WriterPrim o ': Prims m

  algPrims :: Algebra' (Prims (WriterLazyC o m)) (WriterLazyC o m) a
algPrims =
    Algebra' (ListenPrim o : Prims m) (WriterLazyC o m) a
-> (WriterLazyC o m (o -> o, a) -> WriterLazyC o m a)
-> Algebra' (WriterPrim o : Prims m) (WriterLazyC o m) a
forall o (p :: [(* -> *) -> * -> *]) (m :: * -> *) a.
Algebra' (ListenPrim o : p) m a
-> (m (o -> o, a) -> m a) -> Algebra' (WriterPrim o : p) m a
algListenPrimIntoWriterPrim (
      Algebra' (ListenPrim o : Prims m) (ListenLazyC o m) a
-> Algebra' (ListenPrim o : Prims m) (WriterLazyC o m) a
coerce (forall a.
Carrier (ListenLazyC o m) =>
Algebra' (Prims (ListenLazyC o m)) (ListenLazyC o m) a
forall (m :: * -> *) a. Carrier m => Algebra' (Prims m) m a
algPrims @(ListenLazyC o m))
    ) ((WriterLazyC o m (o -> o, a) -> WriterLazyC o m a)
 -> Algebra' (WriterPrim o : Prims m) (WriterLazyC o m) a)
-> (WriterLazyC o m (o -> o, a) -> WriterLazyC o m a)
-> Algebra' (WriterPrim o : Prims m) (WriterLazyC o m) a
forall a b. (a -> b) -> a -> b
$ \(WriterLazyC WriterT o m (o -> o, a)
m) -> WriterT o m a -> WriterLazyC o m a
forall o (m :: * -> *) a. WriterT o m a -> WriterLazyC o m a
WriterLazyC (WriterT o m a -> WriterLazyC o m a)
-> WriterT o m a -> WriterLazyC o m a
forall a b. (a -> b) -> a -> b
$ WriterT o m (a, o -> o) -> WriterT o m a
forall (m :: * -> *) w a.
Monad m =>
WriterT w m (a, w -> w) -> WriterT w m a
LW.pass ((o -> o, a) -> (a, o -> o)
forall a b. (a, b) -> (b, a)
swap ((o -> o, a) -> (a, o -> o))
-> WriterT o m (o -> o, a) -> WriterT o m (a, o -> o)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> WriterT o m (o -> o, a)
m)
  {-# INLINEABLE algPrims #-}

  reformulate :: Reformulation'
  (Derivs (WriterLazyC o m))
  (Prims (WriterLazyC o m))
  (WriterLazyC o m)
  z
  a
reformulate forall x. WriterLazyC o m x -> z x
n Algebra (Prims (WriterLazyC o m)) z
alg =
    Algebra' (Listen o : Tell o : Derivs m) z a
-> (Pass o z a -> z a)
-> Algebra' (Pass o : Listen o : Tell o : Derivs m) z a
forall (e :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *])
       (m :: * -> *) a.
RepresentationalEff e =>
Algebra' r m a -> (e m a -> m a) -> Algebra' (e : r) m a
powerAlg (
    Algebra' (Tell o : Derivs m) z a
-> (Listen o z a -> z a)
-> Algebra' (Listen o : Tell o : Derivs m) z a
forall (e :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *])
       (m :: * -> *) a.
RepresentationalEff e =>
Algebra' r m a -> (e m a -> m a) -> Algebra' (e : r) m a
powerAlg (
      Reformulation' (Tell o : Derivs m) (Prims m) (TellLazyC o m) z a
-> Reformulation'
     (Tell o : Derivs m) (Prims m) (WriterLazyC o m) z a
forall (m :: * -> *) (n :: * -> *) (r :: [(* -> *) -> * -> *])
       (p :: [(* -> *) -> * -> *]) (z :: * -> *) a.
Coercible m n =>
Reformulation' r p m z a -> Reformulation' r p n z a
coerceReform (forall (z :: * -> *) a.
(Carrier (TellLazyC o m), Monad z) =>
Reformulation'
  (Derivs (TellLazyC o m))
  (Prims (TellLazyC o m))
  (TellLazyC o m)
  z
  a
forall (m :: * -> *) (z :: * -> *) a.
(Carrier m, Monad z) =>
Reformulation' (Derivs m) (Prims m) m z a
reformulate @(TellLazyC o m)) forall x. WriterLazyC o m x -> z x
n (Algebra' (WriterPrim o : Prims m) z x -> Algebra' (Prims m) z x
forall (e :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *])
       (m :: * -> *) a.
Algebra' (e : r) m a -> Algebra' r m a
weakenAlg Algebra' (WriterPrim o : Prims m) z x
Algebra (Prims (WriterLazyC o m)) z
alg)
    ) ((Listen o z a -> z a)
 -> Algebra' (Listen o : Tell o : Derivs m) z a)
-> (Listen o z a -> z a)
-> Algebra' (Listen o : Tell o : Derivs m) z a
forall a b. (a -> b) -> a -> b
$ \case
      Listen z a
m -> (Union (WriterPrim o : Prims m) z (o, a) -> z a
Algebra (Prims (WriterLazyC o m)) z
alg (Union (WriterPrim o : Prims m) z (o, a) -> z a)
-> (WriterPrim o z (o, a)
    -> Union (WriterPrim o : Prims m) z (o, a))
-> WriterPrim o z (o, a)
-> z a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WriterPrim o z (o, a) -> Union (WriterPrim o : Prims m) z (o, a)
forall (e :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *])
       (m :: * -> *) a.
Member e r =>
e m a -> Union r m a
inj) (WriterPrim o z (o, a) -> z a) -> WriterPrim o z (o, a) -> z a
forall a b. (a -> b) -> a -> b
$ z a -> WriterPrim o z (o, a)
forall (m :: * -> *) a o. m a -> WriterPrim o m (o, a)
WriterPrimListen z a
m
    ) ((Pass o z a -> z a)
 -> Algebra' (Pass o : Listen o : Tell o : Derivs m) z a)
-> (Pass o z a -> z a)
-> Algebra' (Pass o : Listen o : Tell o : Derivs m) z a
forall a b. (a -> b) -> a -> b
$ \case
      Pass z (o -> o, a)
m -> (Union (WriterPrim o : Prims m) z a -> z a
Algebra (Prims (WriterLazyC o m)) z
alg (Union (WriterPrim o : Prims m) z a -> z a)
-> (WriterPrim o z a -> Union (WriterPrim o : Prims m) z a)
-> WriterPrim o z a
-> z a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WriterPrim o z a -> Union (WriterPrim o : Prims m) z a
forall (e :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *])
       (m :: * -> *) a.
Member e r =>
e m a -> Union r m a
inj) (WriterPrim o z a -> z a) -> WriterPrim o z a -> z a
forall a b. (a -> b) -> a -> b
$ z (o -> o, a) -> WriterPrim o z a
forall (m :: * -> *) o a. m (o -> o, a) -> WriterPrim o m a
WriterPrimPass z (o -> o, a)
m
  {-# INLINEABLE reformulate #-}

-- | 'WriterThreads' accepts the following primitive effects:
--
-- * 'Control.Effect.Regional.Regional' @s@
-- * 'Control.Effect.Optional.Optional' @s@ (when @s@ is a functor)
-- * 'Control.Effect.BaseControl.BaseControl' @b@
-- * 'Control.Effect.Type.ListenPrim.ListenPrim' @o@ (when @o@ is a 'Monoid')
-- * 'Control.Effect.Type.WriterPrim.WriterPrim' @o@ (when @o@ is a 'Monoid')
-- * 'Control.Effect.Type.ReaderPrim.ReaderPrim' @i@
-- * 'Control.Effect.Mask.Mask'
-- * 'Control.Effect.Bracket.Bracket'
-- * 'Control.Effect.Fix.Fix'
-- * 'Control.Effect.NonDet.Split'
class    ( forall o. Monoid o => Threads (WriterT o) p
         ) => WriterThreads p
instance ( forall o. Monoid o => Threads (WriterT o) p
         ) => WriterThreads p

-- | 'WriterLazyThreads' accepts the following primitive effects:
--
-- * 'Control.Effect.Regional.Regional' @s@
-- * 'Control.Effect.Optional.Optional' @s@ (when @s@ is a functor)
-- * 'Control.Effect.BaseControl.BaseControl' @b@
-- * 'Control.Effect.Type.ListenPrim.ListenPrim' @o@ (when @o@ is a 'Monoid')
-- * 'Control.Effect.Type.WriterPrim.WriterPrim' @o@ (when @o@ is a 'Monoid')
-- * 'Control.Effect.Type.ReaderPrim.ReaderPrim' @i@
-- * 'Control.Effect.Mask.Mask'
-- * 'Control.Effect.Bracket.Bracket'
-- * 'Control.Effect.Fix.Fix'
-- * 'Control.Effect.NonDet.Split'
class    ( forall o. Monoid o => Threads (LW.WriterT o) p
         ) => WriterLazyThreads p
instance ( forall o. Monoid o => Threads (LW.WriterT o) p
         ) => WriterLazyThreads p