Skip to content

Instantly share code, notes, and snippets.

@vendethiel
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vendethiel/c643a3e3b2af4ebef4d2 to your computer and use it in GitHub Desktop.
Save vendethiel/c643a3e3b2af4ebef4d2 to your computer and use it in GitHub Desktop.
import @ from "contracts.js";
macro fun {
rule {
$name:ident ($contract ...) { $body ... }
} => {
@ $contract ...
function $name () {
return (function {
$body ...
}).apply(this, arguments);
}
}
}
export fun;
fun getMul ((Num) -> (Num) -> Num) {
3 => (x) => x * 10,
x => (x) => x * 2
};
console.log(getMul(3)(4));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment