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]
|
*optional dictionary entries*:[^not-ideal-optional-encoding]
|
||||||
|
|
||||||
MyDict = {a: int, b: string} & @c MaybeC .
|
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
|
It is not yet clear whether they pull their weight. In particular, the
|
||||||
semantics of serializing a value defined by intersection are not
|
semantics of serializing a value defined by intersection are not
|
||||||
completely clear.
|
completely clear.
|
||||||
|
|
||||||
[^not-ideal-optional-encoding]: This encoding is not ideal. Given a
|
[^not-ideal-optional-encoding]: This encoding is not ideal. It passes
|
||||||
term `{a: 1, b: "", c: sym}`, it will yield a `present` result,
|
responsibility for checking for invalid inputs up to the user,
|
||||||
and given `{a: 1, b: ""}`, will yield an `absent` result; but
|
rather than handling it completely at the Schema layer.
|
||||||
`absent` will also result from `{a: 1, b: "", c: "notasymbol"}`.
|
|
||||||
|
|
||||||
### Patterns.
|
### Patterns.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue