Runtime types (and many other functional ideas)

Thanks everyone for the feedback.

I decided to take a stab at making a separate thread for the individual ideas I originally presented. I started by taking the struct idea and trying to distill it down to its core. It sort of turned into something a little different (tagged records), but it keeps many of the same benefits as the struct presented here. You can see the new thread here. The tagged record idea naturally provides the ability to have variant-like behavior without any extra work, so variants got rolled into that topic as well.

This leaves us with the type class idea. This idea seems to be the most tied to a runtime type system, and I'm not sure I would be able to separate it, also, of all of the syntax suggestions I originally gave, the type classes seemed to be the heftiest, and I'm not sure it would be able to carry its own weight. This will be something that I'll keep thinking on, but I believe this kind of polymorphism would need to be achieved in a very different way in JavaScript, and perhaps Haskell's approach isn't the best fit for JavaScript.

The runtime type system idea itself also feels like something that will likely not get very far. It certainly would be nice to have, and I would vote for it, along with the other syntax suggestions I originally gave, but it's a pretty big shift in direction for JavaScript, and I'm not sure something like that would ever get through.

1 Like