melange-community / melange-community/jsonkit

PPX: Support open variants

Open
#40 4 comments 1 reaction 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.