The imperative. When should you create a custom data type, as opposed to reusing pre-existing data types such as Either, Maybe or tuples? Here are some reasons you should reuse a generic type: It saves typing (both in declaration and in pattern matching), making it good for one-off affairs, It gives you a library of […]
Punning is the lowest form of humor. And an endless source of bugs. The imperative. In programming, semantically different data may have the same representation (type). Use of this data requires manually keeping track of what the extra information about the data that may be in a variable. This is dangerous when the alternative interpretation […]
The imperative. Mutable data structures with many children frequently force any given child to be associated with one given parent data structure: class DOMNode { private DOMDocument $ownerDocument; // ... public void appendNode(DOMNode n) { if (n.ownerDocument != this.ownerDocument) { throw DOMException("Cannot append node that " "does not belong to this document"); } // ... […]