Skip to content
Skills Library
Programming · Building & coding

fsharp

/fsharp

Expert F# functional programming assistance covering pattern matching, immutability, async workflows, and .NET interop. Use when developing type-safe domain models, data processing pipelines, or cloud services.

Licence
MIT
Last repository change
01.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
2
Deprecation

No signals detected. Repository changed on 01.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Expert F# functional programming assistance covering pattern matching, immutability, async workflows, and .NET interop. Use when developing type-safe domain models, data processing pipelines, or cloud services.

Original author description

Expert F# functional programming assistance covering pattern matching, immutability, async workflows, and .NET interop. Use when developing type-safe domain models, data processing pipelines, or cloud services.

How it works

  1. When to Use
  2. Quick Start
  3. Core Concepts
  4. Common Patterns
  5. Best Practices
  6. Troubleshooting
  7. References
Original SKILL.md headings · 121 lines, 647 words
SKILL.md preview
---
name: fsharp
description: Expert F# functional programming assistance covering pattern matching, immutability, async workflows, and .NET interop. Use when developing type-safe domain models, data processing pipelines, or cloud services.
---

# F#

F# is a functional-first, cross-platform programming language on .NET, combining strong static typing, pattern matching, lightweight syntax, and seamless C# interoperability.

## When to Use

- **Functional-First Software on .NET**: Building robust, concise, type-safe enterprise applications within the .NET ecosystem.
- **Financial Engineering & Domain Modeling**: Modeling financial instruments, actuarial rules, and transactional workflows using algebraic data types.
- **High-Velocity Data Science & ETL**: Manipulating tabular datasets using interactive F# scripts (`.fsx`) and FSharp.Data type providers.
- **Full-Stack Safe Web Apps (SAFE Stack)**: Developing end-to-end type-safe web applications spanning Saturn, Azure, Fable, and Elmish.

## Quick Start

```fsharp
type Person = { Name: string; Age: int }

let describePerson person =
    match person.Age with
    | age when age < 18 -> sprintf "%s is a minor" person.Name
    | _ -> sprintf "%s is an adult" person.Name

let alice = { Name = "Alice"; Age = 25 }
printfn "%s" (describePerson alice)
```

## Core Concepts

### Discriminated Unions & Pattern Matching

Makes illegal business states unrepresentable through closed algebraic data types:

```fsharp
type PaymentMethod =
    | CreditCard of cardNumber: string * cvv: string
    | BankTransfer of iban: string
    | Crypto of walletAddress: string

let processPayment method amount =
    match method with
    | CreditCard(num, _) -> printfn "Charging card %s: $%.2f" num amount
    | BankTransfer iban  -> printfn "Initiating SEPA transfer to %s" iban
    | Crypto wallet      -> printfn "Broadcasting crypto payment to %s" wallet
```

### Type Providers (Compile-Time Schema Generation)

Generates strongly-typed types directly from external JSON, CSV, or SQL sources at compile-time:

```fsharp
open FSharp.Data

type UserApi = JsonProvider<"https://api.example.com/user.json">

let parseUser jsonString =
    let user = UserApi.Parse(jsonString)
    printfn "User Name: %s, Email: %s" user.Name user.Email
```

### Functional Pipelines & Partial Application

Composes functions using forward pipe (`|>`) and composition (`>>`) operators:

```fsharp
let addTax amount = amount * 1.10
let applyDiscount amount = amount - 5.0

let calculateFinalPrice = applyDiscount >> addTax

let finalTotal = 100.0 |> calculateFinalPrice
```

## Common Patterns

### Discriminated Unions for Exhaustive Domain Modeling

**Problem**: Representing complex state transitions with boolean flags leads to invalid object states.

**Solution**:
Use Discriminated Unions with compiler-verified pattern matching:

```fsharp
type PaymentMethod =
    | CreditCard of cardNumber: string * cvv: string
    | PayPal of email: string
    | Crypto of walletAddress: string

let processPayment method amount =
    match method with
    | CreditCard(num, _) -> sprintf "Charging $%.2f to Card ending in %s" amount (num.Substring(num.Length - 4))
    | PayPal email -> sprintf "Charging $%.2f via PayPal (%s)" amount email
    | Crypto wallet -> sprintf "Requesting crypto transfer to %s" wallet
```

## Best Practices

**Do**:

- Make Illegal States Unrepresentable: Model business domains using Discriminated Unions and Records rather than primitive types.
- Use the Result Type for Error Handling: Chain validation steps using `Result.bind` instead of throwing untyped exceptions.
- Leverage F# Interactive (FSI): Rapidly prototype algorithms in `.fsx` script files before adding to production projects.
- Interoperate with C# and .NET Cleanly: Consume NuGet packages and ASP.NET Core libraries natively.

**Don't**:

- Use mutable variables (`mutable`) unnecessarily: Favor immutable values and recursive or folded loops.
- Use `null`: F# values cannot be null by default; use `Option<'T>` to represent optional data.
- Write heavy class hierarchies: Prefer composition of records, functions, and modules over deep inheritance.

## Troubleshooting

| Error                                                              | Cause                                                                | Solution                                                                    |
| :----------------------------------------------------------------- | :------------------------------------------------------------------- | :-------------------------------------------------------------------------- |
| `Incomplete pattern matches on this expression`                    | Pattern match missing one or more cases of a Discriminated Union.    | Add missing cases to make pattern match exhaustive.                         |
| `FS0001: Type mismatch`                                            | Expected one type but received another; F# does not implicitly cast. | Cast explicitly using functions like `float`, `int`, or conversion methods. |
| `FS0041: A unique overload for method ... could not be determined` | .NET method overload resolution ambiguous.                           | Provide explicit type annotations on method parameters.                     |

## References

- [F# Guide](https://fsharp.org/)

Versions

RepositoryScoreLicence
This page · G1Joshi/Agent-Skills100MIT
managedcode/dotnet-skills100MIT
Tyler-R-Kendrick/agent-skills100MIT

Database snapshot: 13.11.2026 · package version 8a6440612b0e (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100functional-programming
    Use when applying functional programming patterns and principles in C# including immutability, pure functions, higher-order functions, and monadic patterns. USE FOR: functional programming concepts in C#, immutability patterns, pure functions, LINQ as functional operations,…
  • 100ocaml
    Expert OCaml functional programming assistance covering algebraic data types, pattern matching, modules, and Dune. Use when developing static analysis tools, compilers, theorem provers, or high-assurance software.
  • 100csharp
    Expert C# and .NET assistance covering LINQ, async/await patterns, pattern matching, records, Entity Framework Core, and ASP.NET Core web services. Use when writing idiomatic C#, designing .NET enterprise backends, building cross-platform services, or optimizing memory with span/memory types.
  • 85Scala Functional Patterns
    Use when functional programming patterns in Scala including higher-order functions, immutability, pattern matching, algebraic data types, monads, for-comprehensions, and functional composition for building robust, type-safe applications.
  • 100scala-functional-object-programming
    Use this skill when authoring robust Scala 3 applications using case classes, pattern matching, type classes, and pure functions.
  • 90dotnet-csharp
    Baseline C# skill loaded for every .NET code path. Guides language patterns (records, pattern matching, primary constructors, C# 8-15), coding standards, async/await, DI, LINQ, serialization, domain modeling, concurrency, Roslyn analyzers, globalization, native interop…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.