forked from syndicate-lang/preserves
Alternative encoding of optional values in preserves-schema.md
This commit is contained in:
parent
0507ab2f38
commit
5fded03fa4
|
@ -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.
|
||||
|
||||
|
|
Loading…
Reference in New Issue