Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
The most common structural approach is row polymorphism. OCaml has row polymorphic objects and Purescript has proper row polymorphic records. In row polymorphism, you have fields, and then a variable that's "the rest of the record". This provides you type the ability to extend a record with more fields, e.g. some fun x -> {x with f1 = 0, f2 = 'a'} could have some type like {x..} -> {f1 : int, f2 : char | x..}, where x.. denotes the row polymorphic variable. So this is a simple system that gives you fully structural records (e.g. the type is the fields that exist) and a way to type single inheritance, with full type inference. For the dual (polymorphic variants), the same applies (and single inherence corresponds to wildcard matching in this case).