Skip to content

Instantly share code, notes, and snippets.

@eduardoleon
Created July 11, 2016 16:11
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 eduardoleon/f9289748c5d1fde76afb773d225d2ae2 to your computer and use it in GitHub Desktop.
Save eduardoleon/f9289748c5d1fde76afb773d225d2ae2 to your computer and use it in GitHub Desktop.
Modular type classes are defined by elaboration
using IntOrd
(* `Heap` elaborates to `Heap(IntOrd)`,
* so `val xs : Heap(IntOrd).t` *)
val xs = Heap.fromList [1,2,3];
(* shadows previous `using` declaration *)
using Backwards(IntOrd)
(* `Heap` elaborates to `Heap(Backwards(IntOrd))`,
* so `val ys : Heap(Backwards(IntOrd)).t` *)
val ys = Heap.fromList [1,2,3];
(* type error: can't unify `xs`'s type `Heap(IntOrd).t`
* with expected type `Heap(Backwards(IntOrd)).t` *)
val zs = Heap.merge (xs, ys)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment