free-operational-0.5.0.0: Operational Applicative, Alternative, Monad and MonadPlus from free types.

Safe HaskellNone

Control.MonadPlus.Operational

Description

operational-style programs for MonadPlus. See the documentation for Control.Applicative.Operational and Control.Monad.Operational for guidance on how to use this module.

Documentation

newtype ProgramP instr a Source

Constructors

ProgramP 

Fields

toFree :: Free (Coyoneda instr) a

Interpret the program as a free MonadPlus.

Instances

Operational instr (ProgramP instr) 
Monad (ProgramP instr) 
Functor (ProgramP instr) 
MonadPlus (ProgramP instr) 
Applicative (ProgramP instr) 
Alternative (ProgramP instr) 

interpretP :: forall m instr a. (Functor m, MonadPlus m) => (forall x. instr x -> m x) -> ProgramP instr a -> m aSource

fromProgramP :: (Operational instr m, Functor m, MonadPlus m) => ProgramP instr a -> m aSource

data ProgramViewP instr a whereSource

Constructors

Return :: a -> ProgramViewP instr a 
:>>= :: instr a -> (a -> ProgramP instr b) -> ProgramViewP instr b 
MPlus :: [ProgramViewP instr a] -> ProgramViewP instr a 

view :: ProgramP instr a -> ProgramViewP instr aSource