fused-effects-1.1.2.2: A fast, flexible, fused effect system.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Carrier.Accum.IORef

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 add. The Seq or DList monoids may be a superior choice. This carrier also uses an IORef to store its accumulator, which allows it a MonadUnliftIO instance, but precludes backtracking when run in conjunction with NonDet.

Since: 1.1.2.0

Synopsis

Accum carrier

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

Run an Accum effect with a Semigroup-based log.

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 :: MonadIO m => w -> AccumC w m a -> m w Source #

Run a Accum effect with a Semigroup-based log, producing the final log and discarding the result value.

execAccum w = fmap fst . runAccum w

Since: 1.1.2.0

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

Run a Accum effect with a Semigroup-based 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 (ReaderC (IORef w) m a) 

Instances

Instances details
MonadTrans (AccumC w) Source # 
Instance details

Defined in Control.Carrier.Accum.IORef

Methods

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

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

Defined in Control.Carrier.Accum.IORef

Methods

fail :: String -> AccumC w m a #

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

Defined in Control.Carrier.Accum.IORef

Methods

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

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

Defined in Control.Carrier.Accum.IORef

Methods

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

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

Defined in Control.Carrier.Accum.IORef

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] #

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

Defined in Control.Carrier.Accum.IORef

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 #

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

Defined in Control.Carrier.Accum.IORef

Methods

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

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

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

Defined in Control.Carrier.Accum.IORef

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 #

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

Defined in Control.Carrier.Accum.IORef

Methods

mzero :: AccumC w m a #

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

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

Defined in Control.Carrier.Accum.IORef

Methods

withRunInIO :: ((forall a. AccumC w m a -> IO a) -> IO b) -> AccumC w m b #

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

Defined in Control.Carrier.Accum.IORef

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