Parse, don't validate

Click for: original source

Alexis King wrote this piece about his concise, simple way to explain what it means to practice type-driven design. He has now a single, snappy slogan that encapsulates what type-driven design means to him, and better yet, it’s only three words long: Parse, don’t validate.

The article then explains:

  • The essence of type-driven design
  • Turning partial functions total
  • The power of parsing
  • The danger of validation
  • Parsing, not validating, in practice

Author’s advice is to focus on the datatypes. And follow 2 simple ideas: Use a data structure that makes illegal states unrepresentable and push the burden of proof upward as far as possible, but no further. That said, it is not always easy. Excellent read!

[Read More]

Tags programming functional-programming software-architecture