Created
November 27, 2014 17:31
-
-
Save gsg/0375debe0d93974c252d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module rec Value : sig | |
type t = | |
| Nil | |
| Bool of bool | |
| Float of float | |
| String of string | |
| Table of table | |
and table = { | |
id : int; | |
table : t Table.t; | |
} | |
val hash : t -> int | |
val equal : t -> t -> bool | |
val make_table : unit -> table | |
end = struct | |
type t = | |
| Nil | |
| Bool of bool | |
| Float of float | |
| String of string | |
| Table of table | |
and table = { | |
id : int; | |
table : t Table.t; | |
} | |
let hash = Hashtbl.hash | |
let equal x y = match x, y with | |
| Nil, Nil -> true | |
| Bool x, Bool y -> x = y | |
| Float x, Float y -> x = y | |
| String x, String y -> x = y | |
| Table x, Table y -> x == y | |
| _, _ -> false | |
let make_table = | |
let count = ref 0 in | |
fun () -> incr count; { id = !count; table = Table.create 4; } | |
end | |
and Table : 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