diff --git a/core/stdlib/std.ncl b/core/stdlib/std.ncl index 2010f902d1..0ef2c9d63b 100644 --- a/core/stdlib/std.ncl +++ b/core/stdlib/std.ncl @@ -968,7 +968,11 @@ ``` "% = fun contracts label value => - std.array.fold_right (fun contract => std.contract.apply contract label) value contracts, + std.array.fold_left + (fun acc contract => std.contract.apply contract label acc) + value + contracts, + label | doc m%" The label submodule provides functions that manipulate the label diff --git a/core/tests/integration/pass/contracts/contracts.ncl b/core/tests/integration/pass/contracts/contracts.ncl index 04f92b97f7..5df478667d 100644 --- a/core/tests/integration/pass/contracts/contracts.ncl +++ b/core/tests/integration/pass/contracts/contracts.ncl @@ -165,12 +165,17 @@ let {check, Assert, ..} = import "../lib/assert.ncl" in let f | forall r. { ; r } -> { g : forall r. { ; r } -> { z : Number ; r }; r } = fun r => %record_insert% "g" r g in let res = f { z = 3 } - in true, + in std.seq res true, # std.contract.Sequence - let three = 3 | std.contract.Sequence [ Number, std.contract.from_predicate (fun x => x < 5) ] in - # preserves order - let tag = "some_tag" | std.contract.Sequence [ std.enum.TagOrString, [| 'some_tag |] ] - in true + let SmallerThanFive = std.contract.from_predicate (fun x => x < 5) in + let three | std.contract.Sequence [ Number, SmallerThanFive] = 3 in + three == 3, + + # std.contract.Sequence preserves order + let tag | std.contract.Sequence [std.enum.TagOrString, [| 'some_tag |]] + = "some_tag" + in + tag == 'some_tag, ] |> check