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.Corec

Description

Corecursive queues with return values. This is a straightforward generalization of Control.Monad.Queue.Allison. It corresponds to CorecQW in the paper Lloyd Allison's Corecursive Queues: Why Continuations Matter by Leon P Smith in the Monad Reader issue 14.

Synopsis

Documentation

data Q w e a Source

Instances

MonadQueue e (Q w e) Source 
Monad (Q w e) Source 
Functor (Q w e) Source 
Applicative (Q w e) Source 

runResultQueue :: Q a e a -> (a, [e]) Source

Runs the computation, returns the result of the computation and a list of all elements enqueued

runResult :: Q a e a -> a Source

Runs the computation, returns the result of the computation

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

Runs the computation, returns a list of all elements enqueued

enQ :: e -> Q w e () Source

Enqueues an element to the queue

deQ :: Q w e (Maybe e) Source

Dequeues and element: returns Nothing if the queue is empty.

deQ_break :: w -> Q w e e Source

Dequeues an element: terminates the computation with the final result w if the queue is empty.

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

Dequeues up to len elements from the queue

peekQ :: Q w e (Maybe e) Source

Examines the front element of the queue without removing it.

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

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

peekQs :: Integral len => len -> Q w e [e] Source

Looks at up to the first len elements of the queue, like deQs except without removing them.

lenQ :: Integral len => Q w e len Source

Returns the length of the queue

lenQ_ :: Q w e LenType Source

Returns the length of the queue

mapQ :: (w -> w) -> Q w e a -> Q w e a Source

Applies a function to the final return value of the entire computation, like mapCont

wfix :: (w -> Q w e a) -> Q w e a Source

Computes a fixpoint on the result; usually used in conjunction with mapQ

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

exit :: w -> Q w e a Source

Terminates the queue computation with result w