Created
November 29, 2022 13:48
-
-
Save blair55/7c633066076c77482ec082f46a429f3d to your computer and use it in GitHub Desktop.
Trivial writer example
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 Log = string * int | |
let f: Writer<Log, bool> = | |
writer { | |
let x = 1 | |
do! write ("x", x) | |
let y = 2 | |
do! write ("y", y) | |
let z = x + y | |
do! write ("result", z) | |
return z > 0 | |
} | |
let (result: bool, logs: Log list) = run f | |
printfn "%A" result | |
printfn "%A" logs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment