A Dialect of CoffeeScript with contracts
contracts.coffee is a dialect of CoffeeScript with contract support.
Contracts allow you to write powerful runtime assertions about your code. Like types but less painful, like assert but more useful.
square :: (Num) -> Num square = (x) -> x * x # throws a run-time error square "a string"
Documentation, usage, and more examples: http://disnetdev.com/contracts.coffee/
Install via npm:
npm install -g contracts.coffee
Use the compiler:
coffee -c --contracts /path/to/script.coffee
An alternative to using the --contracts flag is setting this env variable:
If you are running in the browser then you'll need to load the contracts library (found in lib/contracts/contracts.js)
There is also experimental support for require.js. See here for an example.
If you are running in node.js then you'll need to install the contracts.js package
npm install contracts.js
.use(), now using