package core

  1. Overview
  2. Docs
Industrial strength alternative to OCaml's standard library

Install

Dune Dependency

Authors

Maintainers

Sources

v0.17.1.tar.gz
md5=743a141234e04210e295980f7a78a6d9
sha512=61b415f4fb12c78d30649fff1aabe3a475eea926ce6edb7774031f4dc7f37ea51f5d9337ead6ec73cd93da5fd1ed0f2738c210c71ebc8fe9d7f6135a06bd176f

doc/src/core/unit.ml.html

Source file unit.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
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
module Stable = struct
  open Stable_witness.Export
  open Base.Export
  open Bin_prot.Std

  module V1 = struct
    module T = struct
      type t = unit [@@deriving bin_io ~localize, compare, sexp, stable_witness]
    end

    include T
    include Comparator.Stable.V1.Make (T)

    let%expect_test _ =
      print_endline [%bin_digest: t];
      [%expect {| 86ba5df747eec837f0b391dd49f33f9e |}]
    ;;
  end

  module V2 = struct
    type t = unit [@@deriving compare, equal, sexp, stable_witness]
    type comparator_witness = V1.comparator_witness

    let comparator = V1.comparator
    let bin_name = "unit_v2"

    let __bin_read_t__ (_ : Bin_prot.Common.buf) ~pos_ref (_ : int) =
      Bin_prot.Common.raise_variant_wrong_type bin_name !pos_ref
    ;;

    let bin_read_t (_ : Bin_prot.Common.buf) ~pos_ref:(_ : int ref) = ()

    let bin_reader_t =
      { Bin_prot.Type_class.read = bin_read_t; vtag_read = __bin_read_t__ }
    ;;

    let bin_shape_t = Bin_prot.Shape.(basetype (Uuid.of_string bin_name)) []
    let bin_size_t () = 0
    let bin_size_t__local () = 0
    let bin_write_t (_ : Bin_prot.Common.buf) ~pos () = pos
    let bin_write_t__local (_ : Bin_prot.Common.buf) ~pos () = pos
    let bin_writer_t = { Bin_prot.Type_class.size = bin_size_t; write = bin_write_t }

    let bin_t =
      { Bin_prot.Type_class.shape = bin_shape_t
      ; writer = bin_writer_t
      ; reader = bin_reader_t
      }
    ;;

    let%expect_test _ =
      print_endline [%bin_digest: t];
      [%expect {| ffbd1a307a4f7ebe8023040fecebf697 |}]
    ;;
  end
end

open! Import

include
  Identifiable.Extend
    (Base.Unit)
    (struct
      type t = unit [@@deriving bin_io]
    end)

include Base.Unit

type t = unit [@@deriving typerep, bin_io ~localize]

let quickcheck_generator = Base_quickcheck.Generator.unit
let quickcheck_observer = Base_quickcheck.Observer.unit
let quickcheck_shrinker = Base_quickcheck.Shrinker.unit

module type S = sig end

type m = (module S)
OCaml

Innovation. Community. Security.