mirror of
https://github.com/tweag/nickel.git
synced 2024-10-07 00:30:47 +03:00
b0e0311267
This renames all builtins and standard library functions to conform to a snake case convention, as per decision recorded in #493. This also adapts examples and tests to this change. All functions have been renamed the way you'd expect, except the following: * `fromPred` -> `from_predicate` * `typeOf` -> `typeof` (like in C) * `fieldsOf` -> `fields` (the `_of` is redundant for a function) * `valuesOf` -> `values` (the `_of` is redundant for a function) Closes #493
19 lines
687 B
Plaintext
19 lines
687 B
Plaintext
// Example of simple custom contract, parametrized by a first argument.
|
|
// In practice, for this kind of simple predicate, one should rather use
|
|
// `contracts.from_predicate`
|
|
let EqualsTo = fun reference_value label value =>
|
|
if reference_value == value then
|
|
value
|
|
else
|
|
contracts.blame label in
|
|
|
|
let AlwaysTrue = EqualsTo true in
|
|
let AlwaysFalse = EqualsTo false in
|
|
|
|
// This contract says: `not` requires its argument to be true, and in return
|
|
// promise that the return value is false.
|
|
// Try passing `false` to `not`, or to use the identity function (replacing `!x`
|
|
// by `x`) to see contract errors appear.
|
|
let not | #AlwaysTrue -> #AlwaysFalse = fun x => !x in
|
|
not true
|