Skip to content

Instantly share code, notes, and snippets.

@Octachron
Created August 8, 2018 08:49
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 Octachron/ca5bc810452640c7b3f5cbc929661027 to your computer and use it in GitHub Desktop.
Save Octachron/ca5bc810452640c7b3f5cbc929661027 to your computer and use it in GitHub Desktop.
module type showable = sig
type t
val show: t -> string
end
(** Typeclass emulation *)
let show (type a) (module M: showable with type t = a) x = M.show x
(** Or with a type abbreviation *)
type 'a showable = (module showable with type t = 'a)
let show (type a) ((module M):a showable) x = M.show x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment