Full stack web development in F#
by Zaid Ajaj
Zaid Ajaj
Originally from Iraq
Living in the Netherlands
Lead Developer at eSightMonitoring
Working with C#, Javascript, F# and SQL
Active OSS contibutor to everything F#-related
Author of The Elmish Book
Follow me on Twitter & Github for F# news and latest developments
What is F#?
Why learn and use F#?
Getting started
Functional thinking
Unit testing
Data access
Beginning SAFE-Stack
Functional-first programming language
Part of .NET
Based on OCaml
Statically typed
Focus on simplicity
Focus on correctness
Fully featured core library
Powerful type-system that works for you!
Safe by default (unless you want otherwise)
Different way of thinking about problems
Huge set of available libraries from .NET and F#
Use everywhere: desktop, web backend, web frontend, mobile etc.
Use dotnet CLI
F# interactive
Use any editor: Visual Studio, VS Code or Rider
Visual Studio + F# Interactive is a great place to learn
Building a console application
F# basics
Starting F# Interactive
dotnet fsi
Creating a new console application
dotnet new console -lang F#
Building and running the application
dotnet run
Adding nuget packages
dotnet add package [package-name]
Value assignment, function declaration
Expressions everywhere and type-inference
Conditionals
Lists, arrays and sequences
The |>
forward pipe operator
Record types
Union types
Pattern matching
Demonstrating idiomatic functional code:
Parsing strings as integers
Modelling shapes with unions
Recursive shapes
Using Expecto
Building test utilities with function
Project can be found in the repository safe-workshop-parsing
Very simple when using Npgsql.FSharp
Built ontop of Ngpsql
Static SQL analysis in VS using Npgsql.FSharp.Analyzer
Schema management with migrations out of scope, recommended to use DbUp
Similar API for different providers
DustyTables for MS-SQL
Fumble for SQLite
No static analysis :(
Full Stack F# web development
Compiling to Javascript using Fable
Modern intergration with the JS ecosystem
Fable already has a large set of bindings
Using SAFE.Simplified template
Abstracting HTTP/JSON away with Fable.Remoting
SAFE-Template - Official templates comes in two flavors (minimal & default)
SAFE.Simplified - focuses on people with dotnet background
See you next time.
Questions?