Files
WoofWare.Whippet/WoofWare.Whippet.Fantomas/CompExpr.fs
Patrick Stevens 8834d885de
Some checks failed
.NET / build (Debug) (push) Has been cancelled
.NET / build (Release) (push) Has been cancelled
.NET / analyzers (push) Has been cancelled
.NET / build-nix (push) Has been cancelled
.NET / check-dotnet-format (push) Has been cancelled
.NET / check-nix-format (push) Has been cancelled
.NET / Check links (push) Has been cancelled
.NET / Check flake (push) Has been cancelled
.NET / nuget-pack (push) Has been cancelled
.NET / expected-pack (push) Has been cancelled
.NET / all-required-checks-complete (push) Has been cancelled
Initial import of Fantomas client library (#6)
2024-10-04 15:13:49 +01:00

56 lines
1.6 KiB
Forth

namespace WoofWare.Whippet.Fantomas
open Fantomas.FCS.Syntax
/// A little DSL for defining the contents of a computation expression.
/// Pass these to `SynExpr.createCompExpr`.
type CompExprBinding =
/// `let! {varName} = {rhs}`
| LetBang of varName : string * rhs : SynExpr
/// `let {varName} = {rhs}`
| Let of varName : string * rhs : SynExpr
/// `use {varName} = {rhs}`
| Use of varName : string * rhs : SynExpr
/// `do {body}`
| Do of body : SynExpr
(*
Potential API!
type internal CompExprBindings =
private
{
/// These are stored in reverse.
Bindings : CompExprBinding list
CompExprName : string
}
[<RequireQualifiedAccess>]
module internal CompExprBindings =
let make (name : string) : CompExprBindings =
{
Bindings = []
CompExprName = name
}
let thenDo (body : SynExpr) (bindings : CompExprBindings) =
{ bindings with
Bindings = (Do body :: bindings.Bindings)
}
let thenLet (varName : string) (value : SynExpr) (bindings : CompExprBindings) =
{ bindings with
Bindings = (Let (varName, value) :: bindings.Bindings)
}
let thenLetBang (varName : string) (value : SynExpr) (bindings : CompExprBindings) =
{ bindings with
Bindings = (LetBang (varName, value) :: bindings.Bindings)
}
let thenUse (varName : string) (value : SynExpr) (bindings : CompExprBindings) =
{ bindings with
Bindings = (LetBang (varName, value) :: bindings.Bindings)
}
*)