Last active
July 27, 2020 21:05
-
-
Save Szer/01c7e531927b0d7326e7269b73a76346 to your computer and use it in GitHub Desktop.
Computational expression with state being passed through steps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type StepfulBuilder() = | |
member _.Zero() = () | |
member _.Yield x = x | |
[<CustomOperation("toInt")>] | |
member inline _.ToInt(_, value) = | |
int value | |
[<CustomOperation("transform")>] | |
member _.Transform(x, f) = | |
f x | |
[<CustomOperation("print")>] | |
member _.Print(x) = | |
printfn "%A" x | |
x | |
let steps = StepfulBuilder() | |
let flow = | |
steps { | |
toInt "1" | |
transform (fun x -> x + 5) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment