SHARE
TWEET

Untitled

a guest Feb 18th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top