Tors and Continuations

Tors are the fundamental building blocks of Koru. A tor declares its input payload and every branch it can produce — its exits, up front.

Tor Declaration

A tor is declared with tor. A branch that carries a value names its payload type directly; a bare branch name carries none:

tor greet { name: string }
| greeting string
| error string

Implementation

A subflow provides the implementation — each arm produces one of the declared branches:

greet => greeting "Hello, " ++ name ++ "!"

Invoking Tors

Tors are invoked with flows, and every declared branch must be handled — drop an arm and the program does not compile:

import std/io

greet(name: "World")
| greeting g |> std/io:print.ln(g)
| error e |> std/io:print.ln(e)