1
1
mirror of https://github.com/tweag/nickel.git synced 2024-10-06 08:07:37 +03:00
nickel/stdlib
matthew healy 717db391c6
Flatten record contracts (#885)
Nickel's `$record` contract was previously implemented as a series of
nested calls to `$record_extend` which, for each field in the record
type, would:

  1. check that the field was present in the value, and if so
  2. insert an `%assume%` which applied the contract for that field to
     the value into the final accumulated record, and
  3. call the contract for the record's tail on any remaining fields.

This commit "flattens" this out so that, rather than a series of nested
`$record_extend` contracts, `$record` is provided a record which maps
expected field names to their associated contracts. These expected
fields are then compared with the record value directly in the contract,
with blame being raised where appropriate.

This makes it possible to, for example, report every missing field name
at once, as opposed to just the first one we find. (Though that has not
been done in this PR to minimise the diff.)
2022-10-26 14:22:52 +02:00
..
array.ncl Fix array.sort in stdlib 2022-08-05 17:34:25 +02:00
builtin.ncl Add push priority operators 2022-10-12 12:38:12 +02:00
contract.ncl Add push priority operators 2022-10-12 12:38:12 +02:00
function.ncl Rename stdlib modules: remove trailing s 2022-02-25 12:41:54 +01:00
internals.ncl Flatten record contracts (#885) 2022-10-26 14:22:52 +02:00
num.ncl Get rid of is_xxx primops in favor of typeof 2022-06-24 18:38:59 +02:00
record.ncl Fix record.update contract, remove trailing spaces 2022-03-28 18:00:10 +02:00
string.ncl Add builtin.to_str and string.from to stdlib 2022-06-24 19:12:50 +02:00