I'm so envious of this. In TypeScript I use ts-pattern and Effect Schema, and while they make this logic way nicer, it's insanely verbose and doesn't offer any of the niceties of being first class.
I've exclusively used the BEAM/Erlang target so far - but the js community within Gleam seems quite interesting.