Functions
Functions are written with arrow syntax only.
add = (a: Number, b: Number): Number => a + bCore rules
- the
functionkeyword is not supported - functions are first-class values
- closures are supported
- functions may be pure or effectful
- the compiler infers whether a function is pure or effectful
Block-bodied functions
greet = (name: String): String => { message = 'hello ' + name message}The final expression in the block becomes the result. There is no return keyword.
Closures
makeAdder = (x: Number) => (y: Number): Number => x + y
add5 = makeAdder(5)result = add5(3)Practical note
Draft 0.1 expects explicit parameter annotations in many places, especially for public APIs. Local return types may often be inferred, but exported functions should usually keep return types explicit.
Comparison to JavaScript
If you already prefer arrow functions in JS or TS, the surface will feel familiar. The bigger shift is that arrows are not one option among many; they are the whole function model.