| Safe Haskell | None |
|---|
Control.Monad.Operational
Description
A reconstruction of the operational package in terms of the
FreeT monad transformer.
This module is meant to be a drop-in replacement for its
counterpart in the operational package. Some of the
implementation choices reflect that:
-
andPrograminstrare type synonyms forProgramViewinstrandProgramTinstr m, just as inProgramViewTinstr moperational. If you don't care for that, Control.Monad.Operational.Simple implements them directly in terms ofFree.
The ProgramT and ProgramViewT types and operations are
reexported from Control.Monad.Trans.Operational.
- module Control.Operational.Class
- module Control.Monad.Trans.Operational
- type Program instr = ProgramT instr Identity
- toFree :: Program instr a -> Free (Coyoneda instr) a
- fromProgram :: (Operational instr m, Functor m, Monad m) => Program instr a -> m a
- liftProgram :: Monad m => Program instr a -> ProgramT instr m a
- interpret :: forall m instr a. (Functor m, Monad m) => (forall x. instr x -> m x) -> Program instr a -> m a
- interpretWithMonad :: Monad m => (forall x. instr x -> m x) -> Program instr a -> m a
- type ProgramView instr = ProgramViewT instr Identity
- view :: Program instr a -> ProgramView instr a
Documentation
module Control.Operational.Class
type Program instr = ProgramT instr IdentitySource
Drop-in replacement for operational's type synonym.
fromProgram :: (Operational instr m, Functor m, Monad m) => Program instr a -> m aSource
Lift a Program into any Operational type at least as strong
as Monad.
liftProgram :: Monad m => Program instr a -> ProgramT instr m aSource
Lift a Program into a ProgramT. Really the same as
fromProgram, but with a more restricted type; this function is a
drop-in replacement for the eponymous function in operational.
interpret :: forall m instr a. (Functor m, Monad m) => (forall x. instr x -> m x) -> Program instr a -> m aSource
Interpret a Program by interpreting each instruction as a
monadic action. Unlike interpretWithMonad, this soes not use
view nor ProgramView.
This function is not a drop-in replacement for interpretWithMonad
because it has an extra Functor m constraint.
interpretWithMonad :: Monad m => (forall x. instr x -> m x) -> Program instr a -> m aSource
type ProgramView instr = ProgramViewT instr IdentitySource
Drop-in replacement for operational's eponymous type synonym.
view :: Program instr a -> ProgramView instr aSource
Drop-in replacement for operational's function.