Miscellaneous

Short function definitions

Very short functions can be written on one line using =.

main void() = log twice 3 twice nat(a nat) = a * 2

Command-line arguments

The signature of main is always void with no arguments.
To take command line arguments, call command-line-args.
To set a process exit code, call exit-process.

import keen/io/process main void() global log command-line-args exit-process 7

Type aliases

alias introduces a new name for a type.
float, int, and nat are aliases for float64, int64, and nat64.

main void() xs nats = 1, 2, 3 log xs nats alias nat[]

Currently, an alias can't be a template.

Doc comments

Regular comments begin with #. Doc comments begin with |.
When referring to another declaration, or a function parameter, wrap its name in {}.
Keen will check that it really refers to something.

main void() log double triple "o" | Makes two of {a} | Use {triple} if you need just a bit more double string(a string) repeat a, 2 | Makes three of {a} | Use {double} if this is too much # This comment will not appear on hover triple string(a string) repeat a, 3

Region comments

region marks the start of a section of a module.
The text to the right of the region keyword is a comment.
This may provide a folding range in your editor. (So far only in VSCode.)
This has no effect on the meaning of the code; for example, private declarations are still visible in the whole file.

main void() log one + two log "{hello} {goodbye}" region numbers -one nat() 1 -two nat() 2 region words -hello string() "hello" -goodbye string() "goodbye"

Unused internals

If you run keen check foo (where foo is a directory) and foo/config.kid exists, it is assumed that this is a complete library.
In that case, Keen will log a diagnostic for any unused internal declarations.

Floats

In Keen, float functions (except for unsafe ones) that would return nan instead throw an exception.

import keen/math/math main void() # Every one of these throws log square-root -1 log 1::float / 0 log log::float 0 log sin infinity

In Keen, a value must always equal itself, so nan == nan.
Also, two values must only be equal if they are indistinguishable, so -0 != 0.
For comparison, Keen uses this ordering:

To get the looser IEEE float comparison, use float-equal and float-less.

main void() unsafe log nan == nan log float-equal nan, nan log nan < -infinity log float-less nan, -infinity log -0.0 < 0 log float-less -0, 0