I’m trying to construct a variant type which contains a map that uses the variant type as a key.
open Base module rec T : sig type t = | Int of int | Table of t Map.M(T).t [@@deriving compare, sexp] include Comparator.S with type t := t end = struct type t = | Int of int | Table of t Map.M(T).t [@@deriving compare, sexp] include Comparator.Make(T) end include T
I’ve been using the Map module from Base, but I’m running into an error:
Error: Cannot safely evaluate the definition of the recursively-defined module T
I think this is because
Comparator.Make() creates a
val comparator : (t, comparator_witness) comparator so
T isn’t a safe module. Any ideas on how to get around this?