Use a custom type as key in a Map

Say I have a type SpecialKey.t

How can I build a Map using SpecialKey.t as key ?
What I am currently doing is using Map.String and adding a layer on top that serializes/deserializes SpecialKey.t .
Is there a way to build a Map with a key of any type ?

many thanks

Just found a solution

module IntCmp = Belt.Id.MakeComparable({
  type t = SpecialKey.t
  let cmp = (a, b) => Pervasives.compare(a, b)
})

let m = Belt.Map.make(~id=module(IntCmp))

let _ = Belt.Map.set(m, SpecialKey.make("myKey"), "myValue")