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
- 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
- (* none of these work *)
- let rec grow_pairs (implicit Show : SHOW) x =
- grow_pairs (x, x)
- let rec grow_pairs (implicit Show : SHOW) x =
- let module Show2 = ShowPair (Show) (Show) in
- grow_pairs (implicit Show2) (x, x)
- let rec grow_pairs (type a) (implicit Show : SHOW with type t = a) (x : a) =
- let module Show2 = ShowPair (Show) (Show) in
- grow_pairs (implicit Show2) (x, x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement