Skip to content

Instantly share code, notes, and snippets.

@blair55
Created November 29, 2022 13:48
Show Gist options
  • Save blair55/7c633066076c77482ec082f46a429f3d to your computer and use it in GitHub Desktop.
Save blair55/7c633066076c77482ec082f46a429f3d to your computer and use it in GitHub Desktop.
Trivial writer example
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