module type EltSig = sig type elt val compare : elt -> elt -> int end module type SetSig = sig type elt type t val create : unit -> t val mem : elt -> t -> bool val insert : elt -> t -> t val delete : elt -> t -> t end module MakeSplaySet (Elt : EltSig) = struct (* Same type of elements *) type elt = Elt.elt (* Splay trees *) type tree = Leaf | Node of tree * elt * tree (* Have to use a reference cell to save result of splay *) type t = tree ref (* Splay operation *) let rec splay x = function Leaf -> Leaf | Node (left, y, right) -> ... (* Membership *) let mem x s = let s' = splay x !s in let found = (* check if x is the root *) in s := s'; found ... end