package crdt-ml

  1. Overview
  2. Docs
CRDTs - Conflict-Free Replicated Data Types for OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

v0.10.0.tar.gz
sha256=c9be2ec006cd4f65e6a9bddbcedf024f876134afc1ddf4fb689dd0167de25b73
md5=b8337dcb24a3220a3c35bd5bae5c8f12

doc/src/crdt_mutable/mutable_types.ml.html

Source file mutable_types.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
(** This module contains all mutable CRDT types, as well as some type
    properties that CRDT state must satisfy. *)


(** Comparable types. All elements in a set must satisfy this property.

    Same as the built-in [Set.OrderedType], this type includes a [t] and a
    [compare : t -> t -> int] function. See [Pervasives.compare] *)
module type Comparable = sig
  include Set.OrderedType
end


(** Mergeable types. All CRDTs satisfy this property. *)
module type Mergeable = sig

  (** Type of mergeable elements. *)
  type t

  (** Create a new mergeable element. *)
  val make : unit -> t

  (** [merge a b] will merge the state of [b] with the one from [a].
      Updates [a]. *)
  val merge : t -> t -> unit
end


(** Vector Clock and increment-only counter types. Supports merging and
    incrementing. The [elt] type must be supplied when including. *)
module type IVector = sig
  include Mergeable

  (** Type of the contents of an [IVector] *)
  type elt

  (** [make_in_range n] creates a new [IVector] of size ranging from [0] to [n].
      being [n] greater than 0 and smaller than 2^30.

      When merging two CRDTs of different sizes, the smaller one grows and pads
      the remaining space with zeros. *)
  val make_in_range : int -> t

  (** [query t] returns the raw state of [t] *)
  val query : t -> elt

  (** [incr t] increments the position associated with the [numsite] of [t].
      See {!module:M_IntVector} for more information on [numsites]. *)
  val incr : t -> unit
end


(** Increment / decrement counter type. Supports merging, incrementing and
    decrementing.

    The [elt] type (included from [IVector] must be supplied when including). *)
module type DCounter = sig
  include IVector

  (** [decr t] decrements the position associated with the [numsite] of [t].
      See {!module:M_IntVector} for more information on [numsites]. *)
  val decr : t -> unit
end


(** Grow-Only set type. Supports merging, adding and lookup operations. *)
module type GSet = sig
  include Mergeable

  (** Type of the contents of [GSet] *)
  type elt

  (** [add el t] adds [el] in-place to [t]. *)
  val add : elt -> t -> unit

  (** [value t] gets the raw state of [t]. *)
  val value : t -> elt list

  (** [lookup el t] returns true if [el] is in [t]. *)
  val lookup : elt -> t -> bool
end


(** Add and remove set type. Supports merging, adding and lookup operations. *)
module type RSet = sig
  include GSet

  (** [remove el t] removes [el] from [t] only if [el] is in [t].
      Does nothing otherwise. *)
  val remove : elt -> t -> unit
end
OCaml

Innovation. Community. Security.