lvish- 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 whereSource

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 QuasiDetSource

A shorthand for quasi-deterministic Par computations.

Unsafe conversions and lifting

unWrapPar :: Par d s a -> Par aSource

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

unsafeRunPar :: Par d s a -> aSource

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 aSource

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

state :: LVar s a d -> aSource

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

liftIO :: MonadIO m => forall a. IO a -> m a

Lift a computation from the IO monad.