Created
April 13, 2021 18:06
-
-
Save EduardoRFS/1a7ab01c459b322e5535114a9271ca78 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 Show = sig | |
type t | |
val show: t -> string | |
end | |
let show (module S: Show) v = S.show v | |
module Show_option (S: Show) = struct | |
type t = S.t option | |
let show v = | |
match v with | |
| None -> "None" | |
| Some v -> Printf.sprintf "(Some %s)" (S.show v) | |
end | |
let x = show ( | |
if Random.float(1.0) > 0.01 then | |
(module Show_option(struct | |
type t = int | |
let show = Printf.sprintf "%d" | |
end)) | |
else | |
(module Show_option(struct | |
type t = int | |
let show v = Printf.sprintf "%d" (v - 1) | |
end)) | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment