I’d like to strengthen the typing discipline of an extensible variant the way we can do it for polymorphic variants. That is via a type annotation.
I believe this is not possible (and suspect it may never be since extensions may not be unique a given structure). But did I maybe miss something ?
More precisely in the to_string
function below I’d like to add an annotation that indicates me that B
is unhandled.
type t = ..
module M = struct
type t += A | B
end
let to_string v = match v with
| M.A -> "A"
| _ -> "Unknown"