Closed kentookura closed 3 months ago
(My apologies for the late reply, I was on holidays!)
This is a bit hard to reproduce on my end, do you have instructions for how /tmp/irmin
was created?
The error seems to be coming from your Rep.Tree
encoding/decoding functions rather than from Irmin itself (but Irmin or Repr could do a better job at explaining the issue). Tree.fold
needs to decode the values and it seems that the decoding function can't read what was encoded on disk. The Jsonm error is because Repr chooses this as the default encoding for all the record/variant
that you defined... but that should be fine, however your Asai range
definition looks suspicious! :)
Could you try recreating your /tmp/irmin
repo (which is likely wrongly encoded?) and rerunning your Tree.fold
test with the following definitions for Asai ranges in lib/core/Rep.ml
?
(* dune
(library
(name Core)
(preprocess (pps ppx_deriving.show ppx_irmin))
^^^^^^^^^ add this
... *)
(** Reps of Asai types *)
type string_source = Asai.Range.string_source = {
title : string option;
content : string;
}
[@@deriving irmin]
type source = [ `File of string | `String of string_source ] [@@deriving irmin]
type position = Asai.Range.position = {
source : source;
offset : int;
start_of_line : int;
line_num : int;
}
[@@deriving irmin]
type view = [ `Range of position * position | `End_of_file of position ]
[@@deriving irmin]
let range : Range.t ty =
Repr.map view_t
(function
| `Range range -> Asai.Range.make range
| `End_of_file pos -> Asai.Range.eof pos)
Asai.Range.view
(This might not the full fix as I'm not exactly sure what went wrong! Happy to take a deeper look if I can reproduce your /tmp/irmin
:) )
No worries :)
The test succeeds after I deleted the git repository. I suppose the error arose because the repo persisted while I was messing around with the representations, so an encoding error makes sense.
Thanks for your tips re. the asai types!
The following code from https://github.com/kentookura/ocaml-forester/blob/main/test/store.ml
raises the error
I am quite baffled by this, is this a bug?
The perhaps confusingly named
Rep.Tree
is a custom content type defined in this fileThe end goal is to write a function analogous to https://github.com/kentookura/ocaml-forester/blob/main/bin/forester/Process.ml which takes a git remote as an argument.