Skip to content

Commit f8395de

Browse files
authored
Merge pull request #127 from mbarbin/rework-ppx-deps
Rework ppx deps
2 parents bf25d6e + a69dd67 commit f8395de

File tree

104 files changed

+1018
-1673
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1018
-1673
lines changed

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
"cmdlang",
1414
"cmdliner",
1515
"Codeberg",
16+
"creat",
1617
"criss-cross",
1718
"decr",
1819
"dedup",
1920
"diataxis",
21+
"downto",
2022
"dunolint",
2123
"Dynable",
2224
"endline",
@@ -72,12 +74,15 @@
7274
"stdlib",
7375
"subdir",
7476
"subrepo",
77+
"sunsetting",
7578
"textf",
79+
"trunc",
7680
"uncapitalize",
7781
"volgo",
7882
"WEXITED",
7983
"worktree",
8084
"worktrees",
85+
"wronly",
8186
"WSIGNALED",
8287
"WSTOPPED",
8388
"Zanuda"

NOTICE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ This notice file contains more details, as well as document the organization of
1616

1717
- **NOTICE.md** (this file) documents the project licensing.
1818

19+
## Third party licenses
20+
21+
Under `third-party-license/` we include license of software used as vendored code.
22+
1923
## A note about Eio-process
2024

2125
To spawn processes in `Eio` and collect their output we've copied some code from the [Eio_process](https://github.com/mbarbin/eio-process) project. The `Eio_process` project is released under `MIT`.

dune-project

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,8 @@
7272
(>= 0.0.16))
7373
(pplumbing-pp-tty
7474
(>= 0.0.16))
75-
(ppx_compare
76-
(>= v0.17))
77-
(ppx_enumerate
78-
(>= v0.17))
7975
(ppx_hash
8076
(>= v0.17))
81-
(ppx_here
82-
(>= v0.17))
83-
(ppx_let
84-
(>= v0.17))
8577
(ppx_sexp_conv
8678
(>= v0.17))
8779
(ppx_sexp_value
@@ -287,8 +279,6 @@
287279
(depends
288280
(ocaml
289281
(>= 5.2))
290-
(base
291-
(>= v0.17))
292282
(eio
293283
(>= 1.0))
294284
(fpath
@@ -301,22 +291,6 @@
301291
(>= 0.0.16))
302292
(pplumbing-pp-tty
303293
(>= 0.0.16))
304-
(ppx_compare
305-
(>= v0.17))
306-
(ppx_enumerate
307-
(>= v0.17))
308-
(ppx_hash
309-
(>= v0.17))
310-
(ppx_here
311-
(>= v0.17))
312-
(ppx_let
313-
(>= v0.17))
314-
(ppx_sexp_conv
315-
(>= v0.17))
316-
(ppx_sexp_value
317-
(>= v0.17))
318-
(ppxlib
319-
(>= 0.33))
320294
(volgo
321295
(= :version))))
322296

@@ -348,8 +322,6 @@
348322
(>= 1.0))
349323
(eio_main
350324
(>= 1.0))
351-
(expect_test_helpers_core
352-
(>= v0.17))
353325
(fpath
354326
(>= 0.7.3))
355327
(fpath-base
@@ -362,34 +334,18 @@
362334
(>= 0.0.16))
363335
(pplumbing-pp-tty
364336
(>= 0.0.16))
365-
(ppx_compare
366-
(>= v0.17))
367-
(ppx_enumerate
368-
(>= v0.17))
369337
(ppx_expect
370338
(>= v0.17))
371339
(ppx_hash
372340
(>= v0.17))
373-
(ppx_here
374-
(>= v0.17))
375-
(ppx_let
376-
(>= v0.17))
377-
(ppx_sexp_conv
378-
(>= v0.17))
379-
(ppx_sexp_message
380-
(>= v0.17))
381341
(ppx_sexp_value
382342
(>= v0.17))
383343
(ppxlib
384344
(>= 0.33))
385345
(re
386346
(>= 1.8.0))
387-
(sexp_pretty
388-
(>= v0.17))
389347
(spawn
390348
(>= v0.17))
391-
(stdio
392-
(>= v0.17))
393349
(vcs-test-helpers
394350
(= :version))
395351
(volgo

dunolint

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@
5656
(preprocess
5757
(pps
5858
(or
59-
(pp ppx_compare)
60-
(pp ppx_enumerate)
6159
(pp ppx_sexp_conv)))))
6260
(enforce
6361
(dune
@@ -69,16 +67,13 @@
6967
(equals force))
7068
(applies_to driver)))))))))
7169

72-
;; With the exceptions of two libraries we made a deliberate effort not to
73-
;; depend on ppx except in dev mode for the user facing libraries in this
74-
;; project. Let's enforce this going forward.
70+
;; With the exception of one library we made a deliberate effort not to depend
71+
;; on ppx except in tests. Let's enforce this going forward.
7572

7673
(rule
7774
(cond
7875
((path
79-
(or
80-
(glob src/volgo-base/*)
81-
(glob src/vcs-test-helpers/*)))
76+
(glob src/volgo-base/*))
8277
return)
8378
((path
8479
(glob src/**))

example/dune

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,13 @@
1515
-open
1616
Pplumbing_err
1717
-open
18-
Expect_test_helpers_base
19-
-open
2018
Volgo_base
2119
-open
2220
Volgo_stdlib)
2321
(libraries
2422
base
2523
eio
2624
eio_main
27-
expect_test_helpers_core.expect_test_helpers_base
2825
fpath
2926
fpath-sexp0
3027
pp
@@ -40,13 +37,4 @@
4037
(lint
4138
(pps ppx_js_style -allow-let-operators -check-doc-comments))
4239
(preprocess
43-
(pps
44-
-unused-code-warnings=force
45-
ppx_compare
46-
ppx_enumerate
47-
ppx_expect
48-
ppx_hash
49-
ppx_here
50-
ppx_let
51-
ppx_sexp_conv
52-
ppx_sexp_value)))
40+
(pps ppx_expect ppx_sexp_value)))

example/hello_git_cli.ml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,14 @@ let%expect_test "hello cli" =
6767
its output, and how to do this with the non-raising API of Vcs. *)
6868
let head_rev =
6969
Vcs.Or_error.git vcs ~repo_root ~args:[ "rev-parse"; "HEAD" ] ~f:(fun output ->
70-
let%bind.Or_error stdout = Vcs.Git.Or_error.exit0_and_stdout output in
70+
let ( let* ) x f = Or_error.bind x ~f in
71+
let* stdout = Vcs.Git.Or_error.exit0_and_stdout output in
7172
match Vcs.Rev.of_string (String.strip stdout) with
7273
| Ok _ as ok -> ok
7374
| Error (`Msg _) -> assert false)
7475
|> Or_error.ok_exn
7576
in
76-
require_equal [%here] (module Vcs.Rev) rev head_rev;
77+
require_equal (module Vcs.Rev) rev head_rev;
7778
[%expect {||}];
7879
(* Let's do one with [Vcs.Result.git]. *)
7980
let abbrev_head =
@@ -301,8 +302,8 @@ let%expect_test "hello cli" =
301302
|}];
302303
(* However when your handler [f] raises, the function will raise too, and you
303304
won't get the context in this case. *)
304-
require_does_raise [%here] (fun () : string Or_error.t -> abbrev_ref "/bogus");
305-
[%expect {| (Failure "Unexpected error code") |}];
305+
require_does_raise (fun () : string Or_error.t -> abbrev_ref "/bogus");
306+
[%expect {| Failure("Unexpected error code") |}];
306307
(* If you use a raising handler [f], you probably meant to use [Vcs.git]. *)
307308
let abbrev_ref ?(repo_root = repo_root) ref_ =
308309
Vcs.git

src/stdlib/dune

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
-warn-error
99
+a
1010
-open
11+
Fpath_sexp0
12+
-open
1113
Sexplib0
1214
-open
1315
Sexplib0.Sexp_conv)
14-
(libraries dyn ordering pp sexplib0)
16+
(libraries dyn fpath-sexp0 ordering pp sexplib0)
1517
(modules
1618
(:standard \ stdlib_compat4xx stdlib_compat5xx))
1719
(instrumentation

src/stdlib/dyn0.ml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
(*******************************************************************************)
2+
(* Volgo - a Versatile OCaml Library for Git Operations *)
3+
(* Copyright (C) 2024-2025 Mathieu Barbin <mathieu.barbin@gmail.com> *)
4+
(* *)
5+
(* This file is part of Volgo. *)
6+
(* *)
7+
(* Volgo is free software; you can redistribute it and/or modify it under *)
8+
(* the terms of the GNU Lesser General Public License as published by the *)
9+
(* Free Software Foundation either version 3 of the License, or any later *)
10+
(* version, with the LGPL-3.0 Linking Exception. *)
11+
(* *)
12+
(* Volgo is distributed in the hope that it will be useful, but WITHOUT ANY *)
13+
(* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *)
14+
(* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License and *)
15+
(* the file `NOTICE.md` at the root of this repository for more details. *)
16+
(* *)
17+
(* You should have received a copy of the GNU Lesser General Public License *)
18+
(* and the LGPL-3.0 Linking Exception along with this library. If not, see *)
19+
(* <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively. *)
20+
(*******************************************************************************)
21+
22+
include Dyn
23+
24+
let inline_record cons fields = Dyn.variant cons [ Dyn.record fields ]
25+
26+
let to_sexp =
27+
let module Sexp = Sexplib0.Sexp in
28+
let module S = Sexplib0.Sexp_conv in
29+
let rec aux (dyn : Dyn.t) : Sexp.t =
30+
match[@coverage off] dyn with
31+
| Opaque -> Atom "<opaque>"
32+
| Unit -> List []
33+
| Int i -> S.sexp_of_int i
34+
| Int32 i -> S.sexp_of_int32 i
35+
| Record fields ->
36+
List (List.map (fun (field, t) -> Sexp.List [ Atom field; aux t ]) fields)
37+
| Variant (v, args) ->
38+
(* Special pretty print of variants holding records. *)
39+
(match args with
40+
| [] -> Atom v
41+
| [ Record fields ] ->
42+
List
43+
(Atom v :: List.map (fun (field, t) -> Sexp.List [ Atom field; aux t ]) fields)
44+
| _ -> List (Atom v :: List.map aux args))
45+
| Bool b -> S.sexp_of_bool b
46+
| String a -> S.sexp_of_string a
47+
| Bytes a -> S.sexp_of_bytes a
48+
| Int64 i -> S.sexp_of_int64 i
49+
| Nativeint i -> S.sexp_of_nativeint i
50+
| Char c -> S.sexp_of_char c
51+
| Float f -> S.sexp_of_float f
52+
| Option o -> S.sexp_of_option aux o
53+
| List l -> S.sexp_of_list aux l
54+
| Array a -> S.sexp_of_array aux a
55+
| Tuple t -> List (List.map aux t)
56+
| Map m -> List (List.map (fun (k, v) -> Sexp.List [ aux k; aux v ]) m)
57+
| Set s -> List (List.map aux s)
58+
in
59+
aux
60+
;;
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
(*_ <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively. *)
2020
(*_******************************************************************************)
2121

22-
val require : bool -> unit
23-
val require_does_raise : (unit -> 'a) -> unit
24-
val require_equal : (module With_equal_and_dyn.S with type t = 'a) -> 'a -> 'a -> unit
22+
include module type of struct
23+
include Dyn
24+
end
25+
26+
val inline_record : string -> (string * Dyn.t) list -> Dyn.t
27+
val to_sexp : Dyn.t -> Sexplib0.Sexp.t

0 commit comments

Comments
 (0)