March Docs

IOList

IOList module: lazy, tree-structured string builder.

IOList represents a sequence of string segments as a tree, deferring concatenation until the list is flushed to IO. This avoids O(n²) copying when building large strings from many small pieces.

Usage pattern: let buf = IOList.append(IOList.from_string("Hello, "), IOList.from_string("world!")) println(IOList.to_string(buf)) -- "Hello, world!"

The key invariant: IOList is lazy. Use it as an accumulator and only call to_string or write to IO at the very end.

Types

typeIOListIOList = Empty | Str(String) | Segments(List(IOList))#