Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class Monad m => MonadCodify cmd m | m -> cmd where
- codifies' :: MonadCodify cmd m => m () -> m [cmd]
- codify :: (AsFacet [cmd] cmd, MonadCodify cmd m) => (a -> m ()) -> m (a -> cmd)
- codify' :: (AsFacet [cmd] cmd, MonadCodify cmd m) => m () -> m cmd
- type MonadCommand cmd m = (MonadState (DList cmd) m, MonadDelegate () m, MonadCodify cmd m, AsFacet [cmd] cmd)
- command :: AsFacet c cmd => c -> cmd
- command' :: AsFacet (c cmd) cmd => c cmd -> cmd
- command_ :: AsFacet [cmd] cmd => () -> cmd
- commands :: AsFacet [cmd] cmd => [cmd] -> cmd
- instruct :: MonadState (DList cmd) m => cmd -> m ()
- instructs :: MonadState (DList cmd) m => [cmd] -> m ()
- exec :: (MonadState (DList cmd) m, AsFacet c cmd) => c -> m ()
- exec' :: (MonadState (DList cmd) m, AsFacet (c cmd) cmd) => c cmd -> m ()
- exec_ :: (Functor c, MonadState (DList cmd) m, AsFacet [cmd] cmd, AsFacet (c cmd) cmd) => c () -> m ()
- eval :: (MonadCommand cmd m, AsFacet [cmd] cmd, AsFacet c cmd) => ((a -> cmd) -> c) -> m a
- eval' :: (MonadCommand cmd m, AsFacet [cmd] cmd, AsFacet (c cmd) cmd) => ((a -> cmd) -> c cmd) -> m a
- sequentially :: MonadCont m => m a -> m a
- dispatch :: (AsFacet (c cmd) cmd, MonadCommand cmd m, Functor c) => c a -> m a
- dispatch_ :: (AsFacet (c cmd) cmd, AsFacet [cmd] cmd, MonadState (DList cmd) m, Functor c) => c () -> m ()
- concurringly :: (MonadCommand cmd m, AsConcur cmd) => Concur cmd a -> m a
- concurringly_ :: (MonadState (DList cmd) m, AsConcur cmd) => Concur cmd () -> m ()
- type AsConcur cmd = (AsFacet [cmd] cmd, AsFacet (Concur cmd cmd) cmd)
- newtype Concur cmd a = Concur {}
- data NewEmptyMVar a
- unNewEmptyMVar :: NewEmptyMVar a -> IO a
Documentation
class Monad m => MonadCodify cmd m | m -> cmd where Source #
Converts a handler that result in monad transformer stack with a State
of list of commands
to a handler that result in a list of commands, using the current monad context,
by running the State of comands with mempty like Writer.
Instances
AsConcur cmd => MonadCodify cmd (Concur cmd) Source # | |
MonadCodify cmd m => MonadCodify cmd (MaybeT m) Source # | Passthrough instance, ignoring that the handler result might be Nothing. |
MonadCodify cmd (State (DList cmd)) Source # | Instance that does real work by running the |
MonadCodify cmd (State (DList cmd)) Source # | Instance that does real work by running the State of commands with mempty. |
(MonadDelegate () m, MonadCodify cmd m) => MonadCodify cmd (ExceptT e m) Source # | Passthrough instance which requires the inner monad to be a |
MonadCodify cmd m => MonadCodify cmd (IdentityT m) Source # | Passthrough instance |
MonadCodify cmd m => MonadCodify cmd (ReaderT r m) Source # | Passthrough instance, using the Reader context |
MonadCodify cmd m => MonadCodify cmd (ContT () m) Source # | Passthrough instance |
codifies' :: MonadCodify cmd m => m () -> m [cmd] Source #
Variation of codifies
to transform the monad stack instead of a handler.
codify :: (AsFacet [cmd] cmd, MonadCodify cmd m) => (a -> m ()) -> m (a -> cmd) Source #
Variation of codifies
to output a handler that result in a single command
codify' :: (AsFacet [cmd] cmd, MonadCodify cmd m) => m () -> m cmd Source #
Variation of codify
to transform the monad stack instead of a handler.
type MonadCommand cmd m = (MonadState (DList cmd) m, MonadDelegate () m, MonadCodify cmd m, AsFacet [cmd] cmd) Source #
command :: AsFacet c cmd => c -> cmd Source #
convert a request type to a command type.
This is used for commands that doesn't have a continuation.
Ie. commands that doesn't "returns" a value from running an effect.
Use command'
for commands that require a continuation ("returns" a value).
command' :: AsFacet (c cmd) cmd => c cmd -> cmd Source #
A variation of command
for commands with a type variable cmd
,
which is usually commands that are containers of command,
or commands that require a continuation
Eg. commands that "returns" a value from running an effect.
command_ :: AsFacet [cmd] cmd => () -> cmd Source #
This helps allow executors of commands of a results only need to execute the type c cmd
,
ie, when the command result in the next cmd
.
This function is useful to fmap a command with a result of unit
to to a command with a result cmd
type.
commands :: AsFacet [cmd] cmd => [cmd] -> cmd Source #
Convert a list of commands to a command. This implementation avoids nesting for lists of a single command.
instruct :: MonadState (DList cmd) m => cmd -> m () Source #
Add a command to the list of commands for this MonadState. I basically want a Writer monad, but I'm using a State monad because but I also want to use it inside a ContT which only has an instance of MonadState.
instructs :: MonadState (DList cmd) m => [cmd] -> m () Source #
Adds a list of commands to the list of commands for this MonadState.
exec_ :: (Functor c, MonadState (DList cmd) m, AsFacet [cmd] cmd, AsFacet (c cmd) cmd) => c () -> m () Source #
eval' :: (MonadCommand cmd m, AsFacet [cmd] cmd, AsFacet (c cmd) cmd) => ((a -> cmd) -> c cmd) -> m a Source #
sequentially :: MonadCont m => m a -> m a Source #
Adds a MonadCont
constraint. It is redundant but rules out
using Concur
at the bottom of the transformer stack.
sequentially
is used for operations that MUST run sequentially, not concurrently.
Eg. when the overhead of using Concur
MVar
is not worth it, or
when data dependencies are not explicitly specified by monadic binds,
Eg. A command to update mutable variable must exact before
a command that reads from the mutable variable.
In this case, the reference to the variable doesn't change, so the
data dependency is not explicit.
dispatch :: (AsFacet (c cmd) cmd, MonadCommand cmd m, Functor c) => c a -> m a Source #
Retrieves the result of a functor command.
dispatch_ :: (AsFacet (c cmd) cmd, AsFacet [cmd] cmd, MonadState (DList cmd) m, Functor c) => c () -> m () Source #
Retrieves the result of a functor command.
A simpler variation of dispatch
that only requires a MonadState (DL.DList cmd) m
concurringly :: (MonadCommand cmd m, AsConcur cmd) => Concur cmd a -> m a Source #
concurringly_ :: (MonadState (DList cmd) m, AsConcur cmd) => Concur cmd () -> m () Source #
This is a monad morphism that can be used to hoist
transformer stacks on Concur cmd ()
A simpler variation of concurringly
that only requires a MonadState (DL.DList cmd) m
This monad is intended to be used with ApplicativeDo
to allow do notation
for composing commands that can be run concurrently.
The Applicative
instance can merge multiple commands into the internal state of DList c
.
The Monad
instance creates a ConcurCmd
command before continuing the bind.
Instances
AsConcur cmd => MonadDelegate () (Concur cmd) Source # | This instance makes usages of |
AsConcur cmd => MonadCodify cmd (Concur cmd) Source # | |
AsConcur cmd => Monad (Concur cmd) Source # | |
Functor (Concur cmd) Source # | |
Applicative (Concur cmd) Source # | Applicative instand allows building up list of commands without blocking |
AsConcur cmd => MonadState (DList cmd) (Concur cmd) Source # | |
Show (Concur cmd a) Source # | |
Generic (Concur cmd a) Source # | |
type Rep (Concur cmd a) Source # | |
Defined in Glazier.Command |
data NewEmptyMVar a Source #
NB. Don't export NewEmptyMVar constructor to guarantee
that that it only contains non-blocking newEmptyMVar
IO.
Instances
Monad NewEmptyMVar Source # | |
Defined in Glazier.Command (>>=) :: NewEmptyMVar a -> (a -> NewEmptyMVar b) -> NewEmptyMVar b # (>>) :: NewEmptyMVar a -> NewEmptyMVar b -> NewEmptyMVar b # return :: a -> NewEmptyMVar a # fail :: String -> NewEmptyMVar a # | |
Functor NewEmptyMVar Source # | |
Defined in Glazier.Command fmap :: (a -> b) -> NewEmptyMVar a -> NewEmptyMVar b # (<$) :: a -> NewEmptyMVar b -> NewEmptyMVar a # | |
Applicative NewEmptyMVar Source # | |
Defined in Glazier.Command pure :: a -> NewEmptyMVar a # (<*>) :: NewEmptyMVar (a -> b) -> NewEmptyMVar a -> NewEmptyMVar b # liftA2 :: (a -> b -> c) -> NewEmptyMVar a -> NewEmptyMVar b -> NewEmptyMVar c # (*>) :: NewEmptyMVar a -> NewEmptyMVar b -> NewEmptyMVar b # (<*) :: NewEmptyMVar a -> NewEmptyMVar b -> NewEmptyMVar a # |
unNewEmptyMVar :: NewEmptyMVar a -> IO a Source #