dph-base-0.6.0.1: Data Parallel Haskell common config and debugging functions.

Safe HaskellSafe-Infered

Data.Array.Parallel.Base

Contents

Description

Common config and debugging functions. Imported by most modules.

Synopsis

Debugging infrastructure

debugCritical :: BoolSource

Enable internal consistency checks for operations that could corrupt the heap.

debug :: BoolSource

Enable internal consistency checks. This is NOT implied by debugCritical above. If you want both you need to set both to `True.`

tracePrimEnabled :: BoolSource

Print tracing information for each flat array primitive to console. The tracing hooks are in `dph-prim-par:Data.Array.Parallel.Unlifted`

check :: String -> Int -> Int -> a -> aSource

Bounds check, enabled when debug = True.

The first integer is the length of the array, and the second is the index. The second must be greater or equal to '0' and less than the first integer. If the not then error with the String.

checkCritical :: String -> Int -> Int -> a -> aSource

Bounds check, enabled when debugCritical = True.

This version is used to check operations that could corrupt the heap.

The first integer is the length of the array, and the second is the index. The second must be greater or equal to '0' and less than the first integer. If the not then error with the String.

checkLen :: String -> Int -> Int -> a -> aSource

Length check, enabled when debug = True.

Check that the second integer is greater or equal to `0' and less or equal than the first integer. If the not then error with the String.

checkSlice :: String -> Int -> Int -> Int -> a -> aSource

Slice check, enable when debug = True.

The vector must contain at least sliceStart + sliceLen elements.

checkEq :: (Eq a, Show a) => String -> String -> a -> a -> b -> bSource

Equality check, enabled when debug = True.

The two a values must be equal, else error.

The first String gives the location of the error, and the second some helpful message.

checkNotEmpty :: String -> Int -> a -> aSource

Given an array length, check it is not zero.

uninitialised :: String -> aSource

Throw an error saying something was not intitialised.

The String must contain a helpful message saying what module the error occured in, and the possible reasons for it. If not then a puppy dies at compile time.

Data constructor rags

type Tag = IntSource

Given a value of an algebraic type, the tag tells us what data constructor was used to create it.

tagToInt :: Tag -> IntSource

Convert a Tag to an Int. This is identity at the value level.

intToTag :: Int -> TagSource

Convert an Int to a Tag. This is identity at the value level.

fromBool :: Bool -> TagSource

Get the Tag of a Bool value. False is 0, True is 1.

toBool :: Tag -> BoolSource

Convert a Tag to a Bool value.

ST monad re-exported from GHC

newtype ST s a

The strict state-transformer monad. A computation of type ST s a transforms an internal state indexed by s, and returns a value of type a. The s parameter is either

  • an uninstantiated type variable (inside invocations of runST), or
  • RealWorld (inside invocations of stToIO).

It serves to keep the internal states of different invocations of runST separate from each other and from invocations of stToIO.

The >>= and >> operations are strict in the state (though not in values stored in the state). For example,

runST (writeSTRef _|_ v >>= f) = _|_

Constructors

ST (STRep s a) 

Instances

Monad (ST s) 
Functor (ST s) 
PrimMonad (ST s) 
Show (ST s a) 

runST :: (forall s. ST s a) -> a

Return the value computed by a state transformer computation. The forall ensures that the internal state used by the ST computation is inaccessible to the rest of the program.