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
CorecQ in that paper.
- data Q e a
- type LenType = Word
- runQueue :: Q e a -> [e]
- enQ :: e -> Q e ()
- deQ :: Q e (Maybe e)
- deQs :: Integral len => len -> Q e [e]
- deQ_break :: Q e e
- peekQ :: Q e (Maybe e)
- peekQn :: Integral index => index -> Q e (Maybe e)
- peekQs :: Integral maxlen => maxlen -> Q e [e]
- lenQ :: Integral len => Q e len
- lenQ_ :: Q e LenType
- callCC :: ((a -> forall b. Q e b) -> Q e a) -> Q e a
- exit :: Q e a
Dequeues an element: terminates the queue computation if the queue is empty.
Examines the element currently at position
index in the queue, indexing starts with
Examines up to
maxlen elements of the queue without removing them.