And the earlier paper “A Polymorphic Type System for Extensible Records and Variants” https://web.cecs.pdx.edu/~mpj/pubs/96-3.pdf Row types are magically good: they serve either records or variants (aka sum types aka enums) equally well and both polymorphically. They’re duals. Here’s a diagram.
Construction Inspection
Records {x:1} : {x:Int} r.x — r : {x:Int|r}
[closed] [open; note the row variable r]
Variants ‘Just 1 : case v of ‘Just 0 -> ...
[open; note the row var v] v :
[closed]
Neither have to be declared ahead of time, making them a perfect fit in the balance between play and serious work on my programming language.
I love polymorphic records/variants. Variants particularly are amazing for error propagation. Records of course are useful in many of the same places tuples and structs are. The main reluctance I have is whether to allow duplicate entries in records. If you allow them, many things become much easier, but they make records inherently ordered when they weren’t previously
Comments (192) 77 threads
Show all comments
Showing thread 7 of 77
And the earlier paper “A Polymorphic Type System for Extensible Records and Variants” https://web.cecs.pdx.edu/~mpj/pubs/96-3.pdf
Neither have to be declared ahead of time, making them a perfect fit in the balance between play and serious work on my programming language.Row types are magically good: they serve either records or variants (aka sum types aka enums) equally well and both polymorphically. They’re duals. Here’s a diagram.
https://www.unisonweb.org/ ?