dinosaure / dinosaure/buffet

Talk about interface

Open
#1 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
OCaml
Stars
6
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Idea behind `buffet` is to provide a safe interface to manipulate buffer (`string`, `bytes` and `bigstring`). `buffet` has different levels about interface:

* `Buffet0` this is the foundation for the next level, it's just a bunch of `external`, `bigstringaf` and nothing else. We provide _getter_ and _setter_ on `char`, `int`, `int32` and `int64` (_little-endian_ and _big-endian_) like what `bigstringaf` does already.
* `Buffet1`: we start with a GADT to keep _kind_ of buffer. We merge all on a `type 'kind tag` type which is used to dispatch functions to the good implementation. `Buffet1.get bytes` will call `Bytes.get`.
* `Buffet2`: we continue with a GADT but put some information like if we have a _read_, _write_ or _async_ (leave the global lock) capability on one of kinds of buffer. Limitation on GADT can not permit us to use a sub-typing (like we do in a common way with polymorphic variant). In this implementation, we lint some pattern-matching like the dispatcher on the `set`/`unsafe_set` function which don't allow a `String` kind for example.
* `Buffet3`: we put a new information, an offset and a length with `type ('a, 'k) Buffet1.access` which check at any step if slice is available on the buffer `'k`. I decided to return a `result` type, `Ok` if we have an access on the buffer `'k` with a specific slice or an error, you can see the function `commit` or `with_off` and `with_len` with the _bind_ operator `>>=`.
* `Buffet4`: again, a GADT to hidden/pack `type ('a, 'k) Buffet3.meta` with 'k. Then, we check with GADT if we are allowed to `read`/`write` and so on on it with reflection. In other case, we raise an exception.

I'm currently on a new implementation of `Buffet2` which use polymorphic variant. Then, we need to do some benchmark to compare them and see which is the best:
* discard `String` case
* or raise an exception

If you have any advise, I will happy to discuss about that (@hannesm, @samoht, @cfcs, @let-def, @Drup).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.