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

Safe HaskellSafe

Control.Monad.MultiPass.Instrument.EmitST2ArrayFxp

Description

The EmitST2ArrayFxp instrument has an identical interface to EmitST2Array. The only difference is that EmitST2ArrayFxp includes support for back-tracking. The emitList method of EmitST2ArrayFxp permits the list argument to be longer than the lower bound which was specified during the first pass. If it is then the algorithm will back-track to the beginning of the second pass and iterate until a fixed point has been reached.

Synopsis

Documentation

data EmitST2ArrayFxp i a r w p1 p2 p3 tc Source

Abstract datatype for the instrument.

Instances

Instrument tc () () (EmitST2ArrayFxp i a r w Off Off Off tc) 

setBaseIndexSource

Arguments

:: (Ix i, Num i, Monad p1, Monad p2, Monad p3) 
=> EmitST2ArrayFxp i a r w p1 p2 p3 tc

Instrument

-> p2 i

Base index

-> MultiPassPrologue r w tc () 

Initialise the base index of the output array. This method is optional: if it is not called then the base index defaults to zero.

emitSource

Arguments

:: (Ix i, Num i, Monad p1, Monad p2, Monad p3) 
=> EmitST2ArrayFxp i a r w p1 p2 p3 tc

Instrument

-> p3 a

Value to emit

-> MultiPass r w tc () 

Write one element to the output array.

emitListSource

Arguments

:: (Ix i, Num i, Monad p1, Monad p2, Monad p3) 
=> EmitST2ArrayFxp i a r w p1 p2 p3 tc

Instrument

-> p1 Int

Length of the list

-> p3 [a]

List of elements to emit

-> MultiPass r w tc () 

Write a list of elements to the output array. The instrument uses back-tracking to iterate until the length of the list has been determined. It is the client's responsibility to ensure that any operations which depend on the length of the list are monotonic so that a fixed point will be found. The first argument is used to supply a minimum length for the list (zero is always a valid input). It can be used to shorten the time to convergence when a good lower bound is known.

getIndexSource

Arguments

:: (Ix i, Num i, Monad p1, Monad p2, Monad p3) 
=> EmitST2ArrayFxp i a r w p1 p2 p3 tc

Instrument

-> MultiPass r w' tc (p2 i)

Current index

Get the current index in the output array.

getResultSource

Arguments

:: (Ix i, Num i, Monad p1, Monad p2, Monad p3) 
=> EmitST2ArrayFxp i a r w p1 p2 p3 tc

Instrument

-> MultiPassEpilogue r w tc (p3 (ST2Array r w i a))

Output array

Get the output array.