Repository navigation
v0.17.0
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
#localcommand 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)iscount<T>(xs: Array<T>): Number, andgreet(name) = "#{name}"isgreet<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 && falsewasfalse, and is nowtrue.within { network: ... }andwithin { publish: ... }areE-TYPE-WITHIN-SPEC. Writeoutbound(false,trueor egress entries;"none"isfalse,"default"istrue) andinbound(false,trueor the host addresses a port may be published on).--formatand--stdout-encodeare removed.--outputsets stdout (the result ofeval, every report and help) totext,jsonorpretty-json;--log-formatsets stderr (logs, the command log, diagnostics) totextorjson.- A failure nobody awaited fails the run. An
asynccomputation that was never awaited and failed used to give onlyW-ASYNC-UNAWAITEDand 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
finallyblock runs when its body is abandoned bytimeout,race,allor a signal. It used to be skipped. - The command line calls functions only.
lask run <value> --helpexits 4, andlask envs ... <name>no longer takes a plain value or aninternaldeclaration. 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
Environmentat run time.castatEnvironmentfails withgot Runnable, and acaseheadEnvironmentno longer selects it. E-MODULE-HASH-MISMATCHandE-MODULE-REV-MOVEDare renamedE-IO-MODULE-HASH-MISMATCHandE-IO-MODULE-REV-MOVED, matching their stage and exit code 3.- The
environmentsof JSON help have the fieldsenvironmentandkind, the kindlocal,registryorrecipe, asenvs listshows them. - A command-line parse error exits 4 with
E-CLI-USAGE, as every usage error does. It exited 1. - Haskell API (experimental):
ELambdacarries type parameters, the AST gainsENeg, the EDSL's ordering operators take anyOrderable, andLanguage.Lask.Accessfollows 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>andAsyncHandle<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. AnArray<Number>variable can be passed whereArray<Any>is wanted, as a literal always could. - Join with
Null.c ? "x" : null,if (c) { null } else { "x" }, acasewith anullarm andtry ... catch (e) { null }areString | Null, as anifwithoutelsealready 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
caseno 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_allas_build-all, not as an option.
Operators and names
<,<=,>,>=take any orderable type, so strings compare by code point, assortorders 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,runandfailincluded, can be redefined. Onlystdinis reserved.
Access constraints
access Name = { ... }declares a named constraint, used aswithin Nameorwithin m.Nameon a function or a module. It is imported, re-exported and markedinternallike a type alias, and diagnostics andlask envs accessshow it by name.- One rule for the fields: left out is unbounded,
falseadmits nothing,trueadmits anything a container can be given, and a list admits what it lists. runsbounds where a use may run:runs: ["container"]keeps a function off the host, andruns: falseadmits no command at all.inboundbounds 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 checkgives 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
finallyblock runs,asynccomputations included, and the run fails withE-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 cmdforwards SIGTERM to its program.envvariables 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
--outputand--log-formatreplace--formatand--stdout-encode, one option per stream.pretty-jsonworks 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@paramnaming no parameter),W-CLI-PARAM-SHADOWED(a keyword parameter namedhelp) andW-EXPORT-INCONSISTENT(exporton some declarations and not others). - A function's help lists its environments as
envs listdoes.
Specification
- The command schema rules move to Appendix A.
- The choices left to the implementation are pinned: a JSON object decodes to a record,
lengthcounts 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:
Runnableis 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-CYCLEprints 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