The easy-format package, a dependency of js_of_ocaml, still uses Jbuilder, and the author states on his GitHub profile that he no longer maintains it. Will this be an issue?

Jbuilder will be discontinued in July: https://dune.build/blog/second-step-deprecation/

The last commit to easy-format was on February 21, 2018, and the author states on his profile that he no longer maintains it, but he does not state who the current maintainers are, if any exist.

Notably, easy-format is a dependency of js_of_ocaml. I noticed it because I am using js_of_ocaml for a project, and when I built it, I saw a warning about the dependency on jbuilder. (js_of_ocaml depends on js_of_ocaml-compiler, which depends on yojson, which depends on easy-format.)

Is the fact that easy-format still depends on jbuilder and does not seem to be maintained going to be an issue?

EDIT: yojson also depends on biniou, which depends on jbuilder and is written by the same person as easy-format.

Possibly a good candidates for inclusion in community-driven GitHub’s ocaml-community organization? See the issue where it was described precisely: https://github.com/ocaml-community/meta/issues/25

I’ve mentioned my position on this previously: I would prefer we just … got rid of it. In Yojson, notably. It’s not very useful. It seems like a much better use of our time than trying to maintain it ad-ethernam.

I agree that Yojson should try and strip off this dependency. I have nothing against easy-fmt, but it’s not really necessary to pretty-print json.

I think the one useful feature in yojson’s pretty-printer which may be hard to emulate is this:

$ (echo "["; for x in $(seq 1 99); do echo "$x,"; done; echo "100]") | ydump
[
  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
  22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
  41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
  60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
  79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
  98, 99, 100
]

If you know how to do that sort of wrapping with another library that someone is willing to maintain, that’s awesome.

With containers’s CCFormat:

# open Containers;;
# Format.printf "[@[<hv>@;<0 1>@[<hov>%a@]@;<0 -1>]@." Format.(list ~sep:(return ",@ ") int) List.(1 -- 5);;
[1, 2, 3, 4, 5]
- : unit = ()
# Format.printf "[@[<hv>@;<0 1>@[<hov>%a@]@;<0 -1>]@." Format.(list ~sep:(return ",@ ") int) List.(1 -- 100);;
[
  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
  20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
  36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
  52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
  68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
  84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
  100
]
1 Like

You can do it with plain Format:

# Format.printf "[@[<hv>@;<0 1>@[<hov>%a@]@;<0 -1>]@." Format.(pp_print_list ~pp_sep:(fun ppf () -> fprintf ppf ",@ ") pp_print_int) (List.init 100 (fun i -> i));;
[
  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
  21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
  40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
  59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
  78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
  97, 98, 99
]
- : unit = ()
3 Likes

Note that this requires sniffing the subtree before printing it, since you probably don’t want this wrapping for a list of non-atoms (objects or arrays). For instance we usually don’t want that:

[
  { "x": 1, "y": true }, { "x": 2, "y": true }, { "x": 3, "y": true },
  { "x": 4, "y": true }, { "x": 5, "y": true }, { "x": 6, "y": true },
  { "x": 7, "y": true }, { "x": 8, "y": true }, { "x": 9, "y": true },
  { "x": 10, "y": true }
]

but we want this:

[
  { "x": 1, "y": true },
  { "x": 2, "y": true },
  { "x": 3, "y": true },
  { "x": 4, "y": true },
  { "x": 5, "y": true },
  { "x": 6, "y": true },
  { "x": 7, "y": true },
  { "x": 8, "y": true },
  { "x": 9, "y": true },
  { "x": 10, "y": true }
]

Anyway, the rule followed by easy-format is to do the wrapping iff all the elements of the array are atoms (possibly a mix of different kinds: null, boolean, number, or string).

I agree too, but it is not only Yojson directly. easy-format is also depended upon by biniou, another dependency of Yojson. I tried to strip out biniou but that changes the API (since bits of Biniou is exported in the signatures), so a Yojson 2 would be required. Also, I haven’t had much time in actually progressing the PR to do so. easy-format was my second thing to remove but without removing biniou it makes no difference.