Guest User

Untitled

a guest
Feb 18th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. let revapply x f = f x
  2.  
  3. module Contravariant : sig
  4. type -'a t
  5. val create : unit -> [< `Foo] t
  6. end = struct
  7. type 'a t = unit
  8. let create () = ()
  9. end
  10.  
  11. module M : sig
  12. val int_to_string : [ `Bar of int ] -> string
  13. end = struct
  14. let int_to_string x =
  15. let x =
  16. revapply x (fun (`Bar int) -> (`Bar int), Contravariant.create ())
  17. in
  18. revapply x (fun ((`Bar int), _) -> (int : string))
  19. end
  20.  
  21. let () = Printf.printf "%s" (M.int_to_string (`Bar 0))
Add Comment
Please, Sign In to add comment