queue-0.1.2: Abstraction typeclasses for queue-like things.

Data.Queue

Synopsis

Documentation

class Monad m => NewFifo q m whereSource

Construct a new FIFO queue.

Methods

newFifo :: m qSource

Instances

class Monad m => DefaultFifo q m a | q -> a, m a -> qSource

A type class carrying an altered set of functional dependencies used to constrain queues when the type of the queue never escapes far enough for a more deliberate choice to be made.

Instances

class Monad m => Enqueue q m a | q -> a whereSource

Methods

enqueue :: q -> a -> m ()Source

Put an item into a queue. May block while trying to do so. No constraint is placed on the behavior of the queue except that every item put in really ought to come out sometime before dequeue returns a Nothing.

enqueueBatch :: q -> [a] -> m ()Source

Instances

Enqueue (Chan a) IO a 
Enqueue (MVar a) IO a 
Enqueue (TMVar a) IO a 
Enqueue (TMVar a) STM a 
Enqueue (TChan a) IO a 
Enqueue (TChan a) STM a 
Enqueue q m a => Enqueue (WQueue q) m a 

class Monad m => Dequeue q m a | q -> a whereSource

Methods

dequeue :: q -> m (Maybe a)Source

Pull an item out of a queue. Should not block. No ordering constraints are implied other than that any item that went into the queue really ought to come out before dequeue returns Nothing.

dequeueBatch :: q -> m [a]Source

Instances

Dequeue (MVar a) IO a 
Dequeue (TMVar a) IO a 
Dequeue (TMVar a) STM a 
Dequeue (TChan a) IO a 
Dequeue (TChan a) STM a 
Dequeue q m a => Dequeue (RQueue q) m a 

class Monad m => DequeueWhere q m a | q -> a whereSource

Methods

dequeueWhere :: q -> (a -> Bool) -> m (Maybe a)Source

Pull an item matching the given predicate out of a queue.

class Monad m => PeekQueue q m a | q -> a whereSource

Methods

peekQueue :: q -> m [a]Source

return the whole contents of the queue (if possible) without altering the queue's contents. Obviously in cases where this can't be done lazily this can be a very expensive operation.

peekQueueTaking :: Int -> q -> m [a]Source

peek a specified number of items off the queue. The default implementation is hideously wasteful in cases where peekQueue is not able to get the contents lazily.

Instances

class Monad m => QueueSize q m whereSource

Methods

queueSize :: q -> m IntSource

return the number of elements in the queue

data RQueue q Source

RQueue : read-only newtype wrapper for arbitrary queues

Instances

Dequeue q m a => Dequeue (RQueue q) m a 

data WQueue q Source

WQueue : write-only newtype wrapper for arbitrary queues

Instances

Enqueue q m a => Enqueue (WQueue q) m a