Last active
August 29, 2015 14:25
-
-
Save Drup/88c91344f5cfb6a7c35b to your computer and use it in GitHub Desktop.
Something something eqtype
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
type (_,_) eq = Refl : ('a,'a) eq | |
module type EqTag = sig | |
type 'a t | |
val create : unit -> 'a t | |
val equal : 'a t -> 'b t -> ('a, 'b) eq option | |
end | |
module M : EqTag = struct | |
type 'a w = .. | |
module type S = sig | |
type a | |
type 'a w += T : a w | |
end | |
type 'a t = (module S with type a = 'a) | |
let create (type a') () : a' t = | |
let module M = struct | |
type a = a' | |
type 'a w += T : a w | |
end | |
in (module M : S with type a = a') | |
let equal (type a) (type b) ((module A) : a t) ((module B) : b t) : (a, b) eq option = | |
match A.T with | |
| B.T -> Some Refl | |
| _ -> None | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment