Safe Haskell | None |
---|---|
Language | Haskell2010 |
Common utilities for implementing reservation data structures.
A reservation data structure is one that allows multiple inserts of the same item, by returning a unique handle for each insert operation that must be given to the delete operation.
If you need to store the handle together with the item, e.g. so that the item knows how to delete itself, this can be achieved via the standard Haskell "tying the knot" technique.
This API is experimental at the moment, and parts of it may change.
Synopsis
- newtype RHandles = RHandles {}
- data RHandle
- newHandles :: RHandles
- nextHandle :: RHandles -> (RHandle, RHandles)
- checkHandle :: RHandles -> RHandle -> Bool
- withHandle :: ((RHandle, i) -> c -> c) -> i -> (RHandles, c) -> (RHandle, (RHandles, c))
- sEnqueue :: a -> Seq a -> Seq a
- sUnqueue :: (HasCallStack, Eq k) => k -> Seq (k, a) -> (Maybe a, Seq (k, a))
- sDequeue :: Seq a -> (Maybe a, Seq a)
Documentation
Handle generator. Runtime invariants:
- A handle from one generator is not used in a context that expects a handle from a different generator. TODO: use a string or other data to distinguish the contexts.
- Newly generated handles are distinguishable from previously-generated
ones.
checkHandle
is used to check this.
Instances
Bounded RHandle Source # | |
Enum RHandle Source # | |
Eq RHandle Source # | |
Ord RHandle Source # | |
Read RHandle Source # | |
Show RHandle Source # | |
Generic RHandle Source # | |
type Rep RHandle Source # | |
Defined in Data.Rsv.Common |