Safe Haskell | Unsafe |
---|
This is not a datatype for the end-user.
Rather, this module is for building new LVar types in a comparatively easy way: by
putting a pure value in a mutable container, and defining a put
operation as a pure
function.
The data structure implementor who uses this module must guarantee
that their put
operation computes a least upper bound, ensuring
that the set of states that their LVar type can take on form a
join-semilattice (http://en.wikipedia.org/wiki/Semilattice).
- newtype PureLVar s t = PureLVar (LVar s (IORef t) t)
- newPureLVar :: BoundedJoinSemiLattice t => t -> Par d s (PureLVar s t)
- putPureLVar :: JoinSemiLattice t => PureLVar s t -> t -> Par d s ()
- waitPureLVar :: (JoinSemiLattice t, Eq t) => PureLVar s t -> t -> Par d s ()
- freezePureLVar :: PureLVar s t -> Par QuasiDet s t
Documentation
An LVar which consists merely of an immutable, pure value inside a mutable box.
newPureLVar :: BoundedJoinSemiLattice t => t -> Par d s (PureLVar s t)Source
A new pure LVar populated with the provided initial state.
putPureLVar :: JoinSemiLattice t => PureLVar s t -> t -> Par d s ()Source
Put a new value which will be joined with the old.
waitPureLVar :: (JoinSemiLattice t, Eq t) => PureLVar s t -> t -> Par d s ()Source
Wait until the pure LVar has crossed a threshold and then unblock. (In the semantics, this is a singleton query set.)
freezePureLVar :: PureLVar s t -> Par QuasiDet s tSource
Freeze the pure LVar, returning its exact value.
Subsequent put
s will raise an error.