package provider
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=5115476c5d4d08b19c867806b291ce1d509c6e61e99d7a2d457bde9422503c0b
sha512=28d8b65af3263227ff09faa774caca6874016043b6d643da5fd8d0b649151facf3439c92e72795fc78b0a8bdd79f2e4e457f967e44c6f275480a0ec29264b6a0
Description
Published: 11 Mar 2024
README
provider
Introduction
The provider
library is an experimental project that extracts and generalizes a pattern used in the Eio project. The goal is to make this pattern reusable in other projects.
The pattern involves using a "provider" construct that implements a set of methods that a library typically needs to provide certain functionality to a client. This allows for manipulating values that behave like objects, without using OCaml's built-in object system.
Rationale
The rationale for this design is detailed in the Eio documentation.
In essence, it provides a way to handle dynamic dispatch, where the target of a function call is not known until runtime. This is particularly useful in situations where there are many ways to provide a certain functionality, and the choice of provider is determined by the user at runtime.
Implementation
At its core, a provider is just a pair consisting of an internal state and a virtual-table of first-class modules operating on that state. This allows dynamic dispatch, but for example doesn't include open recursion or inheritance in its execution model. This design offers an interesting balance between object-oriented and modular programming.
Experimental Status
Please note that this library is still considered experimental. The aim is to gain experience and feedback regarding whether this pattern can have larger applications outside of the scope of Eio.
License
This project is licensed under the ISC license, the same as the original Eio project.
Code documentation
The code documentation of the latest release is built with odoc
and published to GitHub
pages here.
Dependencies (7)
-
ppx_sexp_value
>= "v0.16"
-
ppx_sexp_conv
>= "v0.16"
-
ppx_hash
>= "v0.16"
-
ppx_compare
>= "v0.16"
-
base
>= "v0.16"
-
ocaml
>= "5.1"
-
dune
>= "3.14"
Dev Dependencies (3)
-
odoc
with-doc
-
ppx_js_style
dev & >= "v0.16"
-
bisect_ppx
dev & >= "2.8.3"
Used by
None
Conflicts
None