4 ms·
I've never read a code base where I thought the type system was doing a good job of being a DSL for describing business requirements Types are great imo for ch
by slifin 7y ago
I've never read a code base where I thought the type system was doing a good job of being a DSL for describing business requirements
Types are great imo for checking against primitives because the semantics of int string array etc are strong but most languages are encouraging wrapping up primitives in some user defined wrapper then the semantics of the wrapper are implicit, brittle and known only to the author
The semantics of your Bob class is more likely to change as it's used over many different contexts than the int type is, if the int type is being swapped out it's usually because the wrong data is being used, which is what we are using types to protect against, it's not usually because there's a problem with what int is
- syrak 7y ago> I've never read a code base where I thought the type system was doing a good job of being a DSL for describing business requirements Would refinement types help in that respect? For example, the F* language. https://www.fstar-lang.org/ https://www.fstar-lang.org/ I don't have any experience with "business" code, but my naive understanding is that application-level code is typically very monomorphic which is exactly where refinement types are useful, whereas the OP leverages polymorphism to a large extent (not necessarily), and that works well for general-purpose libraries which don't and must not care about their users' data.