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

Portabilityportable
Stabilityexperimental
Maintainerleon at melding-monads dot com

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) 
Monad (Q w e) 

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 -> aSource

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 eSource

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 lenSource

Returns the length of the queue

lenQ_ :: Q w e LenTypeSource

Returns the length of the queue

mapQW :: (w -> w) -> Q w e a -> Q w e aSource

Applies a function to the final return value of the entire computation, like Control.Monad.Cont.mapCont

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