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

List

Definition

List [Expr]

Fields

FieldTypeDescription
contents[Expr]List of element expressions

Nix Source ↔ AST

# Nix
[ 1 2 3 ]

# AST
{
  "tag": "List",
  "contents": [
    { "tag": "Constant", "contents": { "tag": "Int", "contents": 1 } },
    { "tag": "Constant", "contents": { "tag": "Int", "contents": 2 } },
    { "tag": "Constant", "contents": { "tag": "Int", "contents": 3 } }
  ]
}
# Nix
[ (x + 1) (y * 2) ]

# AST
{
  "tag": "List",
  "contents": [
    { "tag": "Binary", "op": "+", "left": { "tag": "Sym", "contents": "x" }, "right": { "tag": "Constant", "contents": { "tag": "Int", "contents": 1 } } },
    { "tag": "Binary", "op": "*", "left": { "tag": "Sym", "contents": "y" }, "right": { "tag": "Constant", "contents": { "tag": "Int", "contents": 2 } } }
  ]
}

Nix Library Access

syntax.mkList [syntax.mkInt 1, syntax.mkInt 2, syntax.mkInt 3]