We need some way to explicitly unwrap nominal types, in the places it's allowed, but we also need to infer the common case. Hmmm.
Basically the problem as it stands is we have nominal types and structural types, and doing
foo.bar
takes a structural type. So you need to dofoo$.bar
to say "find the type offoo
, and if it's aNamed
type look it up and make sure it resolves to a structural type." So we just need to make it do the lookup automatically when possible. Which then kinda folds into "do we have visibility permissions on type fields in general", which is really a good idea we should do, but is more work I don't want to do yet.
Ironically it appears that ML modules' "sealing" operator is exactly this same problem, it takes a structural type and turns it into a nominal type with a particular signature. IMO ML's style of doing that is also something I have never ever wanted. Rust-style public/private visibility is way easier to think about. Chapter 1 of Dreyer's thesis, "The design space of ML modules", is a good intro to this. ML's transparent/sealed/translucent approach is just a generally weird and janky way of achieving this afaict.