F# Training
F# Training
F# Training
  • Presentation
  • Fundamentals
    • Introduction
    • Syntax
      • Bases
      • Functions
      • Rules
      • Exceptions
    • First concepts
    • 🍔Quiz
  • Functions
    • Signature
    • Concepts
    • Syntax
    • Standard functions
    • Operators
    • Addendum
    • 🍔Quiz
    • 📜Summary
  • Types
    • Overview
    • Tuples
    • Records
    • Unions
    • Enums
    • Anonymous records
    • Value types
    • 📜Recap
    • Addendum
  • Monadic types
    • Intro
    • Option type
    • Result type
    • Smart constructor
    • 🚀Computation expression (CE)
    • 🚀CE theoretical basements
    • 📜Recap
  • Pattern matching
    • Patterns
    • Match expression
    • Active patterns
    • 🚀Fold function
    • 📜Recap
    • 🕹️Exercises
  • Collections
    • Overview
    • Types
    • Common functions
    • Dedicated functions
    • 🍔Quiz
    • 📜Recap
  • Asynchronous programming
    • Asynchronous workflow
    • Interop with .NET TPL
    • 📜Recap
  • Module and Namespace
    • Overview
    • Namespace
    • Module
    • 🍔Quiz
    • 📜Recap
  • Object-oriented
    • Introduction
    • Members
    • Type extensions
    • Class, Struct
    • Interface
    • Object expression
    • Recommendations
Powered by GitBook
On this page
  • Union types: Option and Result
  • Computation expression (CE)
  • 🔗 Additional ressources

Was this helpful?

Edit on GitHub
  1. Monadic types

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, filter → ROP

    • 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

  • Compositional IT (Isaac Abraham)

  • F# for Fun and Profit (Scott Wlaschin)

  • Extending F# through Computation Expressions

PreviousCE theoretical basementsNextPatterns

Last updated 1 month ago

Was this helpful?

• 2020

• 2012

• 2013

• 2015

• 2013

📹

📜

by Jeremie Chassaing

📜
Writing more succinct C# – in F#! (Part 2)
The Option type
Making illegal states unrepresentable
The "Map and Bind and Apply, Oh my!" series
The "Computation Expressions" series
Video
Article
Computation Expressions Workshop
Applicatives IRL