I copied Enforcing invariants in Scala datatypes from my GitHub to my blog, it's quite interesting. [permlink]