Advertisement
Guest User

Untitled

a guest
Sep 12th, 2014
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module type SHOW =
  2. sig
  3. type t
  4. val show : t -> string
  5. end
  6.  
  7. let print (implicit Show : SHOW) x = Show.show x
  8.  
  9. implicit module ShowInt = struct type t = int let show = string_of_int end
  10. implicit module ShowFloat = struct type t = float let show = string_of_float end
  11.  
  12. implicit functor ShowPair (Show1 : SHOW) (Show2 : SHOW) =
  13. struct
  14. type t = Show1.t * Show2.t
  15. let show (x, y) = "(" ^ Show1.show x ^ ", " ^ Show2.show y ^ ")"
  16. end
  17.  
  18. let rec grow1 : (implicit Show : SHOW) -> Show.t -> 'a =
  19. fun (implicit Show : SHOW) x -> grow1 (x, x)
  20. (*
  21. Characters 494-538:
  22. fun (implicit Show : SHOW) x -> grow1 (x, x);;
  23. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  24. Error: This expression has type (implicit Show : SHOW) -> 'b -> 'a
  25. but an expression was expected of type
  26. (implicit Show : SHOW) -> Show.t -> 'a
  27. This instance of Show.t is ambiguous:
  28. it would escape the scope of its equation
  29. *)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement