Skip to content

Instantly share code, notes, and snippets.

@gsg
Created July 26, 2015 10:23
Show Gist options
  • Save gsg/d9787afcb2d54f486a56 to your computer and use it in GitHub Desktop.
Save gsg/d9787afcb2d54f486a56 to your computer and use it in GitHub Desktop.
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