Hacker News new | ask | show | jobs
by turdprincess 1009 days ago
I feel like a common refactor in a large project might be a complete redefinition of a model layer exposed via a bunch of structs.

How does immutability or patter matching save me from runtime errors caused by changing the fields or types inside a struct? Wouldn’t the pattern matching just fail and go down the wrong code path since it was matching for the old pattern?

I feel like immutability is great, pattern matching is great, but static typing is also great and there is no reason why it can’t happily live along side the other two.

1 comments

In this case, the question is moot.

Elixir structs have compile-time checks: https://elixir-lang.org/getting-started/structs.html