Navigation

Queue

FTCQueue (catenable queue, after Kiselyov & Ishii 2015). O(1) snoc/append, amortized O(1) viewl.

append

append: concatenate two queues in O(1); identity queues short-circuit and the __rawResume rotation flag is propagated when present.

append : FTCQueue a b -> FTCQueue b c -> FTCQueue a c

Concatenate two queues. O(1).

Identity queues short-circuit (return the other side untouched). The __rawResume flag is preserved so fx.bind chains around scope.provide retain deep-handler semantics.

leaf

leaf: build a singleton FTCQueue containing one continuation; the leaf of the catenable-tree representation.

leaf : (a -> Computation b) -> FTCQueue a b

Create a singleton queue containing one continuation function.

node

node: join two FTCQueues into a balanced tree node; O(1) concatenation that defers traversal cost to viewl.

node : FTCQueue a x -> FTCQueue x b -> FTCQueue a b

Join two queues. O(1) — just creates a tree node; the cost is amortised by viewl during deconstruction.

qApp

qApp: apply a queue of continuations to a starting value; trampolines pure continuations via genericClosure and halts at the first Impure result.

qApp : FTCQueue a b -> a -> Computation b

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

singleton: alias for leaf; build an FTCQueue from a single continuation function with no nesting.

singleton : (a -> Computation b) -> FTCQueue a b

Create a queue with a single continuation. O(1). Synonym for leaf.

snoc

snoc: append one continuation to the right end of a queue in O(1); preserves the __rawResume rotation flag for deep-handler semantics.

snoc : FTCQueue a b -> (b -> Computation c) -> FTCQueue a c

Append a continuation to the right of the queue. O(1).

Preserves the __rawResume flag through extension so deep-handler rotation continuations keep routing effectful resumes back through inner-scope handlers.

viewl

viewl: extract the leftmost continuation from a queue with amortised O(1) cost via viewlGo rotation; returns { head, tail }, tail = null for singletons.

viewl : FTCQueue a b -> { head : (a -> Computation b), tail : FTCQueue a b | null }

Extract the leftmost continuation from the queue. Amortized O(1).

Returns { head = fn; tail = queue | null; }tail is null when the queue had only one element.