free-operational-0.3.0.0: Operational Applicative, Alternative, Monad and MonadPlus, built with free types.

Safe HaskellNone

Control.Monad.Operational.Simple

Description

A simpler, non-transformer version of this package's Control.Monad.Operational's Program type, using Free directly.

Synopsis

Documentation

newtype Program instr a Source

Constructors

Program 

Fields

toFree :: Free (Yoneda instr) a

Intepret the program as a Free monad.

Instances

Operational instr (Program instr) 
Monad (Program instr) 
Functor (Program instr) 
Applicative (Program instr) 

interpret :: forall m instr a. (Functor m, Monad m) => (forall x. instr x -> m x) -> Program instr a -> m aSource

Interpret a Program by translating each instruction to a Monad action. Does not use view.

fromProgram :: (Operational instr m, Functor m, Monad m) => Program instr a -> m aSource

Lift a Program to any Operational instance at least as powerful as Monad.

data ProgramView instr a whereSource

Constructors

Return :: a -> ProgramView instr a 
:>>= :: instr a -> (a -> Program instr b) -> ProgramView instr b 

view :: Program instr a -> ProgramView instr aSource