SyntaxOak Module
Types
| Type | Description |
|
Example: `as self` — the self-identifier binding at the end of an implicit constructor parameter list. |
|
|
The content from [< to >] |
|
|
Example: `[ |
|
|
A `let … and …` group of mutually recursive bindings, or a sequence of `use` bindings. |
|
|
Example: `let inline private f<'T> (x: 'T) : int = ...` — a value/function/member binding.
Covers `let`, `use`, `and`, `member`, `static member`, etc. depending on |
|
|
Example: `: int` — the explicit return type annotation on a binding (the colon token + type). |
|
|
A single link in a method-call or property-access chain (e.g. |
|
|
A single statement inside a computation-expression body.
|
|
|
Discriminated union for the three forms of constant literal in the Oak representation.
|
|
|
Example: `1.0 |
|
|
An `else if` pair — the `else` and `if` keywords are stored as separate ranges so trivia can be attached correctly. |
|
|
Example: `| Red = 0` — a single enum case declaration. |
|
|
Example: `exception MyError of string` — an exception type definition with an optional member block. |
|
|
Discriminated union of all F# expressions in the Oak intermediate representation.
Each case wraps a strongly-typed node that captures the exact sub-structure needed
for formatting. Use |
|
|
Example: `struct {| Name = "Alice"; Age = 30 |}` — an anonymous struct record expression. Extends `ExprRecordNode` by prepending the `struct` keyword. |
|
|
Example: `List.map(f)` — a qualified name (dotted identifier) applied to a single parenthesised argument |
|
|
Example: `List.map f xs` — a function applied to two or more space-separated arguments |
|
|
Example: `f(a)` — a general expression (not a simple dotted name) applied to a single parenthesised argument |
|
|
Example: `List.map (fun x -> x + 1) xs` — a function applied to zero or more prefix arguments followed by a parenthesised lambda or `function` expression as the last argument. |
|
|
Example: `[a; b; c]` for a list, `[|a; b; c|]` for an array — determined by the opening/closing tokens |
|
|
Example: `begin expr end` — explicit `begin`/`end` block delimiters (equivalent to parentheses). |
|
|
Example: `person.Address.City.ToUpper()` — a chain of dot-separated member accesses and calls |
|
|
The body of a computation expression, consisting of an ordered list of binding statements (e.g. `let! x = …`) and other expressions (e.g. `return x`, `do! f()`). |
|
|
Example: `{ let x = 1; yield x }` — an anonymous computation expression (no explicit builder name). |
|
|
A constant (literal) expression leaf node such as `42`, `"hello"`, `true`, or `3.14`. This node has no child nodes; all textual content is carried by the source range. |
|
|
Example: `arr.[i]` — indexed get using the older dot-bracket syntax (deprecated in F# 6). |
|
|
Example: `arr.[i] <- value` — indexed set using the older dot-bracket syntax (deprecated in F# 6). |
|
|
Example: `_.ToUpper()` or `_.Length` — a dot-lambda shorthand (F# 8+). `Underscore` is the `_` placeholder, `Dot` is the `.`, and `Expr` is the member access or call. |
|
|
Example: `obj.Item[key] <- value` — sets a named indexed property accessed through a dotted expression. |
|
|
Example: `obj?Property` — dynamic member access using the `?` operator. `FuncExpr` is the object; `ArgExpr` is the property name (often a string constant). |
|
|
then |
|
|
Example: `for x in xs do printfn "%A" x` — a `for … in` loop over a sequence. `IsArrow` is `true` when using arrow syntax (`for x in xs -> expr`) instead of `do`. |
|
|
Example: `for i = 1 to 10 do printfn "%d" i` or `for i = 10 downto 1 do …`. `Direction` is `true` for ascending (`to`) and `false` for descending (`downto`). |
|
|
Example: `if a then x elif b then y else z` — contains one or more `if/elif` branches and an optional `else` |
|
|
Example: `if condition then trueResult else falseResult` |
|
|
Example: `if condition then result` |
|
|
Example: `^1` or `^0` — an end-relative index expression (from-end indexer, F# 6+). |
|
|
Example: `0..10`, `..10`, `0..`, `..` — a two-part index range (used in slice expressions and list comprehensions). Either `From` or `To` (or both) may be absent, producing an open-ended range. |
|
|
Example: `xs[i]` — index access using the new F# 6+ dot-free bracket syntax. `Identifier` is the collection; `Index` is the index expression inside `[…]`. |
|
|
Example: `a + b` — a single binary infix application with two different operands or operators |
|
|
Example: `{ inherit Base(args); Field = value }` — a record with an `inherit` constructor call. |
|
|
Example: `$"hello {name}, you are {age} years old"` — an interpolated string expression. `Parts` interleaves raw string `SingleTextNode` segments with `FillExprNode` interpolation holes. |
|
|
Example: `e1 in e2` — used in query-expression `join … in …` clauses; represents the `in` operator. |
|
|
Example: `fun x y -> x + y` |
|
|
Example: `lazy computeExpensiveValue` |
|
|
Internal compiler node for static optimisation hints (library/compiler use only, not user-facing). Emits an expression with attached `StaticOptimizationConstraint` conditions. |
|
|
Example: `Module.mutableValue <- newValue` — mutation via a long (dotted) identifier. |
|
|
Example: `function | Some x -> x | None -> defaultValue` |
|
|
Example: `match x with | Some v -> v | None -> 0` |
|
|
Example: `task { … }` or `async { … }` — a named computation expression with an explicit builder. The builder expression (`Name`) precedes the braces of the computation body. |
|
|
Example: `myProp[key] <- value` — sets a named indexed property on a type. |
|
|
Example: `xs[i] arg` — an indexed expression (`xs[i]`) immediately applied to an argument. Used for cases like `arr[0] + 1` where the index result is itself called or applied. |
|
|
Example: `new StringBuilder(capacity)` |
|
|
Example: `{ new IDisposable with member _.Dispose() = () }` — an object expression that implements an interface or inherits a base class inline. |
|
|
Example: `?name` in a function call — a named optional argument passed explicitly. `IsOptional` is `true` when the `?` prefix is present; `Identifier` is the argument name. |
|
|
Example: `( * )` or `( + )` — an operator name wrapped in parentheses, used as a first-class function value. |
|
|
Example: `(fun x -> x + 1)` — a lambda expression wrapped in parentheses. Distinct from `ExprLambdaNode` in that the parens are explicit and tracked as nodes. |
|
|
Example: `(expr)` — an expression explicitly wrapped in parentheses for grouping or disambiguation. |
|
|
Example: `!x`, `-x`, `~~~x` — a prefix (unary) operator applied to an expression. |
|
|
Example: `<@ expr @>` — a typed quotation; `<@@ expr @@>` — an untyped quotation. The opening and closing tokens capture the bracket pair; `Expr` is the quoted expression. |
|
|
Abstract base for all record expression nodes, providing shared access to the braces and fields. |
|
|
Represents a record instance, parsed from both `SynExpr.Record` and `SynExpr.AnonRecd`. |
|
|
Example: `a + b + c` — a sequence of the *same* operator applied repeatedly (avoids redundant nesting) |
|
|
Example: `x <- newValue` — an imperative assignment (mutation) expression. |
|
|
A single expression prefixed by a keyword, e.g. `assert condition`, `yield value`, `return result`, `upcast expr`, `downcast expr`, `do expr`, `do! asyncExpr`, `return! asyncExpr`. `AddSpace` controls whether a space is emitted between the keyword and the expression. |
|
|
Example: `struct (a, b, c)` — a struct tuple expression. Wraps an `ExprTupleNode` and adds the `struct` keyword and a closing parenthesis. |
|
|
Example: `(^T : (member Get : unit -> int) t)` — a statically-resolved type parameter (SRTP) trait call. Invokes `MemberDefn` on value `Expr` constrained to type `Type` at compile time. |
|
|
Example: `0..2..10` — a three-part numeric range with start, step, and end values (used in slice expressions). |
|
|
Example: `try riskyOp() finally cleanup()` — a try/finally expression that always runs `FinallyExpr`. |
|
|
Example: `try riskyOp() with | :? IOException -> "IO" | ex -> sprintf "other: %O" ex` — a try/with with multiple match clauses. |
|
|
Example: `try riskyOp() with :? IOException -> "IO error"` — a try/with with exactly one match clause. Used as an optimised form when a single pattern covers all exception cases. |
|
|
Example: `(a, b, c)` — items are interleaved with comma `SingleTextNode` separators |
|
|
Example: `id |
|
|
Example: `expr : Type` (type annotation), `expr :? Type` (type test / downcast), `expr :>> Type` (upcast). `Operator` holds the specific type operator string (`:`, `:?`, `:>`, `:>>`). |
|
|
Example: `while i < 10 do printfn "%d" i; i <- i + 1` — a while loop. |
|
|
Example: `[ |
|
|
A single parameter in an `extern` binding: optional attributes, an optional type, and an optional pattern name. |
|
|
Example: `val mutable private name: int` — a field declaration inside a type definition. Used for record fields, union-case fields, and `val`-style class fields. |
|
|
An interpolated-string fill hole: an expression together with an optional format identifier (e.g., `{x:N2}`). |
|
|
A group of consecutive hash directives (e.g. `#r "..."` followed by `#load "..."`) treated as a single declaration. |
|
|
Interface implemented by all type-definition node types that carry a type name and a
member list. Used to access the common parts of a type definition (its header and
members) without matching on every |
|
|
Example: `A.B.C` or `A` — a qualified identifier (sequence of idents and dots). Used wherever a dotted name appears: module names, type names, open statements, etc. |
|
|
A single element of a dotted identifier path, either an identifier token or a dot separator.
|
|
|
The leading keyword of an `if` expression: either a simple `if` token or an `else if` pair (see |
|
|
Example: `(x: int, y: string) as self` — the primary constructor definition directly following the type name. |
|
|
Marker interface implemented by |
|
|
Discriminated union for the argument form following an |
|
|
Example: `inherit Base arg1 arg2` — inherits from a type with non-parenthesised constructor arguments. |
|
|
Example: `inherit Base(arg)` — inherits from a type with a single parenthesised constructor argument. |
|
|
Example: `inherit Base` — inherits from a type with no constructor arguments. |
|
|
Example: `inherit Base()` — inherits from a type with an explicit unit constructor. |
|
|
Example: `interface IDisposable with member _.Dispose() = ()` — an interface implementation clause inside an object expression or type definition. |
|
|
A chain link where a function is applied to a parenthesised argument, e.g. `foo(x)` in `a.foo(x).bar`. |
|
|
A chain link where a function is applied to a unit argument, e.g. `Dispose()` in `x.Dispose()`. |
|
|
Example: `| pat when guard -> body` — a single arm of a `match` or `try…with` expression. The leading bar, guard (`when` clause), and arrow are all optional depending on context. |
|
|
|
|
|
Example: `m / s` or `1 / s` (when |
|
|
Example: `m * s` or `m / s` — a binary operator expression between two unit-of-measure terms. |
|
|
Example: `(m * s)` — a parenthesised unit-of-measure expression for grouping. |
|
|
Example: `m^2` — a unit-of-measure raised to a rational power. |
|
|
Example: `m s` — a sequence of juxtaposed unit-of-measure terms (implicit multiplication). |
|
|
Discriminated union of all member definitions that can appear inside a type body.
Covers everything from |
|
|
Example: `abstract member Area: float` — an abstract member declaration specifying a name and type signature. |
|
|
Example: `member val Name = "" with get, set` — an auto-implemented property that generates a backing field automatically. |
|
|
Secondary constructor new (pat: type) = expr |
|
|
Example: `inherit Base()` — an `inherit` member declaration inside a class body that specifies the base class. |
|
|
Example: `interface IDisposable with member _.Dispose() = ()` — an `interface` implementation clause inside a class or struct definition. |
|
|
Example: `member x.Prop with get() = … and set v = …` — a property member with explicit `get` and/or `set` accessor bodies. |
|
|
Example: `abstract member Name: string with get, set` — a `val` declaration in a signature used as an abstract or interface member. |
|
|
Example: `module M = Ns.OtherModule` — a module abbreviation that creates a short alias for a qualified module. |
|
|
Each case in this DU should have a container node |
|
|
Top-level attributes with an optional `do` expression (e.g., `[ |
|
|
The header of a module or namespace declaration: optional doc, attributes, leading keyword (`module`/`namespace`), optional accessibility, optional recursive flag, and the qualified name. Example: `module rec MyApp.Utils` or `namespace global`. |
|
|
A top-level module or namespace containing an optional header and a list of declarations. Corresponds to a `SynModuleOrNamespace` in the FCS untyped AST. |
|
|
All attribute lists on a declaration: zero or more |
|
|
A node holding two or more adjacent text tokens that logically form one keyword or modifier sequence. Example: `static member` (two tokens), `abstract default` (access + keyword). |
|
|
Example: `field1 = x` — a named field–pattern pair used in union-case destructuring (e.g. `Point(x = px; y = py)`). |
|
|
Example: `-2` or `-(3/2)` — a negated rational constant used as a unit-of-measure exponent. |
|
|
Example: `module rec Utils = …` — a nested module definition (non-top-level) with its declarations. |
|
|
The core interface implemented by every node in the Oak intermediate representation.
Each node carries trivia (comments, blank lines, directives) that were attached to
it during the AST → Oak transformation, together with its source range and child nodes.
The printer reads |
|
|
Base implementation of |
|
|
|
|
|
Discriminated union for the two forms of |
|
|
A group of consecutive `open` statements (module/namespace opens and type-directed opens). |
|
|
Example: `open System.IO` — an `open` declaration that brings a module or namespace into scope by qualified name. |
|
|
Example: `open type System.Math` — an `open type` declaration that brings static members and nested types into scope. |
|
|
Example: `#r "nuget: Newtonsoft.Json"` or `#load "Utils.fs"` — a hash directive at the file level.
|
|
|
Example: `pat1 & pat2 & pat3` |
|
|
Example: `[a; b; c]` (list pattern) or `[| a; b; c |]` (array pattern) |
|
|
Example: `:? SomeType` (a type-test pattern) |
|
|
A pattern composed from a left hand-side pattern, a single text token/operator and a right hand-side pattern. Example (Or): `A | B` Example (As): `x as y` Example (ListCons): `head :: tail` |
|
|
Example: `Some x` or `MyModule.MyDU value` (a union case or long-ident pattern with optional sub-patterns) |
|
|
Example: `MyUnion(field1 = x; field2 = y)` (named field patterns on a union case) |
|
|
Example: `x` or `private x` (a simple named binding pattern) |
|
|
Example: `( * )` (operator name used as a pattern in member definitions) |
|
|
Example: `[ |
|
|
Example: `(pat)` (a parenthesised pattern) |
|
|
Example: `{ Field1 = x; Field2 = y }` (a record pattern) |
|
|
Example: `struct (a, b)` (a struct tuple pattern) |
|
|
Example: `a, b, c` (a tuple pattern) |
|
|
Discriminated union of all F# patterns in the Oak intermediate representation.
Each case wraps a strongly-typed node. Use |
|
|
A single `get` or `set` accessor body inside a `member … with get/set` property declaration. |
|
|
Discriminated union for the three forms of a rational-number exponent in a unit-of-measure
type annotation (e.g. |
|
|
Example: `(3/2)` — a rational-number exponent in a unit-of-measure power expression such as `m^(3/2)`. |
|
|
Example: `Name = expr` — a single record field assignment inside a record expression or update. |
|
|
The most fundamental leaf node — a single token of source text (keyword, operator, identifier, punctuation, etc.). Examples: `let`, `=`, `->`, `(`, `myVar`. |
|
|
A static optimisation constraint attached to an |
|
|
Example: `when 'T = int` — a static optimisation constraint that requires a type parameter to equal a specific type constructor. |
|
|
A leaf node holding a plain string value with no sub-nodes (e.g. a verbatim string token or source text fragment). |
|
|
The kind of non-code content that can be attached to a node as trivia.
Single-line and line-after-source-code comments carry their text; block comments
also record whether blank lines should surround them. |
|
|
A node carrying trivia content (comment, blank line, directive, or cursor) and its source range.
Trivia nodes are attached to |
|
|
Example: `'T` or `[ |
|
|
Discriminated union for the three syntactic forms of type-parameter declaration.
|
|
|
Example: `<'T, 'U when 'T: equality>` — a postfix (angle-bracket) list of type parameter declarations with constraints. |
|
|
Example: `('T, 'U)` — a prefix (parenthesised) list of type parameter declarations. |
|
|
Discriminated union of all F# type expressions in the Oak intermediate representation.
Each case wraps a strongly-typed node that carries the substructure of that type form.
Use |
|
|
Example: `{| Name: string; Age: int |}` or `struct {| X: float |}` — an anonymous record type. |
|
|
Example: `int list` or `string option` — a postfix type application where the type argument precedes the type name. |
|
|
Example: `List |
|
|
Example: `int[]` (rank 1) or `int[,]` (rank 2) — an array type with a base element type and a rank. |
|
|
Discriminated union of all type-constraint forms that can appear in |
|
|
Example: `default 'T: int` — a default type constraint used in statically-resolved type parameters. |
|
|
Example: `'T: enum |
|
|
Example: `'T: comparison` or `'T: null` — a simple single-token type constraint. |
|
|
Example: `'T :> IDisposable` — a subtype constraint. |
|
|
Example: `'T: (member Foo: int)` — a member constraint on a statically resolved type parameter. |
|
|
`'T: not null` in `type C<'T when 'T: not null> = class end` |
|
|
Discriminated union of all F# type-definition forms in the Oak representation.
|
|
|
Example: `type Alias = OtherType` — a type abbreviation. |
|
|
Example: `type MyClass with` — a type augmentation (intrinsic extension) adding members to an existing type. |
|
|
Example: `type MyDelegate = delegate of int * string -> bool` — a delegate type declaration. |
|
|
Example: `type Color = Red | Green | Blue` — an enum-style type definition with integer-valued cases. |
|
|
The body of a `class … end` / `struct … end` / `interface … end` explicit type definition block. |
|
|
Example: `type MyClass() = class … end` — a type definition using an explicit `class`/`struct`/`interface` block. |
|
|
Example: `type Point = { X: float; Y: float }` — a record type definition. |
|
|
A regular type definition (class, interface, or abstract class without an explicit `class … end` block). Example: `type MyClass() =\n member _.Foo() = …` |
|
|
Example: `type Result<'T> = Ok of 'T | Error of string` — a discriminated union type definition. |
|
|
Example: `int -> string -> bool` — a function type with one or more parameters and a return type. Each parameter is paired with its arrow token; the final element is the return type. |
|
|
Example: `#IDisposable` — a flexible/hash constraint type that matches any subtype. |
|
|
Example: `IFoo & IBar` — an intersection type (F# 9+), combining multiple types with `&` separators. |
|
|
Example: `Map |
|
|
Example: `m^2` — a measure type raised to a rational power (used in units of measure). |
|
|
The shared header of a type definition: `type` / `and` keyword, optional doc, attributes, name, type parameters, constraints, optional implicit constructor, and `=` / `with` tokens. Example: `type private MyType<'T when 'T: equality>(x: int) =` |
|
|
Example: `A or B` — an F# 9+ type union (disjunction) used in type constraints and signatures. |
|
|
Example: `(int -> string)` — a parenthesised type, used to clarify precedence or wrap a type in parens. |
|
|
Example: `?x: int` or `[ |
|
|
Example: `const 42` — a static constant expression used as a type argument (e.g. in inline F# code or SRTP). |
|
|
Example: `N=3` — a named static constant type, pairing an identifier type with a value type (e.g. in SRTP constraints). |
|
|
Example: `struct (int * string)` — a struct tuple type, distinguishable from a reference tuple by the `struct` keyword. |
|
|
Example: `int * string * bool` — a tuple type. Path interleaves the component types with `*` separators. |
|
|
Example: `'T when 'T : equality` — a type paired with one or more type constraints that apply globally. |
|
|
Example: `| MyCase of int * string` — a discriminated union case declaration. |
|
|
Example: `()` — a unit value consisting of an opening and closing parenthesis. |
|
|
Example: ` |
|
|
Example: `val mutable x: int` — a value declaration in a class or signature file, optionally mutable and with an initial expression. |
|
|
Example: `/// Summary line.\n/// More detail.` — an XML documentation comment block.
Each element of |
fantomas