Wafl Home

Program Structure Tutorial

Functional Operator Syntax

The usage of higher order functions and partial application assumes that used abstractions are functions and not operators. To make the usage of operators in these contexts possible, Wafl allows special functional syntax for operators. Operators may be used as functions if referenced using the name operator<op>.

Even if operator - is used as both unary and binary operator, when it is used in functional form it is used exclusively as binary function.

Source code:

{#
operator+(_,5)(10),
apply( operator+(_,5), 10),
apply( operator+(_,5), _)(10),
apply2( operator+, _, _ )(5,10),
apply2(_,5,10)(operator+)
#}
where{
    apply(f,x) = f(x);
    apply2(f,x,y) = f(x,y);
}

Result:

{# 15, 15, 15, 15, 15 #}

 

Table of Contents

Let's Start

Program Structure

Primitive Data Types

List

Tuple

Record

HTML

Command Line Interpreter

Using Web Servers

Syntax

Examples

Tips

The most of examples evaluates with both command line and Web server Wafl interpreters. If any example is based on specific features of an interpreter, it is explicitly annotated.