No more spurious option

This commit is contained in:
Smaug123
2023-12-21 22:41:38 +00:00
parent 64127ef139
commit 9a79297e36

View File

@@ -38,7 +38,7 @@ type Pipeline =
| Empty
| ShellScript of script : string * andThen : (Pipeline)
| ShellScriptBind of script : string * consumeStdout : (Stdout -> Pipeline)
| Sequence of first : (Pipeline * PipelineModifier option) * second : (Pipeline)
| Sequence of first : (Pipeline * PipelineModifier) * second : (Pipeline)
[<RequireQualifiedAccess>]
module Pipeline =
@@ -53,14 +53,10 @@ module Pipeline =
let dummyPipeline = consumeStdout (Stdout (Comp.make outputDummy))
$"%s{indent}Run: %s{script}\n%s{indent}With its output labelled %s{outputDummy}:\n%s{toStringInner (bindCount + 1) (indentCount + 2) dummyPipeline}"
| Pipeline.Sequence((first, modifier), second) ->
let firstMod =
match modifier with
| None -> ""
| Some modifier ->
$"%O{modifier}"
let firstMod = $"%s{indent} %O{modifier}\n"
let first = $"%s{toStringInner bindCount (indentCount + 2) first}"
let second = $"%s{toStringInner bindCount (indentCount + 2) second}"
$"%s{indent} {firstMod}\n%s{first}\n%s{indent}----\n%s{second}"
$"%s{firstMod}%s{first}\n%s{indent}----\n%s{second}"
let toString (p : Pipeline) = toStringInner 0 0 p
@@ -130,7 +126,7 @@ type PipelineBuilder (agent : string Comp option) =
let subsequent = cont ()
Pipeline.ShellScript (toRun, subsequent)
/// Bind in another pipeline, perhaps on a different agent
member _.Bind (p : Pipeline * PipelineModifier option, cont : unit -> Pipeline) : Pipeline =
member _.Bind (p : Pipeline * PipelineModifier, cont : unit -> Pipeline) : Pipeline =
Pipeline.Sequence (p, cont ())
member _.Yield (x : unit) : unit = ()
member _.For
@@ -141,16 +137,17 @@ type PipelineBuilder (agent : string Comp option) =
let pipeline = cont ()
pipeline
member _.Run x = x, Some modifier
member _.Run x =
x, modifier
[<AutoOpen>]
module PipelineBuilder =
let pipeline (agent : string Comp) = PipelineBuilder (Some agent)
let pipelineSameAgent = PipelineBuilder None
let toStepDag (p : Pipeline, modifier : PipelineModifier option) : SealedStepDag<unit, unit> =
match modifier with
let toStepDag (p : Pipeline, modifier : PipelineModifier) : SealedStepDag<unit, unit> =
match modifier.AgentModifier with
| None -> failwith "Pipeline must run on an agent, but no agent was specified"
| Some modifier ->
| Some _ ->
failwith $"TODO\n%O{modifier}\n%s{Pipeline.toString p}"
let foo () : SealedStepDag<unit, unit> =