4 ms·
>Ocaml-style ad-hoc structural sums Ocaml also has ad-hoc products (objects and tuples).
by ernst_klim 9y ago
>Ocaml-style ad-hoc structural sums
Ocaml also has ad-hoc products (objects and tuples).
- wyager 9y agoBasically every language has ad-hoc products in the form of tuples. They aren’t structurally typed in ocaml, which is the interesting part. Typescript has labeled products that have similar subtyping rules to ocaml’s anonymous sum subtyping rules. Eg {x:a, y:b} < {x:a}.
- ernst_klim 9y agoObjects in OCaml are labeled products. < x:a; y:b > <: <x:a>
- wyager 9y agoAh, I did not know that. I’ve only used the {x : a} record syntax in ocaml.