summaryrefslogtreecommitdiff
path: root/utils/src/main.rs
diff options
context:
space:
mode:
authorstuebinm2021-04-12 17:11:14 +0200
committerstuebinm2021-04-12 17:11:14 +0200
commitd3607cf2c5f06f95a7309df5dfb5167cac5d45c1 (patch)
tree110716cfdd7748fafe9d58597db67f4da8e91c84 /utils/src/main.rs
parent6b892239f80e8523e02d7348e5483e9a7aea58ee (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/src/main.rs')
-rw-r--r--utils/src/main.rs8
1 files changed, 6 insertions, 2 deletions
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>()
{