Portability | portable |
---|---|

Stability | experimental |

Maintainer | leon at melding-monads dot com |

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.

- data Q w e a
- type LenType = Word
- runResultQueue :: Q a e a -> (a, [e])
- runResult :: Q a e a -> a
- runQueue :: Q a e a -> [e]
- enQ :: e -> Q w e ()
- deQ :: Q w e (Maybe e)
- deQ_break :: w -> Q w e e
- deQs :: Integral len => len -> Q w e [e]
- peekQ :: Q w e (Maybe e)
- peekQn :: Integral index => index -> Q w e (Maybe e)
- peekQs :: Integral len => len -> Q w e [e]
- lenQ :: Integral len => Q w e len
- lenQ_ :: Q w e LenType
- mapQ :: (w -> w) -> Q w e a -> Q w e a
- wfix :: (w -> Q w e a) -> Q w e a
- callCC :: ((a -> forall b. Q w e b) -> Q w e a) -> Q w e a
- exit :: w -> Q w e a

# Documentation

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

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

deQ_break :: w -> Q w e eSource

Dequeues an element: terminates the computation with the final result `w`

if the queue is empty.

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.

mapQ :: (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`