melange-community / melange-community/jsonkit
PPX: Support open variants
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 24
- Forks
- 7
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 5
Description
Sometimes there are type definitions like this:
type status = [> `Foo | `Bar ]
let handle_status (status : status) : string =
match status with
| `Foo -> "It's Foo!"
| `Bar -> "It's Bar!"
| _ -> "Unknown status."
This is useful because this code is "future compatible", meaning a server could add new cases without the client crashing, or the other way around.
Would be nice to support it in melange-json PPX.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the melange-json PPX entry points and the existing handling for variant type definitions. Use the open-variant example in this issue to understand the expected behavior, then inspect related tests or add coverage for known and unknown constructors. Done means the PPX supports encoding and decoding the open variant without breaking the fallback case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100