9 Checked Bodies🔗ℹ

The bodies of functions with refinements can use many but not all features of Shplait. A body is a sequence of (zero or more) local defs followed by one result expression, and it may contain:

For instance, there is no abs; write max(n, -n). A local def may not shadow a parameter or an earlier local.

A builtin such as first(l) may be called, but nothing is known about its value. Builtins check their own arguments only when the program runs: string_get(s, i) with an i out of range is a run-time error, not a compile-time one. To have such a precondition checked, write a function that states it, like safe_get above, and call that.