Queue
FTCQueue (catenable queue, after Kiselyov & Ishii 2015). O(1) snoc/append, amortized O(1) viewl.
append
Concatenate two queues. O(1).
leaf
Create a singleton queue containing one continuation function.
node
Join two queues. O(1) — just creates a tree node.
qApp
Apply a queue of continuations to a value. Processes continuations left-to-right: if a continuation returns Pure, feed the value to the next continuation. If it returns Impure, append the remaining queue to the effect's own queue and return.
singleton
Create a queue with a single continuation. O(1).
snoc
Append a continuation to the right of the queue. O(1).
viewl
Extract the leftmost continuation from the queue. Amortized O(1).
Returns { head = fn; tail = queue | null; }
tail is null if the queue had only one element.