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
open Core
open! Import
open Types.Kind
module Node = Types.Node
type 'a t = 'a Types.Freeze.t =
{ main : 'a Node.t
; child : 'a Node.t
; only_freeze_when : 'a -> bool
}
[@@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 _ -> ()
| Freeze t' -> assert (phys_equal t t')
| _ -> assert false))
~child:ignore
~only_freeze_when:ignore)
;;