Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const maybe = <A>(s: Schema<A>): Schema<Maybe<A>> => | ||
| new Schema(D.maybe(s.decoder), E.maybe(s.encoder)); | ||
|
|
||
| // An object field that may be absent. |
There was a problem hiding this comment.
Optional schema cannot decode its own encoded Just values
The optional schema still wires D.optional (which only accepts a raw value or undefined) to E.maybe, but E.maybe now emits { nothing: {} }/{ just: ... } objects. After this change, encoding s.optional(s.string) with Just('x') produces { just: 'x' }, which D.optional rejects because it no longer matches either branch, so the schema can no longer roundtrip even non-empty optionals. Any use of s.optional will now fail to decode values it encodes.
Useful? React with 👍 / 👎.
This PR:
Maybevalues. Previously we could not correctly encode nested maybe values (Maybe<Maybe<T>>).optionalNullableandoptionalMaybeto represent object fields that may be omitted.jsonlibrary.