Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Binary (Binary Operation)

Definition

Binary { op :: Text, left :: Expr, right :: Expr }

Fields

FieldTypeDescription
opTextOperator symbol (e.g., +, ==, &&)
leftExprLeft operand
rightExprRight operand

Supported Operators

See Operators for the full list of binary operators.

Nix Source ↔ AST

# Nix
x + y

# AST
{
  "tag": "Binary",
  "op": "+",
  "left": { "tag": "Sym", "contents": "x" },
  "right": { "tag": "Sym", "contents": "y" }
}
# Nix
{ a = 1; } // { b = 2; }

# AST
{
  "tag": "Binary",
  "op": "//",
  "left": { "tag": "Set", "recursive": false, "bindings": [...] },
  "right": { "tag": "Set", "recursive": false, "bindings": [...] }
}

Nix Library Access

syntax.mkBinary "+" (syntax.mkSym "x") (syntax.mkSym "y")
syntax.mkBinary "//" set1 set2