package incremental

  1. Overview
  2. Docs

Source file alarm_value.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
open Core_kernel
open! Import

module Action = struct
  type t = Types.Alarm_value.Action.t =
    | At of At.t
    | At_intervals of At_intervals.t
    | Snapshot : _ Snapshot.t -> t
    | Step_function : _ Step_function.t -> t
  [@@deriving sexp_of]

  let invariant = function
    | At at -> At.invariant at
    | At_intervals at_intervals -> At_intervals.invariant at_intervals
    | Snapshot snapshot -> Snapshot.invariant ignore snapshot
    | Step_function step_function -> Step_function.invariant ignore step_function
  ;;
end

type t = Types.Alarm_value.t =
  { action :
      Action.t
  (* [next_fired] singly links all alarm values that fire during a single call to
     [advance_clock]. *)
  ; mutable next_fired : t Uopt.t sexp_opaque
  }
[@@deriving fields, sexp_of]

let invariant t =
  Invariant.invariant [%here] t [%sexp_of: t] (fun () ->
    let check f = Invariant.check_field t f in
    Fields.iter ~action:(check Action.invariant) ~next_fired:ignore)
;;

let create action = { action; next_fired = Uopt.none }
OCaml

Innovation. Community. Security.