Unary (Unary Operation)
Definition
Unary { op :: Text, arg :: Expr }
Fields
| Field | Type | Description |
|---|---|---|
op | Text | Operator symbol (- or !) |
arg | Expr | Operand 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")