F# Code I Love

F# Code I Love - Don Syme

What is good F# practice?!

What is F#?

It's high performance from Microsoft Dotnet!

But also Fable/JavaScript!

dotnet new -lang F#
dotnet build

  • 350,000 to 30,000 lines!

  • 3000 null checks!

  • 2000 try catches!

Good F# Code


  • Pipelining!

Domain Modeling

  • Domain Modeling
    • Expression Modeling!

  • Web Request

  • Request to iTunes!

Data Scripting

  • flow of data and code

User Interfaces

  • User Interfaces! (Web, Mobile)
    • Model-View-Update

  • As a website! View is now a function
  • Fable, SAFE stack, Elmish
  • Fabulous for Xamarin


  • The compiler just composes functions together!

  • Giraffe Functional Web Server

Bad F# code. Don't Do's!

  • Just use parenthesis. Read them as tuples.

Back pipe

  • <| is just confusing. Use parenthesis

Point Free Code

  • weird operators like >> or >>=

Fold considered harmful

Objects Programming

Type Providers

  • Take a HTMLProvider now you have the page type information!

Computational Expression

  • Use a for loop list