I also witness surprising behaviour for any non-string keys with Git memory backend. See the code below. Are there any restrictions with the use of RW stores?
(* Build with
* ocamlfind ocamlc -linkpkg -package irmin.git,irmin.unix,git -o rw_test rw_test.ml
*)
let (>>=) = Lwt.bind
module Git = Irmin_git.RW(Git.Memory)
module HumInt = struct
include Tc.Int
let of_hum s =
(* Following line prints “master" *)
print_string @@ s^"\n";
int_of_string s
let to_hum = string_of_int
end
module HumString = struct
include Tc.String
let of_hum s = s
let to_hum s = s
end
(*****************************************************************************)
(* Following Fails *)
module Hum = HumInt
let key = 0
(* Following works *)
(*
module Hum = HumString
let key = "0"
*)
(*****************************************************************************)
module S = Git(Hum)(Irmin.Hash.SHA1)
module SHA1 = Irmin.Hash.SHA1
let conf = Irmin_git.config ()
let task = Irmin_unix.task
let main =
S.create conf task
>>= fun store ->
S.update (store "update") key
(SHA1.of_hum "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12")
>>= fun _ -> S.read_exn (store "read") key
>>= fun res ->
SHA1.to_hum res |> print_string;
Lwt.return ()
let () = Lwt_main.run main