Created
August 8, 2018 08:49
-
-
Save Octachron/ca5bc810452640c7b3f5cbc929661027 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
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