-
-
Save yrashk/6233141df17bfe2811460a92a0f8bd19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Traits | |
module type I = sig | |
include PartialEq.T | |
include PartialOrd.T | |
end | |
(* Admittedly, a bit wordy *) | |
let test (type a) | |
(module M : I | |
with type PartialEq.t = a | |
and type PartialEq.rhs = a | |
and type PartialOrd.t = a | |
and type PartialOrd.rhs = a) x y = | |
PartialOrd.partial_cmp (module M) x y | |
(* Can be used to provide multiple traits through a single module, | |
* we don't need to know which function is being used (eq? partial_cmp?) *) | |
let _ = test (module Int) 1 2;; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment