FsToolkit.ErrorHandling is a free, open-source F# package for working with options and results through computation expressions and related helpers. Its option { } expression makes optional-value workflows read like ordinary sequential code while handling failure propagation automatically. section 9.3
The practical pattern is:
- Bind each optional value with let!, which unwraps Some values and stops the computation when a value is None. section 9.3
- Return the final calculation inside the expression, avoiding nested pattern matching and manual option plumbing. section 9.3
- Use result { } similarly for Ok and Error values; let! unwraps Ok and discards Error values. section 9.3
#r "nuget:FSToolkit.ErrorHandling, 2.13.0" #1
open FsToolkit.ErrorHandling #1
let myMaybeData = option { #2
let! numberOne = tryParseNumber "1" #3
let! numberTwo = tryParseNumber "2" #3
let! numberThree = tryParseNumber "3" #3
return calc numberOne numberTwo numberThree #4
}
A compact runnable example installs the package, opens its namespace, parses three optional numbers, and calculates with their unwrapped values. section 9.3
