Safe Haskell | Unsafe |
---|---|
Language | Haskell98 |
This module contains the unsafe bits that we cannot expose from Data.LVar.Generic.
- 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)
- data AFoldable a = forall f2 . Foldable f2 => AFoldable (f2 a)
- unsafeCoerceLVar :: LVarData1 f => f s1 a -> f s2 b
- unsafeTraversable :: LVarData1 f => f Frzn a -> IO (f Trvrsbl a)
Documentation
class Foldable (f Trvrsbl) => LVarData1 f where Source
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.
The superclass constraint on this class serves to ensure that once frozen, the LVar contents are foldable.
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 a Source
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 (SatMap k) | An |
LVarData1 (IMap k) | An |
class LVarWBottom f where Source
A class enabling generic creation of new LVars.
type LVContents f a :: Constraint Source
Requirements for contents types of this LVar.
newBottom :: LVContents f a => Par d s (f s a) Source
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.
unsafeCoerceLVar :: LVarData1 f => f s1 a -> f s2 b Source
A safer version of unsafeCoerce#
(that is, with a slightly more constrained type) for LVars only.
Note, that the type of the LVar's contents must be allowed to change, because freezing is recursive.