lvish-1.1.4: Parallel scheduler, LVar data structures, and infrastructure to build more.

Safe HaskellUnsafe




This module is not Safe Haskell; as an end-user, you shouldn't ever need to import it.

It is exposed only because it is necessary for implementing new LVar types that will live in their own, separate packages.


Type-safe wrappers around internal components

newtype Par :: Determinism -> * -> * -> * where Source

The type of parallel computations. A computation Par d s a may or may not be deterministic based on the setting of the d parameter (of kind Determinism). The s parameter is for preventing the escape of LVars from Par computations (just like the ST monad).

Implementation note: This is a wrapper around the internal Par type, only with more type parameters.


WrapPar :: Par a -> Par d s a 


Monad (Par $a $b) 
Functor (Par $a $b) 
Applicative (Par $a $b) 
MonadIO (Par d s) 

newtype LVar s all delt Source

The generic representation of LVars used by the scheduler. The end-user can't actually do anything with these and should not try to.




unWrapLVar :: LVar all delt

data Determinism Source

This datatype is promoted to type-level (DataKinds extension) and used to indicate whether a Par computation is guaranteed-deterministic, or only quasi-deterministic (i.e., might throw NonDeterminismExn).




type QPar = Par QuasiDet Source

A shorthand for quasi-deterministic Par computations.

Unsafe conversions and lifting

unWrapPar :: Par d s a -> Par a Source

Unsafe: drops type information to go from the safe Par monad to the internal, dangerous one.

unsafeRunPar :: Par d s a -> a Source

This is cheating! It pays no attention to session sealing (s) or to the determinism level (d).

unsafeConvert :: Par d1 s1 a -> Par d2 s2 a Source

Ignore the extra type annotations regarding both determinism and session-sealing.

unsafeDet :: Par d1 s a -> Par d2 s a Source

Unsafe coercion from quasi-deterministic to deterministic. The user is promising that code is carefully constructed so that put/freeze races will not occur.

state :: LVar s a d -> a Source

Extract the state of an LVar. This should only be used by implementations of new LVar data structures.

liftIO :: IO a -> Par d s a Source

Unsafe internal operation to lift IO into the Par monad.

Debugging information taken from the environment

dbgLvl :: Int Source

Debugging flag shared by several modules. This is activated by setting the environment variable DEBUG=1..5.

By convention DEBUG=100 turns on full sequentialization of the program and control over the interleavings in concurrent code, enabling systematic debugging of concurrency problems.