Allow additional functions in virtual library implementations
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 1.9k
- Forks
- 500
- Avg merge
- 15h 21m
- Merged PRs (30d)
- 277
Description
Desired Behavior
Virtual libraries have an interface file which implementations can implement. Currently, the implementations cannot add additional functions beyond what is defined in the virtual library interface. It would be useful for implementations to be able to add additional functions such that executables that use a particular implementation get implementation-specific functions.
Note: this is an issue created from a discussion on the #dune channel on the OCaml discord server but I thought I would open an issue to track it, thanks @rgrinberg for the initial response on there.
Example
This example arose from a desire to create a simple, JSON virtual library with Ezjsonm, Yojson and Brr.Json implementations. This would allow, for example, server-client applications that communicate using JSON to share a common library of OCaml types and JSON encoders/decoders. In the browser, the implementation can be using Brr.Json i.e. the browser JSON API which is significantly faster.
Consider the following simple interface:
type t
(** Internal JSON representation *)
val get : t -> string -> t option
(** [get t s] retrieves the value associated with [s] if [t] is a JSON object *)
All three of the implementation libraries can implement this interface perfectly fine. The issue is providing the constructor for type t. You could be very generic and just add val of_string : string -> t to the interface file but it would be nice to allow implementation-specific constructors. In particular for Brr.Json it would be good to have val of_jstr : Jstr.t -> t which can't really go into the shared virtual library interface.
Happy to look into this if I could get some pointers about where to start/if this is even possible?
Contributor guide
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 tracing how Dune handles virtual library interface files and their implementations. Use the JSON example in the issue as the behavior to investigate; done means an implementation can expose additional functions while still satisfying the shared virtual library interface.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100