I’m probably not the first to do this. I wrote an ...
# arrow
e
I’m probably not the first to do this. I wrote an article on how to make invalid domain states unrepresentable using Kotlin/Arrow. Critical feedback encouraged: Article: https://dev.to/edreyer/making-illegal-states-unrepresentable-in-kotlin-2k6l corresponding repo: https://github.com/edreyer/safe-domain
y
You keep saying:
Another hidden trap in this method is that if a new enum is ever added, there are no compile time errors
But that's not true because
when
explicitly does that lol
e
Ah right. Those are exhaustive as well. I’ll update
f
captain obvious chiming in to say be careful about adding catchall elses to whens as that kind of defeats the purpose (because then, when new types are added, the compiler won't scream, it will just give them catchall treatment)
💯 1
e
It would be awesome to have the compiler warn you about that.
m
FYI the article you link about rich errors is really misleading since its full of what i assume are AI hallucinations claiming that rich errors are released and currently usable with a compiler opt-in and explaining how they work despite not being implemented. I’d just swap that link for the rich error KEEP instead
👍 1