control-monad-queue-0.0.9.1: Reusable corecursive queues, via continuations.

Portabilityportable
Stabilityexperimental
Maintainerleon at melding-monads dot com

Control.Monad.Queue.Allison

Description

A library implementation of corecursive queues, see Circular Programs and Self-Referential Structures by Lloyd Allison, Software Practice and Experience, 19(2), pp.99-109, Feb 1989

http://www.csse.monash.edu.au/~lloyd/tildeFP/1989SPE/

For an explanation of the library implementation, see Lloyd Allison's Corecursive Queues: Why Continuations Matter by Leon P Smith, in The Monad Reader issue 14. This library corresponds to CorecQ in that paper.

Synopsis

Documentation

data Q e a Source

Instances

MonadQueue e (Q e) 
Monad (Q e) 

runQueue :: Q e a -> [e]Source

Returns a list of all elements enqueued during the queue computation

enQ :: e -> Q e ()Source

Enqueues an element to the queue

deQ :: Q e (Maybe e)Source

Dequeues an element, returns Nothing if the queue is empty.

deQs :: Integral len => len -> Q e [e]Source

Dequeues up to len elements from the queue

deQ_break :: Q e eSource

Dequeues an element: terminates the queue computation if the queue is empty.

peekQ :: Q e (Maybe e)Source

Examines the front element of the queue without removing it.

peekQn :: Integral index => index -> Q e (Maybe e)Source

Examines the element currently at position index in the queue, indexing starts with 0, like !!.

peekQs :: Integral maxlen => maxlen -> Q e [e]Source

Examines up to maxlen elements of the queue without removing them.

lenQ :: Integral len => Q e lenSource

Returns the length of the queue

lenQ_ :: Q e LenTypeSource

Returns the length of the queue

callCC :: ((a -> forall b. Q e b) -> Q e a) -> Q e aSource