In my current side project my main data structure is made out of an abstract class with two subclasses, visitor pattern based “pattern matching”, and destructuring methods which can return null. It is type safe, syntactically lightweight, its usage sites are incredibly elegant, it plays nicely with type narrowing, and it encourages a very functional style in its consumers. The internal implementation of the structure itself is verbose but completely mechanical. I love it, partially because it removes large amounts of boilerplate from the algorithms where succinctness and clarity are most important, and partially because it breaks just about every inflexible rule about how FP-oriented code should supposedly be written in a multiparadigm language. I’m absolutely going to put the whole thing in my next blog post and negative comments will become the food which nourishes me.

0

If you have a fediverse account, you can quote this note from your own instance. Search https://social.treehouse.systems/users/jnkrtech/statuses/115568907251888317 on your instance and quote it. (Note that quoting is not supported in Mastodon.)