-
-
Save medigor/84a90c06fa994a2be6ec7b7838704ddc 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