package ocamlformat-lib

  1. Overview
  2. Docs
OCaml Code Formatter

Install

dune-project
 Dependency

Authors

Maintainers

Sources

ocamlformat-0.29.0.tbz
sha256=dac77f0a957ae782bb4b869b07b9803a872a34f8c1eae8901b42d21b623c9db5
sha512=b4ae6fda3c28e91dc12411b577df7b216e9b1afe5887bcb9e89c158e1313dc92183c29ffb256f47f5c9384af3ac8c505ec76849b26ae950b82c9b4c21a460819

doc/src/ocamlformat-lib.odoc_parser/compat.ml.html

Source file compat.ml

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
module Option = struct
  type 'a t = 'a option = None | Some of 'a

  let is_some = function None -> false | Some _ -> true
  let value ~default = function None -> default | Some x -> x

  let join_list l =
    let rec loop acc = function
      | [] -> Some (List.rev acc)
      | Some a :: q -> loop (a :: acc) q
      | None :: _ -> None
    in
    loop [] l
end

module Char = struct
  include Char

  let equal (x : char) y = x = y
end

module String = struct
  include String

  let for_all f str =
    let rec aux i =
      if i >= String.length str then true
      else if f (String.get str i) then aux (i + 1)
      else false
    in
    aux 0
end