Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type foo = [`Foo]
- [@@deriving show]
- type foobar = [ foo | `Bar ]
- module M = struct
- let do_stuff_with_foo (param: foo) =
- Printf.printf "foo: %s" (show_foo param);
- param
- let do_stuff (param: [> foo] as 'res): 'res =
- let res: 'res =
- match param with
- | `Foo as f -> begin
- let foo' = do_stuff_with_foo f in
- (foo' :> 'res)
- end
- | _ as other -> (other :> 'res)
- in
- res
- end
- let main () =
- let bar = `Bar in
- M.do_stuff bar
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement