gojuno / gojuno/koptional

Design: auto-folding Some(None) → None

Open
#32 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
294
Forks
22
PR merge metrics
No merged PRs in 30d

Description

@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>` (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:

```kotlin
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` that would return `None` for `Some(None)`

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.