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

Unary (Unary Operation)

Definition

Unary { op :: Text, arg :: Expr }

Fields

FieldTypeDescription
opTextOperator symbol (- or !)
argExprOperand expression

Supported Operators

See Operators for the full list of unary operators.

Nix Source ↔ AST

# Nix
-x

# AST
{
  "tag": "Unary",
  "op": "-",
  "arg": { "tag": "Sym", "contents": "x" }
}
# Nix
!cond

# AST
{
  "tag": "Unary",
  "op": "!",
  "arg": { "tag": "Sym", "contents": "cond" }
}

Nix Library Access

syntax.mkUnary "-" (syntax.mkSym "x")
syntax.mkUnary "!" (syntax.mkSym "cond")