I noticed that, among OCaml programmers I know, some of them always use polymorphic variants (variants that are not declared, prefixed with a backquote), while othe
The only reason why I use polymorphic variants in most module interfaces is to work around the naming issues of classic variants.
If the following could work, polymorphic variants would no longer be useful in a majority of cases:
type t1 = String of string | Int of int | Bool of bool | List of t1 list
type t2 = String of string | Int of int | Other
let simplify x =
match (x : t1) with
String s -> String s
| Int n -> Int n
| Bool _
| List _ -> Other
2014-02-21 Update: the code above is now valid in OCaml 4.01. Hurray!