I’ve come across
let cast x = (x :> (unit, write_error) result Lwt.t)
and this operator :>
is not in pervasives and I couldn’t find on google/don’t know how to find, because it ignores the :>
in the search.
I’ve come across
let cast x = (x :> (unit, write_error) result Lwt.t)
and this operator :>
is not in pervasives and I couldn’t find on google/don’t know how to find, because it ignores the :>
in the search.
This is a explicit type coercion from a subtype to a supertype. See for instance https://ocaml.org/releases/4.10/htmlman/objectexamples.html#s:using-coercions for more explanations .
Another example of :>
being used for upcasting: https://ocaml.org/releases/4.10/htmlman/privatetypes.html#ss:private-types-abbrev
And it also works for upcasting values of polymorphic variants:
type t = [`t]
type u = [t | `u]
let t: t = `t
let u: u = (t :> u)