diff options
author | stuebinm | 2021-04-12 17:11:14 +0200 |
---|---|---|
committer | stuebinm | 2021-04-12 17:11:14 +0200 |
commit | d3607cf2c5f06f95a7309df5dfb5167cac5d45c1 (patch) | |
tree | 110716cfdd7748fafe9d58597db67f4da8e91c84 /utils | |
parent | 6b892239f80e8523e02d7348e5483e9a7aea58ee (diff) |
utils: use dhall substitutes for config typesdhall-substitutes
this uses my own version of dhall_rust [1], which has actual support for
adding in new types in rust code, which are derived via serde, instead
of just gluing in extra code for every file that is read in (in
particular, this results in actually useful error messages).
Diffstat (limited to 'utils')
-rw-r--r-- | utils/Cargo.lock | 38 | ||||
-rw-r--r-- | utils/Cargo.toml | 3 | ||||
-rw-r--r-- | utils/src/main.rs | 8 |
3 files changed, 28 insertions, 21 deletions
diff --git a/utils/Cargo.lock b/utils/Cargo.lock index 244d1f1..2cfbeb3 100644 --- a/utils/Cargo.lock +++ b/utils/Cargo.lock @@ -12,9 +12,19 @@ dependencies = [ [[package]] name = "abnf" -version = "0.6.1" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76d5f963d2236fd5701b660a9733bd22a5be300267955c71fa03bdf75ecb30b5" +dependencies = [ + "abnf-core", + "nom", +] + +[[package]] +name = "abnf-core" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47feb9fbcef700639ef28e04ca2a87eab8161a01a075ee227b15c90143805462" +checksum = "137c894fdb05ad3feb514cec800945cfebbb6435c73f9c2097b953e44a106273" dependencies = [ "nom", ] @@ -22,8 +32,6 @@ dependencies = [ [[package]] name = "abnf_to_pest" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "372baaa5d3a422d8816b513bcdb2c120078c8614f7ecbcc3baf34a1634bbbe2e" dependencies = [ "abnf", "indexmap", @@ -341,9 +349,7 @@ dependencies = [ [[package]] name = "dhall" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0dc4d9d9848124c8c10f24e3696f86d5249d7d2dca8ca0556cff10f001d51e8" +version = "0.10.1" dependencies = [ "abnf_to_pest", "annotate-snippets", @@ -366,11 +372,8 @@ dependencies = [ [[package]] name = "dhall_proc_macros" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf6cff1e2ddd03851652e0cde982b01dc877c9fc9da9ba25ad4241a151945f09" +version = "0.5.1" dependencies = [ - "itertools", "proc-macro2", "quote", "syn", @@ -1267,10 +1270,11 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] name = "pretty" -version = "0.5.2" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f60c0d9f6fc88ecdd245d90c1920ff76a430ab34303fc778d33b1d0a4c3bf6d3" +checksum = "ad9940b913ee56ddd94aec2d3cd179dd47068236f42a1a6415ccf9d880ce2a61" dependencies = [ + "arrayvec", "typed-arena", ] @@ -1627,9 +1631,7 @@ dependencies = [ [[package]] name = "serde_dhall" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e01dfb806cc18b2cc347254781948862dba85e6fc2cf300b6cb321fa8fed9137" +version = "0.10.1" dependencies = [ "dhall", "dhall_proc_macros", @@ -1952,9 +1954,9 @@ dependencies = [ [[package]] name = "typed-arena" -version = "1.7.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9b2228007eba4120145f785df0f6c92ea538f5a3635a612ecf4e334c8c1446d" +checksum = "0685c84d5d54d1c26f7d3eb96cd41550adb97baed141a761cf335d3d33bcd0ae" [[package]] name = "typenum" diff --git a/utils/Cargo.toml b/utils/Cargo.toml index e959f55..a254855 100644 --- a/utils/Cargo.toml +++ b/utils/Cargo.toml @@ -8,7 +8,8 @@ edition = "2018" [dependencies] serde = { version = "1.0", features = [ "derive" ] } -serde_dhall = "0.10.0" +#serde_dhall = "0.10.0" +serde_dhall = { path = "../../playground/dhall-rust/serde_dhall" } serde_json = "1.0.64" age = "0.5.1" structopt = "0.3.21" diff --git a/utils/src/main.rs b/utils/src/main.rs index 4428ac3..ea267d8 100644 --- a/utils/src/main.rs +++ b/utils/src/main.rs @@ -64,13 +64,17 @@ fn main () { // imported: just wrap our input code into a dhall "let"-statement. // Probably doesn't scale very vell, though ... let code = format!( - "let Question = {} \nlet Answers = {} \nlet Lang = {}\nin {}", + "let Question = {} \nlet Lang = {}\nin {}", Question::static_type(), - AnswerSpace::static_type(), Lang::static_type(), config_file ); match serde_dhall::from_str(&code) + .substitute_names(vec![ + ("Question".to_string(),Question::static_type()), + ("Answers".to_string(), AnswerSpace::static_type()), + ("Lang".to_string(), Lang::static_type()) + ].iter().cloned().collect()) .static_type_annotation() .parse::<Survey>() { |