Skip to content

Commit

Permalink
Update to latest topiary-queries (formatting) (#2032)
Browse files Browse the repository at this point in the history
* Update to latest topiary-queries

Formatting of Nickel code has been updated upstream to better anticipate
the usage of `std.contract.custom` and `std.contract.from_predicate`.
This commit updates to the latest version, and update the formatting of
the stdlib, the examples and the snippets of the manual.

* Update topiary's entry in flake.lock as well

* Format stdlib/internals and benchmarks
  • Loading branch information
yannham authored Sep 9, 2024
1 parent 273ae0f commit c587d3a
Show file tree
Hide file tree
Showing 27 changed files with 1,146 additions and 1,288 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ metrics = "0.21"
metrics-util = "0.15"

topiary-core = "0.4.0"
topiary-queries = { version = "0.4.1", default-features = false, features = ["nickel"] }
topiary-queries = { version = "0.4.2", default-features = false, features = ["nickel"] }
# This version should agree with the topiary-query version: Nickel queries
# target a specific version of the Nickel grammar (though that dependency
# doesn't appear explicitly in `topiary-queries`'s Cargo.toml file). For now you
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ expression: err
---
error: contract broken by the caller of `at`
invalid array indexing
┌─ <stdlib/std.ncl>:166:9
┌─ <stdlib/std.ncl>:164:9
166| std.contract.unstable.IndexedArrayFun 'Index
164| std.contract.unstable.IndexedArrayFun 'Index
-------------------------------------------- expected type
┌─ [INPUTS_PATH]/errors/array_at_empty_array.ncl:3:16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ expression: err
---
error: contract broken by the caller of `at`
invalid array indexing
┌─ <stdlib/std.ncl>:166:9
┌─ <stdlib/std.ncl>:164:9
166| std.contract.unstable.IndexedArrayFun 'Index
164| std.contract.unstable.IndexedArrayFun 'Index
-------------------------------------------- expected type
┌─ [INPUTS_PATH]/errors/array_at_out_of_bound.ncl:3:16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ expression: err
---
error: contract broken by the caller of `range`
invalid range
┌─ <stdlib/std.ncl>:757:9
┌─ <stdlib/std.ncl>:755:9
757| std.contract.unstable.RangeFun Dyn
755| std.contract.unstable.RangeFun Dyn
---------------------------------- expected type
┌─ [INPUTS_PATH]/errors/array_range_reversed_indices.ncl:3:19
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ expression: err
---
error: contract broken by the caller of `range_step`
invalid range step
┌─ <stdlib/std.ncl>:732:9
┌─ <stdlib/std.ncl>:730:9
732| std.contract.unstable.RangeFun (std.contract.unstable.RangeStep -> Dyn)
730| std.contract.unstable.RangeFun (std.contract.unstable.RangeStep -> Dyn)
----------------------------------------------------------------------- expected type
┌─ [INPUTS_PATH]/errors/array_range_step_negative_step.ncl:3:27
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ expression: err
---
error: contract broken by the caller of `map`
expected an array
┌─ <stdlib/std.ncl>:150:33
┌─ <stdlib/std.ncl>:148:33
150 │ : forall a b. (a -> b) -> Array a -> Array b
148 │ : forall a b. (a -> b) -> Array a -> Array b
------- expected type of the argument provided by the caller
┌─ [INPUTS_PATH]/errors/caller_contract_violation.ncl:3:31
Expand Down
8 changes: 3 additions & 5 deletions core/benches/functions/church.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
let encoded =
base
|> std.array.map encode
|> std.array.map
(
fun nChurch =>
add (mult (encode 3) nChurch) (encode 5)
)
|> std.array.map (fun nChurch =>
add (mult (encode 3) nChurch) (encode 5)
)
|> std.array.fold_right add (encode 0)
in

Expand Down
11 changes: 5 additions & 6 deletions core/benches/mantis/deploy-example.ncl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
(import "deploy.ncl")
{
namespace = "mantis-staging",
job = "miner",
role = 'miner,
}
(import "deploy.ncl") {
namespace = "mantis-staging",
job = "miner",
role = 'miner,
}
11 changes: 5 additions & 6 deletions core/benches/mantis/deploy.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ fun vars =>
namespace = vars.namespace,
datacenters
| Array (
lib.contracts.OneOf
[
"eu-central-1",
"us-east-2",
"eu-west-2"
]
lib.contracts.OneOf [
"eu-central-1",
"us-east-2",
"eu-west-2"
]
)
| default
= ["eu-central-1", "us-east-2"],
Expand Down
32 changes: 14 additions & 18 deletions core/benches/mantis/lib.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@
contracts = {
AllOf = fun contracts label value =>
std.array.fold_right
(
fun c acc =>
c
label
acc
(fun c acc =>
c
label
acc
)
contracts
value,
Dummy = fun label value => value,
OneOf = fun values =>
std.contract.from_predicate
(
fun value =>
std.array.elem
value
values
),
std.contract.from_predicate (fun value =>
std.array.elem
value
values
),
Nullable = fun ctr label value =>
if value == null then
null
Expand All @@ -40,12 +37,11 @@
std.contract.blame_with_message "not a string" label,
PseudoOr = fun alts label value =>
std.array.fold_right
(
fun ctr rest =>
if ctr.pred value then
ctr.contract value
else
rest
(fun ctr rest =>
if ctr.pred value then
ctr.contract value
else
rest
)
(std.contract.blame_with_message "no alternative matched" label),
OrableFromPred : (Dyn -> Bool) -> { pred : Dyn -> Bool, contract : Dyn -> Dyn -> Dyn },
Expand Down
Loading

0 comments on commit c587d3a

Please sign in to comment.