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
open Core
open! Import
open Types.Kind
module Node = Types.Node
type 'a t = 'a Types.Snapshot.t =
{ main : 'a Node.t
; at : Time_ns.t
; before : 'a
; value_at : 'a Node.t
; clock : (Types.Clock.t[@sexp.opaque])
}
[@@deriving fields ~iterators:iter, sexp_of]
let invariant invariant_a t =
Invariant.invariant [%here] t [%sexp_of: _ t] (fun () ->
let check f = Invariant.check_field t f in
Fields.iter
~main:
(check (fun (main : _ Node.t) ->
assert (Scope.is_top main.created_in);
match main.kind with
| Invalid -> ()
| Const _ -> ()
| Snapshot t' -> assert (phys_equal t t')
| _ -> assert false))
~at:ignore
~before:(check invariant_a)
~value_at:ignore
~clock:ignore)
;;