Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module type SHOW =
- sig
- type t
- val show : t -> string
- end
- let print (implicit Show : SHOW) x = Show.show x
- let print2 = fun (implicit Show : SHOW) -> fun x -> print (implicit Show) x
- implicit module ShowInt =
- struct
- type t = int
- let show = string_of_int
- end
- implicit module ShowFloat =
- struct
- type t = float
- let show = string_of_float
- end
- implicit functor ShowPair (Show1 : SHOW) (Show2 : SHOW) =
- struct
- type t = Show1.t * Show2.t
- let show (x, y) = "(" ^ Show1.show x ^ ", " ^ Show2.show y ^ ")"
- end
- module ShowString_Internal =
- struct
- type t = string
- let show s = "\"" ^ String.escaped s ^ "\""
- end
- implicit module ShowString = ShowString_Internal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement