Follow

Today I'd like to discuss Conduit, which is what XML Conduit and HTML Conduit is built upon! Maybe that's where they get their names?

Conduit is a system for definining pipelines that can switch between push & pull.

---

A "Conduit" is a function which takes a trailing function to call with some argument and returns a "Pipe". A Pipe is essentiallya linked list with a "final result", though it has several other interesting features.

1/?

A Pipe may alternatively callbacks in case this is a pull pipeline, not a push, it may return leftover input, and it indicates when sideeffects are required to avoid hampering optimizing processing of the rest of the pipe.

To "fuse" (|. operator) two Conduits it iterates over the downstream Pipe, partially echoing it in the result with leftover tokens fed back into it. Upon requesting more input it'll iterate over the upstream until it has a result or another value.

2/?

To run a Conduit you maintain a stack to push upon Leftovers & pop upon NeedInput, but otherwise you just iterate over it until you reach the result.

"await" calls the Conduit's continuation function via a response from NeedInput. "yield" returns a HaveOutput with the continuation function.

Concatenating two Conduits involves the second into the continuation for the first.

Again I'll have to leave the rest of it's APIs up to your imagination. With one exception for tomorrow.

3/3 Fin, for now

Sign in to participate in the conversation
FLOSS.social

For people who care about, support, or build Free, Libre, and Open Source Software (FLOSS).