Skip to content

Commit

Permalink
Init description
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarbin committed Feb 22, 2024
1 parent 4bcf41b commit 703178e
Show file tree
Hide file tree
Showing 11 changed files with 128 additions and 6 deletions.
66 changes: 63 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,67 @@

[![CI Status](https://github.com/mbarbin/vcs/workflows/ci/badge.svg)](https://github.com/mbarbin/vcs/actions/workflows/ci.yml)

## Code documentation
A versatile OCaml library for Git interaction

The code documentation of the latest release is built with `odoc` and published
to `GitHub` pages [here](https://mbarbin.github.io/vcs).
## Overview

`Vcs` is an OCaml library providing a direct-style API for interacting with Git
repositories. It's designed as an "interface", or "virtual" library with the
actual implementation dynamically dispatched at runtime. This design allows for
high flexibility and adaptability to different use cases.

## Architecture

The `vcs` repository contains several components:

![Git-cli diagram](doc/diagram/gitcli.png)

- **vcs**: The main entry point of the library. Marked with a * to indicate no
runtime dependencies.
- **user-lib**: A placeholder in the diagram for any library that uses `Vcs`.
Also marked with a * to indicate no runtime dependencies.
- **executable**: A placeholder for a runtime component based on `user-lib` that
commits to a specific provider and concurrency model.
- **git-cli**: A IO-free library that parses the output of a `git` cli process.
- **vcs-git-provider**: An instantiation of `Git_cli` based on an `Eio` runtime.
- **vcs-git-blocking**: An instantiation of `Git_cli` based on the OCaml `Stdlib`.

![Stdlib diagram](doc/diagram/stdlib.png)

## Design principles

`Vcs` is designed to be backend-agnostic and concurrency-runtime independent.
It's compatible with both `Eio` and OCaml `Stdlib` runtimes. We plan to explore
the feasibility of supporting [luv](https://github.com/aantron/luv) and
[miou](https://github.com/robur-coop/miou) runtimes as separate future work.

The concurrency runtime must be compatible with program written in direct style.
Runtime based on monadic concurrent models such as `Async` and `Lwt` are
purposely left outside of the scope of this project.

## How It Works

`Vcs` is an interface composed of [Traits](doc/traits.md), each providing
different functionalities associated with Git interaction. The dynamic dispatch
implementation uses the [provider](https://github.com/mbarbin/provider) library.

## Motivation

We aim to create a highly compatible library that can serve various use cases
and foster community engagement. We also hope to gain practical experience with
the use of provider-based parametric libraries.

## Relation to ocaml-git

[ocaml-git](https://github.com/mirage/ocaml-git) is a pure OCaml implementation
of the Git format and protocol. In the `Vcs` framework, an Eio compatible
`ocaml-git` is a potential `provider` for the interface. We plan to create a
`Vcs` provider based on `ocaml-git` in the future.

![Ocaml-git diagram](doc/diagram/ocaml-git.png)

## Current Status

The project is currently in the draft stage in a private repository. We're in
the process of selecting an appropriate license and seeking preliminary
feedback.
7 changes: 7 additions & 0 deletions doc/diagram/gitcli.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
digraph G {
"vcs *" -> "user-lib *";
"user-lib *" -> "executable (eio)";
"git-cli" -> "vcs-git-provider";
eio -> "vcs-git-provider";
"vcs-git-provider" -> "executable (eio)";
}
Binary file added doc/diagram/gitcli.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions doc/diagram/ocaml-git.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
digraph G {
"vcs *" -> "user-lib *";
"user-lib *" -> "executable (eio)";
"ocaml-git-eio" -> "ocaml-git-provider";
eio -> "ocaml-git-provider";
"ocaml-git-provider" -> "executable (eio)";
}
Binary file added doc/diagram/ocaml-git.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions doc/diagram/regen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash -e

# Change the current working directory to the directory where the script is located
cd "$(dirname "$0")"

for i in `ls *.dot`; do
echo "Processing $i ..."
dot -Tpng $i -o `echo $i | sed 's/.dot/.png/'`
done
7 changes: 7 additions & 0 deletions doc/diagram/stdlib.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
digraph G {
"vcs *" -> "user-lib *";
"user-lib *" -> "executable (blocking)";
"git-cli" -> "vcs-git-blocking";
stdlib -> "vcs-git-blocking";
"vcs-git-blocking" -> "executable (blocking)";
}
Binary file added doc/diagram/stdlib.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions doc/traits.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# The Power of Traits in `Vcs`

The `Vcs` library leverages the `provider`-based parametric model to offer a
flexible and adaptable interface for Git interaction. This model, also used in
the `Eio` library (`Eio.Resource`), allows us to define small scopes of
functionality, or `Traits`, within the `Vcs` library.

## Experience with `providers`

Our use of the [provider](https://github.com/mbarbin/provider) based parametric
library in `Vcs` serves as a practical, real-world case study of this pattern.

We aim to bring this pattern to the attention of the community, fostering a
general understanding that can be applied to other projects using the same
pattern. In essence, understanding the parametrized model of `Vcs` equates to
understanding `Eio.Resource`, and vice versa.

## Granularity of the Interface via Trait Granularity

The `Trait` design of `provider` allows us to define specific and isolated
sub-functionalities within the `Vcs` library. This granularity enables different
providers to choose which `Trait` they wish to implement, offering a level of
flexibility not possible with a monolithic functor.

With `Traits`, you can select a provider with the specific set of traits you
need, without changing any other code. As explained
[here](https://mbarbin.github.io/provider/provider/Provider/Interface/index.html#type-t),
provider interfaces come with some notion of phantom types, offering additional
compiler assistance.

In summary, the use of `Traits` in `Vcs` provides a flexible, adaptable, and
granular interface for Git interaction, promoting a broader understanding and
application of the `provider`-based parametric model.
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

(package
(name vcs)
(synopsis "A collection of OCaml libraries defining interfaces and providers to interact with git repositories")
(synopsis "A versatile OCaml library for Git interaction")
(depends
(ocaml
(>= 5.1))
Expand Down
3 changes: 1 addition & 2 deletions vcs.opam
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
synopsis:
"A collection of OCaml libraries defining interfaces and providers to interact with git repositories"
synopsis: "A versatile OCaml library for Git interaction"
maintainer: ["Mathieu Barbin"]
authors: ["Mathieu Barbin"]
homepage: "https://github.com/mbarbin/vcs"
Expand Down

0 comments on commit 703178e

Please sign in to comment.