Skip to content

Design: auto-folding Some(None) → None #32

Description

@artem-zinnatullin

@weefbellington from our team at Lyft has been working on serializing/deserializing Koptional values in JSON and we've stuck for some time discussing following use case:

Optional<Optional<T>> (and other levels of direct nesting).

This use case is weird on its own, however Koptional does nothing to prevent it (neither does Arrow btw), so it's a valid state for Koptional 1.x.

Right now we've decided to serialize/deserialize without enhancing JSON with additional metadata, which results in following convention for JSON:

Some(None) → None

However, that creates difference between how we represent Some(None) in-memory vs JSON.


With all that in mind, I'd like to raise a discussion about this and propose following changeset for Koptional 2.x:

  • Hide Some constructor
  • Expose a function named Some(): Optional<T> that would return None for Some(None)

cc @ming13 @dmitry-novikov @nostra13 @AlecStrong @Egorand

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions