Coder Social home page Coder Social logo

Comments (2)

art-w avatar art-w commented on June 12, 2024

(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 :) )

from irmin.

kentookura avatar kentookura commented on June 12, 2024

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!

from irmin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.