Skip to content

Instantly share code, notes, and snippets.

@gsg
Created August 7, 2019 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gsg/b2c2adc5a9ffc60af5912ad02dc76d35 to your computer and use it in GitHub Desktop.
Save gsg/b2c2adc5a9ffc60af5912ad02dc76d35 to your computer and use it in GitHub Desktop.
module rec Value : sig
type t =
| Int of int
| Tbl of t ValueTbl.t
val hash : t -> int
val equal : t -> t -> bool
end = struct
type t =
| Int of int
| Tbl of t ValueTbl.t
let hash = Hashtbl.hash
let equal a b =
match a, b with
| Int x, Int y -> x = y
| Tbl x, Tbl y -> x == y
| _ -> false
end
and ValueTbl : Hashtbl.S with type key = Value.t = Hashtbl.Make (Value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment