package ppx_hardcaml

  1. Overview
  2. Docs
Rewrite OCaml records for use as Hardcaml Interfaces

Install

Dune Dependency

Authors

Maintainers

Sources

v0.17.0.tar.gz
sha256=e4ea96d3edd794a1e3128b9c42eb97da41c95c78371caa1e9cd6842244766e1c

doc/src/ppx_hardcaml.runtime/ppx_hardcaml_runtime.ml.html

Source file ppx_hardcaml_runtime.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
33
open Base

module Array = struct
  include Array

  let for_ length ~f =
    for i = 0 to length - 1 do
      f i
    done
  ;;
end

module Int = Int
module Interface = Hardcaml.Interface
module List = List

let concat = String.concat

let option_map2_exn a b ~f =
  match a, b with
  | None, None -> None
  | Some a, Some b -> Some (f a b)
  | _, _ ->
    raise_s [%message "Option.map2 expects either both to be Some, or both to be None!"]
;;

let option_iter2_exn a b ~f =
  match a, b with
  | None, None -> ()
  | Some a, Some b -> f a b
  | _, _ ->
    raise_s [%message "Option.map2 expects either both to be Some, or both to be None!"]
;;
OCaml

Innovation. Community. Security.