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

Safe HaskellSafe

Control.Monad.MultiPass.Instrument.EmitST2Array

Description

The EmitST2Array instrument is used to emit a sequence of values to an ST2Array. It has three passes. The first pass counts the number of elements that will be written. The second pass is optional: it enables the index values to be read before the actual values have been written. (If this pass is not needed then the second and third passes can be merged by coalescing the type variables for the second and third passes: EmitST2Array p1 p2 p2.) The third pass writes the values to the output array.

Synopsis

Documentation

data EmitST2Array i a r w p1 p2 p3 tc Source

Abstract datatype for the instrument.

Instances

Instrument tc () () (EmitST2Array i a r w Off Off Off tc) 
Num i => Instrument tc (CounterTC1 i r) () (EmitST2Array i a r w On Off Off tc) 

setBaseIndexSource

Arguments

:: (Ix i, Num i, Monad p1, Monad p2, Monad p3) 
=> EmitST2Array 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) 
=> EmitST2Array 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) 
=> EmitST2Array 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 length of the list needs to be declared in the first pass so that the correct number of elements can be allocated.

getIndexSource

Arguments

:: (Ix i, Num i, Monad p1, Monad p2, Monad p3) 
=> EmitST2Array 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) 
=> EmitST2Array 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.