Skip to content

F# Guide — Common Libraries and Ecosystem

DodaTech Updated 2026-06-28 4 min read

In this tutorial, you will learn about F# Guide. We cover key concepts, practical examples, and best practices to help you master this topic.

The F# ecosystem combines .NET's extensive library support with F#-specific libraries for functional web development, data science, parsing, testing, and domain modeling.

What You'll Learn

  • Web frameworks: Giraffe, Saturn, Falco
  • Data science: Deedle, Plotly.NET
  • Parsing: FParsec
  • Testing: Expecto, FsCheck
  • Serialization: FSharp.Json, Thoth.Json

Why It Matters

Knowing the ecosystem helps you choose the right tools for your project and leverage community solutions.

Real-World Use

F# web services use Giraffe/Saturn. Data scientists use Deedle for data frames. Financial systems use FParsec for domain-specific parsers.

flowchart LR
    A["Ecosystem"] --> B["Web"]
    B --> C["Data Science"]
    C --> D["Parsing"]
    D --> E["Testing"]
    A:::current --> B
    style A fill:#2563eb,stroke:#2563eb,color:#fff
    style B fill:#dbeafe,stroke:#2563eb,color:#1e40af
    style C fill:#dbeafe,stroke:#2563eb,color:#1e40af
    style D fill:#dbeafe,stroke:#2563eb,color:#1e40af
    style E fill:#f1f5f9,stroke:#94a3b8,color:#64748b

Web Frameworks

// Giraffe - functional ASP.NET Core
open Giraffe

let webApp =
    choose [
        route "/" >=> text "Hello World"
        route "/api/users" >=> json [{ Name = "Alice" }]
        routef "/user/%s" (fun name -> text (sprintf "User: %s" name))
    ]

// Saturn - full-stack framework
open Saturn

let app = application {
    use_router webApp
    url "http://0.0.0.0:8080"
    memory_cache
    use_gzip
}

run app

Data Science

// Deedle - data frames
open Deedle

let df = Frame.ReadCsv("data.csv")
df.Print()

// Filter and transform
let filtered =
    df
    |> Frame.filterRowValues (fun row -> row.GetAs<float>("Age") > 30)

// Plotly.NET - charts
open Plotly.NET

let chart =
    Chart.Line([1.0; 2.0; 3.0], [4.0; 2.0; 5.0], "My Data")

chart.Show()

Parsing with FParsec

open FParsec

// Parse arithmetic expressions
let parseExpr, exprRef = createParserForwardedToRef<string, unit>()

let number = pint32 |>> string
let operator = spaces >>. (pchar '+' <|> pchar '*') .>> spaces

let expr = pipe3 number operator number (fun a op b ->
    sprintf "(%s %c %s)" a op b)

exprRef.Value <- expr

let result = run expr "3 + 5"
// Success: (3 + 5)

Testing Libraries

// Expecto - functional test framework
open Expecto

let tests =
    testList "Math" [
        test "add" {
            Expect.equal (add 2 3) 5 "2+3=5"
        }
        testProperty "commutative" (fun a b ->
            add a b = add b a)
    ]

runTestsWithCLIArgs [] [||] tests

// FsCheck - property-based testing
open FsCheck

Check.Quick (fun (xs: int list) ->
    List.rev (List.rev xs) = xs)

Common Libraries

// Serialization
// Thoth.Json - F#-focused JSON
open Thoth.Json

let encoder = Encode.object [
    "name", Encode.string "Alice"
    "age", Encode.int 30
]

let json = Encode.toString 4 encoder

// FSharp.Json
open FSharp.Json

type User = { Name: string; Age: int }
let user = Json.deserialize<User>("""{"name":"Alice","age":30}""")

Logging

// Serilog with F#-friendly API
open Serilog

Log.Logger <- LoggerConfiguration()
    .MinimumLevel.Information()
    .WriteTo.Console()
    .CreateLogger()

Log.Information("Application started")
Log.Error("Error processing {UserId}: {Message}", userId, ex.Message)

Common Mistakes

1. Not exploring the ecosystem

Many F#-specific libraries exist. Don't default to C# libraries without checking for F# alternatives.

2. Ignoring community projects

The F# community creates high-quality open-source projects. Check F# Foundation's project list.

3. Over-engineering with minimal libraries

For simple tasks, built-in .NET libraries may be sufficient. Add dependencies only when needed.

4. Not checking compatibility

Verify library compatibility with your F# version and .NET target.

5. Missing Domain-Driven Design libraries

F# types (records, DUs) naturally support DDD. Explore libraries like FsCqrs for CQRS/ES.

Practice Questions

1. What is Giraffe? A functional web framework for ASP.NET Core that uses the compose pattern (>=) for building HTTP applications.

2. What is Deedle? An F# data frame library for working with tabular data, similar to Python's pandas.

3. What is FParsec? A parser combinator library for building parsers for domain-specific languages and data formats.

Challenge: Explore the F# ecosystem and identify libraries for your next project domain.

FAQ

{{< faq question="Where can I find F# libraries?" >} NuGet.org, the F# Foundation's library list, and GitHub's F# topic are the best resources. {{< /faq >}}

{{< faq question="Are there F# ORMs?" >} Yes. Entity Framework Core works with F#. For F#-friendly options, try SQLProvider type provider or FSharp.Data.SqlClient. {{< /faq >}}

{{< faq question="What is the SAFE stack?" >} Saturn (server), Azure (cloud), Fable (client), Elmish (UI) - a full-stack F# development stack. {{< /faq >}}

{{< faq question="Is there an F# REPL?" >} Yes. F# Interactive (dotnet fsi) provides a REPL for experimenting with code and libraries. {{< /faq >}}

{{< faq question="What IDE supports F#?" >} JetBrains Rider, Visual Studio, VS Code with Ionide extension all provide excellent F# support. {{< /faq >}}

Mini Project

Create a web service using Giraffe that serves JSON API:

open Giraffe
open Saturn

type User = { Id: int; Name: string; Email: string }

let users = [
    { Id = 1; Name = "Alice"; Email = "alice@example.com" }
    { Id = 2; Name = "Bob"; Email = "bob@example.com" }
]

let apiRoutes = choose [
    route "/api/users" >=> json users
    routef "/api/users/%d" (fun id ->
        match users |> List.tryFind (fun u -> u.Id = id) with
        | Some user -> json user
        | None -> setStatusCode 404 >=> text "Not Found")
]

let app = application {
    use_router apiRoutes
    url "http://0.0.0.0:5000"
    use_json_serializer (Thoth.Json.Giraffe.createSerializer())
}

run app

What's Next

Now that you've completed the F# tutorial series, explore other languages in the functional and JVM ecosystem.

Topic Description Link
Groovy JVM scripting {{< ref "/programming-languages/groovy" >}}
Clojure Lisp on JVM {{< ref "/programming-languages/clojure" >}}

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro