3 ms·
That's no difference than using newtype structs. If you remove the extra layer you are left with `string` for both of them. > The difference is that happens in
by SkiFire13 1y ago
That's no difference than using newtype structs. If you remove the extra layer you are left with `string` for both of them.
> The difference is that happens in the domain layer instead of the type layer
This view greatly reduces the usefulness of the type layer though, as that's the only automated tool that can help the domain layer with handling cases like this.
- b_e_n_t_o_n 1y agoIt's not really automated though, it's just another layer of code written by a human, prone to the same types of human error.
- lmm 1y agoBugs in the typechecker are rare (it's widely exercised if the language is at all popular) and generally fixed quickly. If you have an expression of type A you can be pretty confident you're getting a value that's passed through a constructor for type A. Can a human encode something different by that than what they intended to encode? Certainly. But it's got the highest cost-benefit of any approach to double-checking your code I've found.
- b_e_n_t_o_n 1y agoThat's not what I mean. It's trivial to encode your types in such a way that it incorrectly implements domain logic and there is no meta-meta language enforcing correctness there.
- lmm 1y agoHow so? To the extent that you use your types with your code, getting your types wrong will lead to either type errors in correct code (in which case you notice and fix them) or overly loose types that will allow incorrect code to pass (in which case you don't get an actual bug unless you make a corresponding mistake in your code).