package provider

  1. Overview
  2. Docs
Dynamic Dispatch with Traits

Install

Dune Dependency

Authors

Maintainers

Sources

provider-0.0.11.tbz
sha256=80e346ccde7dbf39796c3140f914641713c445ccae0183ac2948e3feb18099f3
sha512=6e7ab4734add6543498cc7d4364a4c257c63dfd4c809e798857eec7b151778c4c307901571fb1bc05f2493af3c024efbfada21e98bc9b8d758e6d9a4b613f34f

README.md.html

provider

Introduction

Provider is an OCaml library for creating Traits and Interfaces. It allows you to define the functionality needed by a library without committing to a specific implementation.

In essence, Provider handles dynamic dispatch, where the target of a function call is not known until runtime. This is particularly useful in situations where there are multiple ways to provide a certain functionality, and the choice of provider is determined by the end user.

Documentation

Published here.

Rationale

The rationale for this design is detailed in the Eio documentation.

Motivation

The Provider library started as an experimental project that extracted a pattern featured in the Eio project. The goal was to make this pattern reusable in other projects.

We then went on to use Provider as building block for the parametrization of the Vcs project.

Implementation

At its core, a provider is 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.

Acknowledgements

We're very thankful to:

  • The Eio developers for their work on the Eio project and for the documentation they published on the rationale for the design of the Eio.Resource module, which was the foundation of the Provider project.

  • The diataxis approach to technical documentation, which we use as inspiration to structure our doc.

OCaml

Innovation. Community. Security.