Header menu logo Fabulous.AST

Units of Measure

#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

Oak() {
    AnonymousModule() {
        Measure("cm")

        Measure("ml", MeasurePower(LongIdent "cm", Integer "3"))

        Measure("m")

        Measure("s")

        Measure("kg")

        Measure(
            "N",
            Tuple(
                [ AppPostfix(LongIdent "kg", LongIdent "m")
                  MeasurePower(LongIdent "s", Integer "2") ],
                "/"
            )
        )
    }
}
|> Gen.mkOak
|> Gen.run
|> printfn "%s"

// produces the following code:
[<Measure>]
type cm

[<Measure>]
type ml = cm^3

[<Measure>]
type m

[<Measure>]
type s

[<Measure>]
type kg

[<Measure>]
type N = kg m / s^2
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.Measure: name: string * powerType: string -> WidgetBuilder<Fantomas.Core.SyntaxOak.TypeDefnAbbrevNode>
static member Ast.Measure: name: string * powerType: WidgetBuilder<Fantomas.Core.SyntaxOak.Type> -> WidgetBuilder<Fantomas.Core.SyntaxOak.TypeDefnAbbrevNode>
static member Ast.Measure: name: string -> WidgetBuilder<Fantomas.Core.SyntaxOak.TypeNameNode>

--------------------
module Measure from Fabulous.AST

--------------------
type MeasureAttribute = inherit Attribute new: unit -> MeasureAttribute

--------------------
new: unit -> MeasureAttribute
static member Ast.MeasurePower: measure: string * node: string -> WidgetBuilder<Fantomas.Core.SyntaxOak.Measure>
static member Ast.MeasurePower: measure: WidgetBuilder<Fantomas.Core.SyntaxOak.Measure> * node: WidgetBuilder<Fantomas.Core.SyntaxOak.RationalConstNode> -> WidgetBuilder<Fantomas.Core.SyntaxOak.Measure>
static member Ast.MeasurePower: value: string * rational: WidgetBuilder<Fantomas.Core.SyntaxOak.RationalConstNode> -> WidgetBuilder<Fantomas.Core.SyntaxOak.Type>
static member Ast.MeasurePower: value: WidgetBuilder<Fantomas.Core.SyntaxOak.Type> * rational: WidgetBuilder<Fantomas.Core.SyntaxOak.RationalConstNode> -> WidgetBuilder<Fantomas.Core.SyntaxOak.Type>
static member Ast.LongIdent: value: string -> WidgetBuilder<Fantomas.Core.SyntaxOak.Type>
static member Ast.LongIdent: value: string list -> WidgetBuilder<Fantomas.Core.SyntaxOak.Type>
static member Ast.Integer: value: int -> WidgetBuilder<Fantomas.Core.SyntaxOak.RationalConstNode>
static member Ast.Integer: value: string -> WidgetBuilder<Fantomas.Core.SyntaxOak.RationalConstNode>
Multiple items
static member Ast.Tuple: items: string list * exponent: string -> WidgetBuilder<Fantomas.Core.SyntaxOak.Type>
static member Ast.Tuple: items: string list -> WidgetBuilder<Fantomas.Core.SyntaxOak.Type>
static member Ast.Tuple: items: WidgetBuilder<Fantomas.Core.SyntaxOak.Type> list * exponent: string -> WidgetBuilder<Fantomas.Core.SyntaxOak.Type>
static member Ast.Tuple: items: WidgetBuilder<Fantomas.Core.SyntaxOak.Type> list -> WidgetBuilder<Fantomas.Core.SyntaxOak.Type>

--------------------
module Tuple from Fabulous.AST
static member Ast.AppPostfix: first: string * last: string -> WidgetBuilder<Fantomas.Core.SyntaxOak.Type>
static member Ast.AppPostfix: first: WidgetBuilder<Fantomas.Core.SyntaxOak.Type> * last: string -> WidgetBuilder<Fantomas.Core.SyntaxOak.Type>
static member Ast.AppPostfix: first: string * last: WidgetBuilder<Fantomas.Core.SyntaxOak.Type> -> WidgetBuilder<Fantomas.Core.SyntaxOak.Type>
static member Ast.AppPostfix: first: WidgetBuilder<Fantomas.Core.SyntaxOak.Type> * last: WidgetBuilder<Fantomas.Core.SyntaxOak.Type> -> WidgetBuilder<Fantomas.Core.SyntaxOak.Type>
module Gen 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>
val mkOak: root: WidgetBuilder<'node> -> 'node
val run: oak: Fantomas.Core.SyntaxOak.Oak -> string
val printfn: format: Printf.TextWriterFormat<'T> -> 'T

Type something to start searching.