Header menu logo Fabulous.AST

Open Declarations

An open declaration lets you reference the elements of a module or namespace without a fully qualified name. Open imports a namespace or module, OpenType imports a type's static members, and OpenGlobal opens from the root with the global specifier.

Contents

#r "../../src/Fabulous.AST/bin/Release/netstandard2.1/publish/Fantomas.Core.dll"
#r "../../src/Fabulous.AST/bin/Release/netstandard2.1/publish/Fabulous.AST.dll"
#r "../../src/Fabulous.AST/bin/Release/netstandard2.1/publish/Fantomas.FCS.dll"

open Fabulous.AST
open type Fabulous.AST.Ast

Opening Namespaces and Modules

Pass a single name or a list of path segments:

Oak() {
    AnonymousModule() {
        Open("Fabulous.AST")

        Open([ "System"; "IO" ])
    }
}
|> Gen.mkOak
|> Gen.run
|> printfn "%s"

// produces the following code:
open Fabulous.AST
open System.IO

Opening a Type

OpenType exposes the accessible static members and fields of a type:

Oak() { AnonymousModule() { OpenType([ "System.Math" ]) } }
|> Gen.mkOak
|> Gen.run
|> printfn "%s"

// produces the following code:
open type System.Math

Global Opens

OpenGlobal opens from the root path only, emitting the global specifier:

Oak() {
    AnonymousModule() {
        OpenGlobal("A")

        OpenGlobal([ "A"; "B" ])
    }
}
|> Gen.mkOak
|> Gen.run
|> printfn "%s"

// produces the following code:
open global.A
open global.A.B
namespace Fabulous
namespace Fabulous.AST
type Ast = class end
Multiple items
static member Ast.Oak: unit -> CollectionBuilder<Fantomas.Core.SyntaxOak.Oak,'marker>

--------------------
module Oak from Fabulous.AST
static member Ast.AnonymousModule: unit -> CollectionBuilder<Fantomas.Core.SyntaxOak.ModuleOrNamespaceNode,Fantomas.Core.SyntaxOak.ModuleDecl>
Multiple items
static member Ast.Open: value: string -> WidgetBuilder<Fantomas.Core.SyntaxOak.ModuleDecl>
static member Ast.Open: values: string seq -> WidgetBuilder<Fantomas.Core.SyntaxOak.ModuleDecl>

--------------------
module Open from Fabulous.AST
type Gen = static member mkOak: root: WidgetBuilder<'node> -> 'node static member parse: source: string -> string + 1 overload static member run: oak: Oak -> string + 1 overload
<summary> Renders a widget tree to F# source and verifies the result. <c>mkOak</c> turns the root widget into a Fantomas node (recursively building its children), <c>run</c> formats that node to source (optionally with a config), and <c>parse</c> round-trips the source back through the parser to confirm it is syntactically valid. Designed for pipeline use, e.g. <c>widget |&gt; Gen.parse</c> or <c>widget |&gt; Gen.mkOak |&gt; Gen.run |&gt; Gen.parse</c>. </summary>
static member Gen.mkOak: root: WidgetBuilder<'node> -> 'node
static member Gen.run: oak: Fantomas.Core.SyntaxOak.Oak -> string
static member Gen.run: oak: Fantomas.Core.SyntaxOak.Oak * config: Fantomas.Core.FormatConfig -> string
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
static member Ast.OpenType: value: string -> WidgetBuilder<Fantomas.Core.SyntaxOak.ModuleDecl>
static member Ast.OpenType: values: string seq -> WidgetBuilder<Fantomas.Core.SyntaxOak.ModuleDecl>
static member Ast.OpenGlobal: value: string -> WidgetBuilder<Fantomas.Core.SyntaxOak.ModuleDecl>
static member Ast.OpenGlobal: values: string seq -> WidgetBuilder<Fantomas.Core.SyntaxOak.ModuleDecl>

Type something to start searching.