append([1,2], [3,4]) fromMaybe(1, just(2)) cons(1, cons(2, nil()))
Function and production application
Functions and productions are invoked with identical syntax, which is similar to C/Java’s (i.e. uncurried):
<Expr> ( <Expr> ( , <Expr> ) * )
Example: invoking the
substringfunction, with three arguments.
substring(1, 5, "/path/file")Example: passing
fooas a parameter to either
b, depending on the value of
(if cond then a else b)(foo)Example: constructing trees (given suitable productions
Note that production application necessarily produces the undecorated type of the nonterminal it constructs. (See Decorated vs Undecorated for more on the distinction between decorated and undecorated.)
Missing arguments replaced by underscores will result in a partially-applied function.
map(add(3,_), [1,2]) = [add(3,1), add(3,2)] fun(_,_) = fun
Arguments supplied in a partial application are only evaluated once, so any expensive computation will be reused by the other applications of the same resulting function value.