lvish-2.0: 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 where

The type of parallel computations. A computation Par e 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 e s a 


Monad (Par $a $b) 
Functor (Par $a $b) 
Applicative (Par $a $b) 
ParFuture (Par e s) 
ParIVar (Par e s) 
ParSealed (Par e s) 
LVarSched (Par e s) 
ParThreadSafe (Par e s) 
ParMonad (Par e s) 
MonadIO (Par e s) 
(Deterministic e1, ~ EffectSig e2 (SetF F e1)) => ParQuasi (Par e1 s) (Par e2 s) 
(Deterministic e1, ~ EffectSig e2 (SetF F e1)) => LVarSchedQ (Par e1 s) (Par e2 s) 

newtype LVar s all delt

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

Unsafe conversions and lifting

unWrapPar :: Par e s a -> Par a

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

unsafeRunPar :: Par e s a -> a

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

unsafeConvert :: Par e1 s1 a -> Par e2 s2 a

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

unsafeDet :: Par e1 s a -> Par e2 s a

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

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

liftIO :: IO a -> Par e s a

Unsafe internal operation to lift IO into the Par monad.

Debugging information taken from the environment

dbgLvl :: Int

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.