• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mbarbin / crs / 274

21 Dec 2025 08:55PM UTC coverage: 98.221% (-1.8%) from 100.0%
274

Pull #103

github

web-flow
Merge 20d267c28 into 84c356b9d
Pull Request #103: Initiate project stdlib

1 of 34 new or added lines in 3 files covered. (2.94%)

1822 of 1855 relevant lines covered (98.22%)

145.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/stdlib/dyn0.ml
1
(********************************************************************************)
2
(*  crs - A tool for managing code review comments embedded in source code      *)
3
(*  Copyright (C) 2024-2025 Mathieu Barbin <mathieu.barbin@gmail.com>           *)
4
(*                                                                              *)
5
(*  This file is part of crs.                                                   *)
6
(*                                                                              *)
7
(*  crs is free software; you can redistribute it and/or modify it under the    *)
8
(*  terms of the GNU Lesser General Public License as published by the Free     *)
9
(*  Software Foundation either version 3 of the License, or any later version,  *)
10
(*  with the LGPL-3.0 Linking Exception.                                        *)
11
(*                                                                              *)
12
(*  crs 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

NEW
24
let inline_record cons fields = Dyn.variant cons [ Dyn.record fields ]
×
25

26
module type Stringable_S = sig
27
  type t
28

29
  val to_string : t -> string
30
end
31

32
let stringable (type a) (module M : Stringable_S with type t = a) (a : a) =
NEW
33
  Dyn.string (M.to_string a)
×
34
;;
35

36
let to_sexp =
37
  let module Sexp = Sexplib0.Sexp in
38
  let module S = Sexplib0.Sexp_conv in
39
  let rec aux : Dyn.t -> Sexp.t = function
NEW
40
    | Opaque -> Atom "<opaque>"
×
NEW
41
    | Unit -> List []
×
NEW
42
    | Int i -> S.sexp_of_int i
×
NEW
43
    | Int32 i -> S.sexp_of_int32 i
×
NEW
44
    | Record fields ->
×
NEW
45
      List (List.map (fun (field, t) -> Sexp.List [ Atom field; aux t ]) fields)
×
NEW
46
    | Variant (v, args) ->
×
47
      (* Special pretty print of variants holding records. *)
48
      (match args with
NEW
49
       | [] -> Atom v
×
NEW
50
       | [ Record fields ] ->
×
51
         List
NEW
52
           (Atom v :: List.map (fun (field, t) -> Sexp.List [ Atom field; aux t ]) fields)
×
NEW
53
       | _ -> List (Atom v :: List.map aux args))
×
NEW
54
    | Bool b -> S.sexp_of_bool b
×
NEW
55
    | String a -> S.sexp_of_string a
×
NEW
56
    | Bytes a -> S.sexp_of_bytes a
×
NEW
57
    | Int64 i -> S.sexp_of_int64 i
×
NEW
58
    | Nativeint i -> S.sexp_of_nativeint i
×
NEW
59
    | Char c -> S.sexp_of_char c
×
NEW
60
    | Float f -> S.sexp_of_float f
×
NEW
61
    | Option o -> S.sexp_of_option aux o
×
NEW
62
    | List l -> S.sexp_of_list aux l
×
NEW
63
    | Array a -> S.sexp_of_array aux a
×
NEW
64
    | Tuple t -> List (List.map aux t)
×
NEW
65
    | Map m -> List (List.map (fun (k, v) -> Sexp.List [ aux k; aux v ]) m)
×
NEW
66
    | Set s -> List (List.map aux s)
×
67
  in
68
  aux
69
;;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc