Skip to content

Instantly share code, notes, and snippets.

@Octachron
Created April 13, 2021 17:55
Show Gist options
  • Save Octachron/552d3298b3d09671d3715f8b2f205a5e to your computer and use it in GitHub Desktop.
Save Octachron/552d3298b3d09671d3715f8b2f205a5e to your computer and use it in GitHub Desktop.
module type T = sig
type t
val x: t
val show: t -> string
end
module Int = struct
type t = int
let x = 1
let show = string_of_int
end
module String = struct
type t = string
let x = "one"
let show = Fun.id
end
let random (): (module T) =
if Random.float > 0.5 then
(module String)
else
(module Int)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment