What language that has static types doesn't have the func, params, and return type in one line?
add1 = map (+1)
OTOH they also split the signature and function "header" so that you don't need to remove the "noise" to get the bare signature e.g. add1 :: (Num a) => [a] -> [a]
add1 = map (+1)Normal C style declaration
int foo() { return 2; }
Trailing return type. Useful when the return type depends on the parameter types, or is inside the namespace of the function auto foo() -> int { return 2; }
Automated type deduction. Increasingly the choice when possible auto foo() { return 2; } int foo(x,y)
{
return baz(x,y);
}
bar(x,y,z)
short x;
int z;
{
return x+y+z;
}
baz(x,y,z)
{
return 42;
}