Created
July 26, 2015 10:23
-
-
Save gsg/d9787afcb2d54f486a56 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module type ToStr = sig | |
type t | |
val to_string : t -> string | |
end | |
module Str (T:ToStr) = struct | |
let stringify t = T.to_string t | |
end | |
let to_string (type t) (module M : ToStr with type t = t) (x : t) = | |
M.to_string x | |
module Int = struct | |
type t = int | |
let to_string = string_of_int | |
end | |
let _ = to_string (module Int) 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment