Skip to content

v0.17.0

Choose a tag to compare

@Ikepeeee Ikepeeee released this 14 Nov 13:40
· 188 commits to main since this release
24ece72

The language now asks for fewer annotations and holds fewer surprises, and a run cleans up after itself however it ends.

v0.17.0 comes out of a review of the whole specification. An unannotated parameter is no longer Any: its type is inferred from how the body uses it. Arrays, maps, records and functions take the variance that immutable values allow, an if, ?:, case or try with a null branch joins into T | Null, and lambdas can have type parameters. The operators follow other languages (&& above ||, < on strings, unary minus), and sugar is hygienic, so every built-in name can be shadowed. Access constraints get names, with access, and one rule for their fields, including runs and inbound. A finally block now runs when timeout, race, all or a SIGINT or SIGTERM cuts its body short, and containers are reaped even after SIGKILL. The command line splits its output options by stream, and the error codes are one complete table. Native Windows support is dropped: on Windows, Lask runs inside WSL 2.

Breaking changes

  • Native Windows is no longer supported. On Windows, run Lask inside WSL 2; the installation guide shows how. v0.16.0 is the last release with a Windows binary. A #local command always runs under /bin/sh, and the shell syntax check applies on every host.
  • An unannotated parameter is inferred from its uses, not Any (spec 4.3). count(xs) = size(xs) is count<T>(xs: Array<T>): Number, and greet(name) = "#{name}" is greet<T: stringifiable>(name: T). A body that uses a parameter in ways no single type satisfies, or reads a field of it, now asks for an annotation. A keyword parameter with a default keeps its default's type.
  • && binds tighter than ||. true || false && false was false, and is now true.
  • within { network: ... } and within { publish: ... } are E-TYPE-WITHIN-SPEC. Write outbound (false, true or egress entries; "none" is false, "default" is true) and inbound (false, true or the host addresses a port may be published on).
  • --format and --stdout-encode are removed. --output sets stdout (the result of eval, every report and help) to text, json or pretty-json; --log-format sets stderr (logs, the command log, diagnostics) to text or json.
  • A failure nobody awaited fails the run. An async computation that was never awaited and failed used to give only W-ASYNC-UNAWAITED and exit 0. The run now fails with that computation's error and exit code. To ignore a failure, catch it where it starts: async try { ... } catch (e) { null }.
  • A finally block runs when its body is abandoned by timeout, race, all or a signal. It used to be skipped.
  • The command line calls functions only. lask run <value> --help exits 4, and lask envs ... <name> no longer takes a plain value or an internal declaration. Write a value to print as a function of no parameters, version() = "1.0".
  • No type alias or type parameter may take a built-in type's name (String, Environment, Array, ...): E-NAME-DUPLICATE. Such a declaration was never used.
  • A runnable with run options is not an Environment at run time. cast at Environment fails with got Runnable, and a case head Environment no longer selects it.
  • E-MODULE-HASH-MISMATCH and E-MODULE-REV-MOVED are renamed E-IO-MODULE-HASH-MISMATCH and E-IO-MODULE-REV-MOVED, matching their stage and exit code 3.
  • The environments of JSON help have the fields environment and kind, the kind local, registry or recipe, as envs list shows them.
  • A command-line parse error exits 4 with E-CLI-USAGE, as every usage error does. It exited 1.
  • Haskell API (experimental): ELambda carries type parameters, the AST gains ENeg, the EDSL's ordering operators take any Orderable, and Language.Lask.Access follows the new constraint fields.

Lask is pre-1.0 and every feature is experimental until 1.0, so breaking changes remain possible; see compatibility.md.

Types

  • Parameter types are inferred from the body (spec 4.3). The inferred type is the most general one that every use accepts. A parameter used in a generic position gets a shape, such as Array<T>. One that is unused or used only through a bound becomes an implicit type parameter, T, U, ..., with that bound. Call sites never change the type, and an annotation always wins. Help shows the inferred signature.
  • Variance (spec 4.4). Array<T>, Map<T> and AsyncHandle<T> are covariant, record fields are covariant with the field set exact, and function types are contravariant in their parameters and covariant in their result. An Array<Number> variable can be passed where Array<Any> is wanted, as a literal always could.
  • Join with Null. c ? "x" : null, if (c) { null } else { "x" }, a case with a null arm and try ... catch (e) { null } are String | Null, as an if without else already was. Branches of other different types are still an error. The type of the branches no longer depends on which comes first.
  • Lambdas with type parameters: largest = \<T: orderable>(xs: Array<T>): T -> last(sort(xs)) is generic where it is bound. A recursive lambda binding uses the lambda's own return type.
  • Narrowing to a type parameter with case no longer fails at run time (or_default<T>(x: T | Null, d: T)).
  • An identifier with a leading underscore is always a value name. The command line shows _build_all as _build-all, not as an option.

Operators and names

  • <, <=, >, >= take any orderable type, so strings compare by code point, as sort orders them.
  • Unary minus: -x, with the precedence of !.
  • Sugar is hygienic (spec 7.6). for, async, try, $ and !! always mean the built-ins, so every built-in name, map, run and fail included, can be redefined. Only stdin is reserved.

Access constraints

  • access Name = { ... } declares a named constraint, used as within Name or within m.Name on a function or a module. It is imported, re-exported and marked internal like a type alias, and diagnostics and lask envs access show it by name.
  • One rule for the fields: left out is unbounded, false admits nothing, true admits anything a container can be given, and a list admits what it lists.
  • runs bounds where a use may run: runs: ["container"] keeps a function off the host, and runs: false admits no command at all.
  • inbound bounds the host addresses a published port may listen on.
  • Static evaluation of run options is bounded by 1,000,000 steps instead of one second, so lask check gives the same answer on a fast laptop and a loaded CI runner.

Stopping and cleaning up

  • SIGINT and SIGTERM stop a run gracefully (spec 11.12): the running command is stopped, every finally block runs, async computations included, and the run fails with E-RUNTIME-INTERRUPTED, exit 130 or 143. A second signal stops at once.
  • Containers are reaped after SIGKILL. Every container lask starts is labelled with its owner, and a small reaper process removes them, and the egress networks, when lask goes away without cleaning up.
  • lask cmd forwards SIGTERM to its program.
  • env variables that the engine client would read itself (DOCKER_*, *_PROXY, PATH, ...) are passed in a private file, not on the client's command line.

Command line and errors

  • --output and --log-format replace --format and --stdout-encode, one option per stream. pretty-json works for every report, and JSON Lines logs can go with a text report.
  • One complete table of codes (spec 14.2): every code with its class, exit code and defining section, checked against the implementation by the test suite.
  • New advisories from lask check: W-REGEX-PATTERN (a literal pattern that does not compile), W-DOC-PARAM-UNKNOWN (an @param naming no parameter), W-CLI-PARAM-SHADOWED (a keyword parameter named help) and W-EXPORT-INCONSISTENT (export on some declarations and not others).
  • A function's help lists its environments as envs list does.

Specification

  • The command schema rules move to Appendix A.
  • The choices left to the implementation are pinned: a JSON object decodes to a record, length counts code points, split(s, "") gives them, a command's output is never truncated, and object keys are written in code point order.
  • Many smaller fixes where the text and the implementation disagreed: Runnable is comparable and in the grammar, the variables a command gets, the tag and lock key of a recipe, one collision rule for a namespace re-export, and the requirements document aligned with the specification.

Fixes

  • The note on E-MODULE-CYCLE prints the cycle in import order.
  • The language server no longer paints a command's { } and $[...] brackets as string text.

Full Changelog: v0.16.0...v0.17.0