Safe Haskell | Trustworthy |
---|
A generic interface providing operations that work on all LVars.
- class Foldable (f Trvrsbl) => LVarData1 f where
- class LVarWBottom f where
- type LVContents f a :: Constraint
- newBottom :: LVContents f a => Par d s (f s a)
- class LVarData1 f => OrderedLVarData1 f where
- snapFreeze :: f s a -> Par QuasiDet s (f Trvrsbl a)
- data AFoldable a = forall f2 . Foldable f2 => AFoldable (f2 a)
- castFrzn :: LVarData1 f => f Trvrsbl a -> f Frzn a
- forFrzn :: LVarData1 f => f Frzn a -> (a -> Par d s ()) -> Par d s ()
Classes containing the generic interfaces
class Foldable (f Trvrsbl) => LVarData1 f whereSource
A class representing monotonic data structures that take one type
parameter, as well as an s
parameter for session safety.
LVars that fall into this class are typically collection types.
addHandler :: Maybe HandlerPool -> f s elt -> (elt -> Par d s ()) -> Par d s ()Source
Add a handler function which is called whenever an element is added to the LVar.
freeze :: f s a -> Par QuasiDet s (f Frzn a)Source
An O(1) operation that atomically switches the LVar into a frozen state. Any threads waiting on the freeze are woken.
The contents of a frozen LVar are fully observable: e.g., a whole set instead of one element, or the full/empty information for an IVar, instead of just the payload.
However, note that Frzn
LVars cannot be folded, because they may have
nondeterministic ordering after being frozen. See sortFreeze
.
sortFrzn :: Ord a => f Frzn a -> AFoldable aSource
Perform a freeze followed by a sort operation which guarantees
that the elements produced will be produced in a deterministic order.
The result is fully accessible to the user (Foldable
).
LVarData1 IVar | An |
LVarData1 IStructure | An |
LVarData1 ISet | An |
LVarData1 ISet | An |
LVarData1 (IMap k) | An |
LVarData1 (IMap k) | An |
class LVarWBottom f whereSource
A class enabling generic creation of new LVars.
type LVContents f a :: ConstraintSource
Requirements for contents types of this LVar.
newBottom :: LVContents f a => Par d s (f s a)Source
class LVarData1 f => OrderedLVarData1 f whereSource
Some LVar datatypes are stored in an internally ordered way so that it is then possible to take O(1) frozen snapshots and consume them inexpensively in a deterministic order.
LVars with this additional property provide this class as well as LVarData1
.
snapFreeze :: f s a -> Par QuasiDet s (f Trvrsbl a)Source
Don't just freeze the LVar, but make the full contents
completely available and Foldable
. Guaranteed O(1).
OrderedLVarData1 IStructure | The |
OrderedLVarData1 ISet | The |
OrderedLVarData1 ISet | The |
OrderedLVarData1 (IMap k) | The |
OrderedLVarData1 (IMap k) | The |
Supporting types and utilities
Carries a Foldable
type, but you don't get to know which one.
The purpose of this type is that sortFreeze
should not have
to impose a particular memory representation.