fused-effects-1.1.2.0: A fast, flexible, fused effect system.
Safe HaskellNone
LanguageHaskell2010

Control.Carrier.Accum.Strict

Description

A carrier for Accum effects. This carrier performs its append operations strictly and thus avoids the space leaks inherent in lazy writer monads. These appends are left-associative; as such, [] is a poor choice of monoid for computations that entail many calls to tell. The Seq or DList monoids may be a superior choice.

  • - | @since 1.1.2.0
Synopsis

Accum carrier

runAccum :: w -> AccumC w m a -> m (w, a) Source #

Run an Accum effect with a Monoidal log, applying a continuation to the final log and result.

runAccum w0 (pure a) = pure (w0, a)
runAccum w0 (add w) = pure (w0 <> w, ())
runAccum w0 (add w >> look) = pure (w0 <> w, w0 <> w)

Since: 1.1.2.0

execAccum :: Functor m => w -> AccumC w m a -> m w Source #

Run a Accum effect (typically with a Monoidal log), producing the final log and discarding the result value.

execAccum w = fmap fst . runAccum w

Since: 1.1.2.0

evalAccum :: Functor m => w -> AccumC w m a -> m a Source #

Run a Accum effect (typically with a Monoidal log), producing the result value and discarding the final log.

evalAccum w = fmap snd . runAccum w

Since: 1.1.2.0

newtype AccumC w m a Source #

Since: 1.1.2.0

Constructors

AccumC (w -> m (w, a)) 

Instances

Instances details
Monoid w => MonadTrans (AccumC w) Source # 
Instance details

Defined in Control.Carrier.Accum.Strict

Methods

lift :: Monad m => m a -> AccumC w m a #

(Monad m, Monoid w) => Monad (AccumC w m) Source # 
Instance details

Defined in Control.Carrier.Accum.Strict

Methods

(>>=) :: AccumC w m a -> (a -> AccumC w m b) -> AccumC w m b #

(>>) :: AccumC w m a -> AccumC w m b -> AccumC w m b #

return :: a -> AccumC w m a #

Functor m => Functor (AccumC w m) Source # 
Instance details

Defined in Control.Carrier.Accum.Strict

Methods

fmap :: (a -> b) -> AccumC w m a -> AccumC w m b #

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

(MonadFix m, Monoid w) => MonadFix (AccumC w m) Source # 
Instance details

Defined in Control.Carrier.Accum.Strict

Methods

mfix :: (a -> AccumC w m a) -> AccumC w m a #

(MonadFail m, Monoid w) => MonadFail (AccumC w m) Source # 
Instance details

Defined in Control.Carrier.Accum.Strict

Methods

fail :: String -> AccumC w m a #

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

Defined in Control.Carrier.Accum.Strict

Methods

pure :: a -> AccumC w m a #

(<*>) :: AccumC w m (a -> b) -> AccumC w m a -> AccumC w m b #

liftA2 :: (a -> b -> c) -> AccumC w m a -> AccumC w m b -> AccumC w m c #

(*>) :: AccumC w m a -> AccumC w m b -> AccumC w m b #

(<*) :: AccumC w m a -> AccumC w m b -> AccumC w m a #

(MonadIO m, Monoid w) => MonadIO (AccumC w m) Source # 
Instance details

Defined in Control.Carrier.Accum.Strict

Methods

liftIO :: IO a -> AccumC w m a #

(Alternative m, Monad m, Monoid w) => Alternative (AccumC w m) Source # 
Instance details

Defined in Control.Carrier.Accum.Strict

Methods

empty :: AccumC w m a #

(<|>) :: AccumC w m a -> AccumC w m a -> AccumC w m a #

some :: AccumC w m a -> AccumC w m [a] #

many :: AccumC w m a -> AccumC w m [a] #

(MonadPlus m, Monoid w) => MonadPlus (AccumC w m) Source # 
Instance details

Defined in Control.Carrier.Accum.Strict

Methods

mzero :: AccumC w m a #

mplus :: AccumC w m a -> AccumC w m a -> AccumC w m a #

(Algebra sig m, Monoid w) => Algebra (Accum w :+: sig) (AccumC w m) Source # 
Instance details

Defined in Control.Carrier.Accum.Strict

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (AccumC w m) -> (Accum w :+: sig) n a -> ctx () -> AccumC w m (ctx a) Source #

Accum effect