Skip to content

Instantly share code, notes, and snippets.

@Octachron
Created February 7, 2017 15:57
Show Gist options
  • Save Octachron/f20e5d1a625da349dd52e08295d809fe to your computer and use it in GitHub Desktop.
Save Octachron/f20e5d1a625da349dd52e08295d809fe to your computer and use it in GitHub Desktop.
module type s = sig
type 'a t
val hash : 'a t -> int
val equal : 'a t -> 'a t -> bool
end
module Id: s = struct
type 'a t = {
id : int;
contents : 'a;
}
let hash { id; _ } = id
let equal a b = a.id = b.id
end
module Spec(T:sig type t end) =
struct
type 'a aux = T.t Id.t
type t = T.t aux
include (Id: s with type 'a t := 'a aux)
end
module H = Hashtbl.Make(Spec(struct type t = int end))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment