Skip to content

Instantly share code, notes, and snippets.

@michaeloyer
michaeloyer / script.fsx
Created February 16, 2022 13:51
Demonstrating how to use a database with F#. Run this with `dotnet fsi script.fsx`
#r "nuget: System.Data.SQLite"
#r "nuget: Dapper"
open System
open Dapper
open System.Data
open System.Data.SQLite
[<CLIMutable>] // This creates private setters for Dapper to work with, but your F# code cannot
type Person = { Id: int; First: string; Last: string }
@michaeloyer
michaeloyer / Program.fs
Last active November 12, 2025 20:29
Better Support for F# Option<'T> in Swagger
open System
open Microsoft.AspNetCore.Builder
open Microsoft.Extensions.Hosting
open Microsoft.Extensions.DependencyInjection
open Microsoft.FSharp.Core
open Microsoft.OpenApi.Models
open Swashbuckle.AspNetCore.SwaggerGen
type Child = { Text: string }
type Parent = { Child: Child option }
@michaeloyer
michaeloyer / script.fsx
Created April 2, 2023 15:03
CSV Reading in F# with CsvHelper
#r "nuget: CsvHelper"
open System
open CsvHelper
type Transaction = { Amount: float; Date: DateOnly; Description: string }
let readTransactions() : Transaction list = [
use reader = new IO.StringReader("""
Account Number,Posted Date,Check,Description,Debit,Credit