Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let revapply x f = f x
- module Contravariant : sig
- type -'a t
- val create : unit -> [< `Foo] t
- end = struct
- type 'a t = unit
- let create () = ()
- end
- module M : sig
- val int_to_string : [ `Bar of int ] -> string
- end = struct
- let int_to_string x =
- let x =
- revapply x (fun (`Bar int) -> (`Bar int), Contravariant.create ())
- in
- revapply x (fun ((`Bar int), _) -> (int : string))
- end
- let () = Printf.printf "%s" (M.int_to_string (`Bar 0))
Add Comment
Please, Sign In to add comment