# Basic Syntax

Those who have seen an ML-based language before will find Kuljet's expression syntax familiar ground, and can probably skip to the next section.

## Literals

Expressions can be literals, such as `"string"`

or `123`

.

Construct lists square brackets, like `[ 1, 2, 3 ]`

.

Construct records with curly brackets, like `{ a = 1, b = 2 }`

.

P.S. Access values of a record with a dot: `record.field`

.

## Function Application

Unlike C-style languages, function application does not require parentheses. Given a function `a`

which takes two integers and returns an integer (i.e. type `int -> int -> int`

), then `a 1 2`

calls that function with arguments `1`

and `2`

.

Functions are partially applied, so `a 1`

gives a function of type `int -> int`

, and `(a 1) 2`

is the same as `a 1 2`

.

Use parentheses for nested application e.g. `a (a 1 2) 2`

.

## Let

Introduce names for expressions by using `let`

.

`let <name> = <expression> in <expression>`

e.g.

`let x = 1 in x + x`

## Functions

Write functions with the `fun`

keyword:

`fun <var> -> <expression>`

You will sometimes need to provide the type of the function argument using a *type annotation*:

`fun <var>: <type> -> <expression>`

## Binary Operators

Operate on numbers with `+`

, `-`

, `*`

and `/`

.

Compare with `=`

, `<`

, `>`

, `<=`

and `>=`

.

Combine Boolean values with `and`

and `or`

.

`and (3 = 3 + 1 or 3 = 3) 1 <= 2 `

## If expression

`if`

expressions are written:

`if <condition> then <expression> else <expression>`

Unlike C-style languages, they are expressions not statements.