Caqti_eio has a function which needs a parameter of type
type stdenv = <
net : [`Generic] Eio.Net.ty Eio.Std.r;
clock : float Eio.Time.clock_ty Eio.Std.r;
mono_clock : Eio.Time.Mono.ty Eio.Std.r;
>
If I feed it with a Caqti_eio.stdenv given by Eio_main.run, I have the error:
File "main.ml", line 9, characters 47-53:
9 | Caqti_eio.with_connection ~stdenv
^^^^^^
Error: This expression has type Eio_unix.Stdenv.base
but an expression was expected of type Caqti_eio.stdenv
The second object type has no method backend_id
I do understand that the object I give implements to many methods (backend_id is one of them). On most languages, there is an issue when there is not enough methods.
Is there a simple way to have a an object which match the type (just the 3 needed methods) based on stdenv:Eio_unix.Stdenv.base.
I have tried to patch caqtiand add a .. to tolerate other methods, but this doesn’t compile anymore:
65 | type stdenv = <
66 | net : [`Generic] Eio.Net.ty Eio.Std.r;
67 | clock : float Eio.Time.clock_ty Eio.Std.r;
68 | mono_clock : Eio.Time.Mono.ty Eio.Std.r;
69 | ..
70 | >
Error: A type variable is unbound in this type declaration.
In type
< clock : float Eio.Time.clock_ty Eio.Std.r;
mono_clock : Eio.Time.Mono.ty Eio.Std.r;
net : [ `Generic ] Eio.Net.ty Eio.Std.r; .. >
as 'a the variable 'a is unbound
It’s because Caqti_eio.with_connection’s signature requires something of type Caqti_eio.stdenv rather than <Caqti_eio.stdenv; .. >. You could work around it by putting this at the start:
module Caqti_eio = struct
include Caqti_eio
let with_connection ~stdenv uri fn =
with_connection ~stdenv:(stdenv :> stdenv) uri fn
end
See the Passing env section of the README for more on this.