πRecap
Union types: Option and Result
Option and ResultWhat they are used for:
Model absence of value and business errors
Partial operations made total
tryXxxSmart constructor
tryCreate
How to use them:
Chaining:
map,bind,filterβ ROPPattern matching
Their benefits:
nullfree,Exceptionfree β no guard clauses Cluttering the codeMakes business logic and happy path more readable
Computation expression (CE)
Syntactic sugar: inner syntax standard or "banged" (
let!)Separation of Concerns: business logic vs "machinery"
Compiler translates to builder calls
Object storing a state
Builds an output value of a specific type
Can be nested but not easy to combine!
Underlying theoretical concepts
Monoid β
seq(of composable elements and with a "zero ")Monad β
async,option,resultApplicative β
validation/Result<'T, 'Err list>
Libraries: FSharpPlus, FsToolkit, Expecto, Farmer, Saturn, Bolero...
π Additional ressources
Compositional IT (Isaac Abraham)
F# for Fun and Profit (Scott Wlaschin)
The Option type β’ 2012
The "Computation Expressions" series β’ 2013
Applicatives IRL by Jeremie Chassaing
Last updated
Was this helpful?