Skip to content

Instantly share code, notes, and snippets.

@avsm
Created June 16, 2009 08:57
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 avsm/130604 to your computer and use it in GitHub Desktop.
Save avsm/130604 to your computer and use it in GitHub Desktop.
module Int = struct
type t = int
let compare : int -> int -> int = compare
end
module M = Map.Make(Int)
type +'a elt
type 'a map = 'a elt M.t
let addA (x : 'a) (m : [> `A of 'a] map) =
M.add (Obj.magic `A) (Obj.magic x) m
let addB (x : 'a) (m : [> `B of 'a] map) =
M.add (Obj.magic `B) (Obj.magic x) m
let getA (m : [> `A of 'a] map) : 'a =
Obj.magic (M.find (Obj.magic `A) m)
let getB (m : [> `B of 'a] map) : 'a =
Obj.magic (M.find (Obj.magic `B) m)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment