From 5fded03fa40194fb4f1ef63ae26e962fa7ac1db3 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Thu, 30 Sep 2021 14:46:35 +0200 Subject: [PATCH] Alternative encoding of optional values in preserves-schema.md --- preserves-schema.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/preserves-schema.md b/preserves-schema.md index 9194f48..f32a696 100644 --- a/preserves-schema.md +++ b/preserves-schema.md @@ -182,16 +182,15 @@ Intersections are an experimental feature. They can be used to express *optional dictionary entries*:[^not-ideal-optional-encoding] MyDict = {a: int, b: string} & @c MaybeC . - MaybeC = @present {c: symbol} / @absent {} . + MaybeC = @present {c: symbol} / @invalid {c: any} / @absent {} . It is not yet clear whether they pull their weight. In particular, the semantics of serializing a value defined by intersection are not completely clear. -[^not-ideal-optional-encoding]: This encoding is not ideal. Given a - term `{a: 1, b: "", c: sym}`, it will yield a `present` result, - and given `{a: 1, b: ""}`, will yield an `absent` result; but - `absent` will also result from `{a: 1, b: "", c: "notasymbol"}`. +[^not-ideal-optional-encoding]: This encoding is not ideal. It passes + responsibility for checking for invalid inputs up to the user, + rather than handling it completely at the Schema layer. ### Patterns.