Namespaces
Both namespaces and modules are used for organizing the code in a hierarchical, logical way.
Constructors
Constructors |
Description |
---|---|
Namespace(name: string) |
Creates a namespace with the specified name. |
TopLevelModule(name: string) |
Creates a top-level module with the specified name. |
AnonymousModule() |
Creates an anonymous module. |
Properties
Properties |
Description |
---|---|
toRecursive() |
Makes the namespace or module recursive. |
toPrivate() |
Makes the namespace or module private. |
toInternal() |
Makes the namespace or module internal. |
toPublic() |
Makes the namespace or module public. |
Usage
#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.Core.dll"
#r "../../src/Fabulous.AST/bin/Release/netstandard2.1/publish/Fantomas.FCS.dll"
open Fabulous.AST
open Fantomas.Core
open type Fabulous.AST.Ast
Oak() {
Namespace("MyNamespace") { Record("Person") { Field("name", "string") } }
TopLevelModule("MyModule") { Record("Person1") { Field("name", "string") } }
AnonymousModule() { Record("Person2") { Field("name", "string") } }
Namespace("MyNamespace") { NestedModule("MyModule") { Record("Person") { Field("name", "string") } } }
}
|> Gen.mkOak
|> CodeFormatter.FormatOakAsync
|> Async.RunSynchronously
|> printfn "%s"
Will output the following code:
namespace MyNamespace
type Person = { name: string } module MyModule
type Person1 = { name: string } type Person2 = { name: string } namespace MyNamespace
module MyModule = type Person = { name: string }
static member Ast.Oak: unit -> CollectionBuilder<SyntaxOak.Oak,'marker>
--------------------
module Oak from Fabulous.AST
static member Ast.Namespace: name: string -> CollectionBuilder<NamespaceNode,SyntaxOak.ModuleDecl>
--------------------
module Namespace from Fabulous.AST
static member Ast.Record: name: string -> CollectionBuilder<SyntaxOak.TypeDefnRecordNode,SyntaxOak.FieldNode>
--------------------
module Record from Fabulous.AST
static member Ast.Field: name: string * filedType: string -> WidgetBuilder<SyntaxOak.FieldNode>
static member Ast.Field: name: string * filedType: WidgetBuilder<SyntaxOak.Type> -> WidgetBuilder<SyntaxOak.FieldNode>
static member Ast.Field: filedType: string -> WidgetBuilder<SyntaxOak.FieldNode>
static member Ast.Field: filedType: WidgetBuilder<SyntaxOak.Type> -> WidgetBuilder<SyntaxOak.FieldNode>
--------------------
module Field from Fabulous.AST
static member Ast.TopLevelModule: name: string -> CollectionBuilder<TopLevelModuleNode,SyntaxOak.ModuleDecl>
--------------------
module TopLevelModule from Fabulous.AST
static member Ast.AnonymousModule: unit -> CollectionBuilder<AnonymousModuleNode,SyntaxOak.ModuleDecl>
--------------------
module AnonymousModule from Fabulous.AST
static member Ast.NestedModule: name: string -> CollectionBuilder<SyntaxOak.NestedModuleNode,SyntaxOak.ModuleDecl>
--------------------
module NestedModule from Fabulous.AST
<summary> It takes the root of the widget tree and create the corresponding Fantomas node, and recursively creating all children nodes </summary>
static member CodeFormatter.FormatOakAsync: oak: SyntaxOak.Oak * config: FormatConfig -> Async<string>
module Async from Fantomas.Core
--------------------
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>