schedule-0.3.0.0: Pure deterministic scheduled computations

Safe HaskellNone
LanguageHaskell2010

Data.Rsv.Common

Description

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

Documentation

newtype RHandles Source #

Handle generator. Runtime invariants:

  1. 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.
  2. Newly generated handles are distinguishable from previously-generated ones. checkHandle is used to check this.

Constructors

RHandles 
Instances
Eq RHandles Source # 
Instance details

Defined in Data.Rsv.Common

Read RHandles Source # 
Instance details

Defined in Data.Rsv.Common

Show RHandles Source # 
Instance details

Defined in Data.Rsv.Common

Generic RHandles Source # 
Instance details

Defined in Data.Rsv.Common

Associated Types

type Rep RHandles :: Type -> Type #

Methods

from :: RHandles -> Rep RHandles x #

to :: Rep RHandles x -> RHandles #

type Rep RHandles Source # 
Instance details

Defined in Data.Rsv.Common

type Rep RHandles = D1 (MetaData "RHandles" "Data.Rsv.Common" "schedule-0.3.0.0-rXAR2JhUGJ487cqZKqedA" True) (C1 (MetaCons "RHandles" PrefixI True) (S1 (MetaSel (Just "getNextHandle") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 RHandle)))

data RHandle Source #

Instances
Bounded RHandle Source # 
Instance details

Defined in Data.Rsv.Common

Enum RHandle Source # 
Instance details

Defined in Data.Rsv.Common

Eq RHandle Source # 
Instance details

Defined in Data.Rsv.Common

Methods

(==) :: RHandle -> RHandle -> Bool #

(/=) :: RHandle -> RHandle -> Bool #

Ord RHandle Source # 
Instance details

Defined in Data.Rsv.Common

Read RHandle Source # 
Instance details

Defined in Data.Rsv.Common

Show RHandle Source # 
Instance details

Defined in Data.Rsv.Common

Generic RHandle Source # 
Instance details

Defined in Data.Rsv.Common

Associated Types

type Rep RHandle :: Type -> Type #

Methods

from :: RHandle -> Rep RHandle x #

to :: Rep RHandle x -> RHandle #

type Rep RHandle Source # 
Instance details

Defined in Data.Rsv.Common

type Rep RHandle = D1 (MetaData "RHandle" "Data.Rsv.Common" "schedule-0.3.0.0-rXAR2JhUGJ487cqZKqedA" True) (C1 (MetaCons "RHandle" PrefixI True) (S1 (MetaSel (Just "getHandle") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Word64)))

checkHandle :: RHandles -> RHandle -> Bool Source #

Check that an existing handle is consistent with the current state of a handle generator, i.e. it must not be part of the generator's future.

withHandle :: ((RHandle, i) -> c -> c) -> i -> (RHandles, c) -> (RHandle, (RHandles, c)) Source #

sEnqueue :: a -> Seq a -> Seq a Source #

sUnqueue :: (HasCallStack, Eq k) => k -> Seq (k, a) -> (Maybe a, Seq (k, a)) Source #

sDequeue :: Seq a -> (Maybe a, Seq a) Source #