Skip to content

Operators Reference

OperatorDescriptionExample
+Additiona + b
-Subtraction / negationa - b, -x
*Multiplicationa * b
/Divisiona / b
%Moduloa % b

Equality operators compile to strict equality (===, !==). Structural equality is used for == between same types.

OperatorDescriptionCompiles to
==Equal===
!=Not equal!==
<Less than<
>Greater than>
<=Less or equal<=
>=Greater or equal>=
OperatorDescriptionExample
&&Logical ANDa && b
||Logical ORa || b
!Logical NOT!a
OperatorDescriptionExample
|>Pipex |> f

The pipe operator passes the left side as the first argument to the right side. Use _ as a placeholder for non-first-argument positions.

x |> f // f(x)
x |> f(a, _) // f(a, x)
x |> f |> g // g(f(x))
x |> match { ... } // match x { ... }
OperatorDescriptionExample
?Unwrap Result/Optionexpr?

The ? operator unwraps Ok(value) or Some(value), and returns early with Err(e) or None on failure. Only valid inside functions that return Result or Option.

OperatorDescriptionExample
tryWrap unsafe npm call in Resulttry parseYaml(input)

The try operator wraps a potentially throwing npm function call in a Result<T, Error>. Required for non-trusted npm imports.

OperatorContextExample
..Record spread in constructorsUser(..existing, name: "New")
..Array rest in match patterns[first, ..rest]
...Type spread in record definitionstype B { ...A, extra: string }
1..10Range pattern in matchmatch n { 1..10 -> "small" }
OperatorContextMeaning
(x) =>Closures(x) => x + 1
.fieldDot shorthand.name (implicit field-access closure)
->Match arms, return types, function typesOk(x) -> x, fn add(a) -> number, (string) -> number
|>Pipesdata |> transform
  1. Unary: !, -
  2. Multiplicative: *, /, %
  3. Additive: +, -
  4. Comparison: <, >, <=, >=
  5. Equality: ==, !=
  6. Logical AND: &&
  7. Logical OR: ||
  8. Pipe: |>
  9. Unwrap: ?