Esc
Start typing to search...

Task Module

Compile-time operations for running external Keel files as tasks.

The Task module provides run and define for splitting programs into multiple files with typed interfaces. Unlike other modules, these are compile-time operations intercepted by the compiler.

Functions

  • run: Run an external Keel file, passing variables by name
  • define: Declare a task file's input parameters and outputs

Common patterns

-- Caller (host.kl)
let { result } = Task.run "compute.kl" (x)

-- Callee (compute.kl)
Task.define (x : Int) -> (result : Int)
let result = x + 10

Functions

Task.define

(params) -> (outputs)

Define the interface for a task file — typed input parameters and optional outputs.

Must appear at the top of a task file, before any expressions.

Example:
Task.define (x : Int) -> (result : Int)
let result = x + 10
Try it

Notes: This is a declaration, not a runtime function. It is read by the compiler when another file calls Task.run on this file.

See also: Task.run

Task.run

String -> a

Run an external Keel file as a task. Variables can be passed by name.

Returns a record of the task file's exposed values.

Example:
let { result } = Task.run "compute.kl" (x)
let { data } = Task.run "extract.kl"
Task.run "load.kl" (data)
Try it

Notes: This is a compile-time operation — the file is read, parsed, and compiled inline. The task file declares its interface with Task.define.

See also: Task.define