I think I've got enough understanding of F# monads (workflows) that I see a few places in my code where implementing them makes sense.
For example, I've got a function with multiple nested if/thens, i.e. the function should continue only so long as the data pass certain "tests" along the way.
I'm familiar with the "maybe" monad, but in all the examples that I've seen, it's coded to operate on let!
bindings, which I'm not doing. I'm hoping that someone can provide me with an example of the "maybe" workflow tailored for nested Boolean tests, not let
binds.
You could pull this off without defining a new monad. Just define
let test b = if b then Some () else None
which you can now use with maybe
:
maybe {
do! test (1 > 0)
printfn "1"
do! test (2 > 3)
printfn "2"
return ()
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With