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

Copyright(c) Leon P Smith 2009-2011
LicenseBSD3
Maintainerleon@melding-monads.com
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell98

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

http://themonadreader.files.wordpress.com/2009/07/issue142.pdf

Synopsis

Documentation

data Q e a Source

Instances

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