Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Fresh m k
- fresh :: (Member Fresh sig, Carrier sig m) => m Int
- resetFresh :: (Member Fresh sig, Carrier sig m) => m a -> m a
- runFresh :: Functor m => FreshC m a -> m a
- newtype FreshC m a = FreshC {}
- class (HFunctor sig, Monad m) => Carrier sig m | m -> sig
- class Member (sub :: (* -> *) -> * -> *) sup
- run :: PureC a -> a
Fresh effect
fresh :: (Member Fresh sig, Carrier sig m) => m Int Source #
Produce a fresh (i.e. unique) Int
.
run (runFresh (replicateM n fresh)) === nub (run (runFresh (replicateM n fresh)))
resetFresh :: (Member Fresh sig, Carrier sig m) => m a -> m a Source #
Reset the fresh counter after running a computation.
run (runFresh (resetFresh (replicateM m fresh) *> replicateM n fresh)) === run (runFresh (replicateM n fresh))
Fresh carrier
runFresh :: Functor m => FreshC m a -> m a Source #
Run a Fresh
effect counting up from 0.
run (runFresh (replicateM n fresh)) === [0..pred n]
run (runFresh (replicateM n fresh *> pure b)) === b
Instances
MonadTrans FreshC Source # | |
Defined in Control.Effect.Fresh | |
Monad m => Monad (FreshC m) Source # | |
Functor m => Functor (FreshC m) Source # | |
MonadFix m => MonadFix (FreshC m) Source # | |
Defined in Control.Effect.Fresh | |
MonadFail m => MonadFail (FreshC m) Source # | |
Defined in Control.Effect.Fresh | |
Monad m => Applicative (FreshC m) Source # | |
MonadIO m => MonadIO (FreshC m) Source # | |
Defined in Control.Effect.Fresh | |
(Alternative m, Monad m) => Alternative (FreshC m) Source # | |
(Alternative m, Monad m) => MonadPlus (FreshC m) Source # | |
(Carrier sig m, Effect sig) => Carrier (Fresh :+: sig) (FreshC m) Source # | |
Re-exports
class (HFunctor sig, Monad m) => Carrier sig m | m -> sig Source #
The class of carriers (results) for algebras (effect handlers) over signatures (effects), whose actions are given by the eff
method.