3 ms·
If the database structure is encoded in your type system, and all your code that accesses the database (including the initial population of the database) is che
by dllthomas 14y ago
If the database structure is encoded in your type system, and all your code that accesses the database (including the initial population of the database) is checked against that encoding, the compiler can absolutely statically check the correctness of code that relies on the structure and contents of the database. Several of the mainstream Haskell database packages do this.
- drorweiss 14y agoSure, I will look at Haskell. Still, IMO this may be true in theory. In practice, most of the errors we encounter come from incomplete understanding of the input we're dealing with. These are many little rules that are very hard to formalize.
- Peaker 14y agoMost of the errors you remember encountering, I bet.
- dllthomas 14y agoIncomplete understanding of input or domain is certainly a cause of problems, and I don't know that there is a way the type system can help in the general case. With regard to databases in particular, though, it is comparatively easy to constrain things so that you don't have that problem, and enlisting the type system there makes sense. There are other areas that have useful approaches as well - consider protocol buffers, for instance. I prefer to let the type system catch what it can, and use tests for where it can't - often type info can be leveraged to help in the testing, too: I recommend checking out quickcheck if you haven't.