September 10th, 2015
(written by lawrence krubner, however indented passages are often quotes). You can contact lawrence at: email@example.com
One very useful feature of Prismatic/schema which core.typed does not have is called coercions. With this feature you can both validate your data structure and transform it to the desired state. This is particularly useful when validating input data from a database or ring request and doing all the string->int, kebab-casing etc in one step. The net effect being much less defensive code ‘on the other side’ of the coercer since you can rely on the exact shape of the data.
By using type annotations the reliance on example-based unit testing can be deemphasized, and more focus can be put on other forms of testing. It cannot however totally replace the need for run-time checks, and features like coercers are too good to trade away for just type annotations. Luckily schemas and type annotations can co-exist in a codebase, and since Prismatic/schema definitions and type annotations are so similar you can even write your schemas once and generate the core.typed annotations from them.