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

Copyright(c) Leon P Smith 2009-2011
Safe HaskellSafe



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

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, Jul 2009. This library corresponds to CorecQ in that paper.



data Q e a Source


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 e Source

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 len Source

Returns the length of the queue

lenQ_ :: Q e LenType Source

Returns the length of the queue

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

exit :: Q e a Source

Terminates the queue computation