📜Recap

Union types: Option and Result

  • What they are used for:

    • Model absence of value and business errors

    • Partial operations made total tryXxx

      • Smart constructor tryCreate

  • How to use them:

    • Chaining: map, bind, filterROP

    • Pattern matching

  • Their benefits:

    • null free, Exception free → no guard clauses Cluttering the code

    • Makes 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, result

    • Applicative → validation/Result<'T, 'Err list>

  • Libraries: FSharpPlus, FsToolkit, Expecto, Farmer, Saturn, Bolero...

🔗 Additional ressources

Last updated

Was this helpful?