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

Antiquoted (Embedded Expression)

Embedded expression inside a string. Constructor of Antiquoted.

Definition

Antiquoted Expr

Fields

FieldTypeDescription
contentsExprThe embedded expression to evaluate and interpolate

Description

Antiquoted represents an ${...} expression inside a string. The contained Expr is evaluated and its result is converted to a string for interpolation.

Nix Source ↔ AST

# Nix
"hello ${name}"

# AST (part of DoubleQuoted contents)
{
  "tag": "Antiquoted",
  "contents": { "tag": "Sym", "contents": "name" }
}

Complex Antiquotation

# Nix
"${if cond then "yes" else "no"}"

# AST
{
  "tag": "Antiquoted",
  "contents": {
    "tag": "If",
    "cond": { "tag": "Sym", "contents": "cond" },
    "thenExpr": { "tag": "Str", ... },
    "elseExpr": { "tag": "Str", ... }
  }
}

Nix Library Access

syntax.mkAntiquoted (syntax.mkSym "name")
syntax.mkAntiquoted (syntax.mkIf cond thenExpr elseExpr)