Debian Codegraph @

test/override_example.ml

raw symbols SCIP
1 open Ppx_hash_lib.Std
2 open Hash.Builtin
3
4 module Barbins_example = struct
5 module X = struct
6 type t = int [@@deriving hash]
7 end
8
9 module Y = struct
10 type y = int [@@deriving hash]
11 end
12
13 module Z = struct
14 type t = int [@@deriving hash]
15 end
16
17 module Example = struct
18 module T = struct
19 type t =
20 { x : X.t
21 ; y : Y.y
22 ; z : Z.t
23 ; mutable cached : int option [@hash.ignore]
24 }
25 [@@deriving hash]
26 end
27
28 module T_type = struct
29 type t = T.t =
30 { x : X.t
31 ; y : Y.y
32 ; z : Z.t
33 ; mutable cached : int option
34 }
35 end
36
37 module Unmemoized = T
38
39 module Memoized = struct
40 include T_type
41
42 let hash t =
43 match t.cached with
44 | Some x -> x
45 | None ->
46 let cached = T.hash t in
47 (* dont use state *)
48 t.cached <- Some cached;
49 cached
50 ;;
51
52 let hash_fold_t (state : Hash.state) (t : t) = hash_fold_int state (hash t)
53
54 (* use state *)
55 end
56 end
57
58 module Client = struct
59 (* ensure overrides are typed correctly *)
60 type t1 = Example.Unmemoized.t [@@deriving hash]
61 type t3 = Example.Memoized.t [@@deriving hash]
62 end
63 end