Skip to content

Instantly share code, notes, and snippets.

@fogus
Forked from Chouser/mapmap.ml
Last active August 29, 2015 14:14
Show Gist options
  • Save fogus/fd07e75fa2e224128544 to your computer and use it in GitHub Desktop.
Save fogus/fd07e75fa2e224128544 to your computer and use it in GitHub Desktop.
module rec VariantMod
: sig
type t = Int of int | Map of t OrderedValMap.t
end = VariantMod
and OrderedVal
: sig
type t = VariantMod.t
val compare : t -> t -> int
end
= struct
type t = VariantMod.t
let compare = Pervasives.compare
end
and OrderedValMap
: Map.S with type key = OrderedVal.t
= Map.Make(OrderedVal)
let example_int = VariantMod.Int 42
let example_map_val = OrderedValMap.add example_int example_int OrderedValMap.empty
let example_map = VariantMod.Map example_map_val
let example_map2 = VariantMod.Map (OrderedValMap.add example_map example_map OrderedValMap.empty)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment