Control-Monad-MultiPass-0.1.0.0: A Library for Writing Multi-Pass Algorithms.

Safe HaskellSafe

Control.Monad.MultiPass.Instrument.Monoid2

Description

The Monoid2 instrument is used to accumulate a global value during the first pass. During the second pass, the global value can be read but not written. The value must be an instance of the Monoid class. The names of the methods, tell and listen, are taken from the MonadWriter class. If this causes a naming conflict, then this module should be imported qualified. For example:

 import qualified Control.Monad.MultiPass.Instrument.Monoid2 as M

Synopsis

Documentation

data Monoid2 a r w p1 p2 tc Source

Abstract datatype for the instrument.

Instances

Instrument tc () () (Monoid2 a r w Off Off tc) 
Monoid a => Instrument tc (MonoidTC a) () (Monoid2 a r w On Off tc) 

tellSource

Arguments

:: (Monoid a, Monad p1, Monad p2) 
=> Monoid2 a r w p1 p2 tc

Instrument

-> p1 a

Value to add

-> MultiPass r w tc () 

Add a value to the global value, during the first pass.

listenSource

Arguments

:: (Monoid a, Monad p1, Monad p2) 
=> Monoid2 a r w p1 p2 tc

Instrument

-> MultiPass r w tc (p2 a)

Global value

Read the global value, during the second pass.

tellPrologueSource

Arguments

:: (Monoid a, Monad p1, Monad p2) 
=> Monoid2 a r w p1 p2 tc

Instrument

-> p1 a

Value to add

-> MultiPassPrologue r w tc () 

Add a value to the global value, during the prologue of the first pass.

listenEpilogueSource

Arguments

:: (Monoid a, Monad p1, Monad p2) 
=> Monoid2 a r w p1 p2 tc

Instrument

-> MultiPassEpilogue r w tc (p1 a)

Global value

Read the global value, during the epilogue of the first pass.