You can get that code accepted in Haskell today (or even in H98 except for the r.value
: use value r
instead). You need
data Tree a
= Nil
| Node (Node' a)
data Node' a = MkNode{ value :: a, left :: Tree a, right :: Tree a }
IOW, just as with purescript, nest an extra constructor to express the field names. You might even be able to use the auxiliary Node'
within other data types; in effect re-using the field names.
So your ‘Alternative front end’ could support some syntactic sugar to make those decls less verbose.
There are good reasons to introduce free-standing first-class records/global field labels into a Haskell, but merely to avoid partial access is not one of them: I suspect the nested-constructor here will be just annoying enough people will define direct extractor functions – and you’re back to partiality.