Skip to content

Instantly share code, notes, and snippets.

@swlaschin
swlaschin / WorkflowTemplate.fsx
Created May 13, 2019 13:00
Workflow Template example
#load "Result.fs"
// ==================================
// Example of workflows with Onion architecture
// ==================================
let notImplemented() = failwith "not implemented"
// ==================================
// pure workflow
@swlaschin
swlaschin / testutils.fs
Last active April 29, 2019 09:38
Test utilities
module TestUtils
// Utilities for tests
/// Helper for testing only! Do not use in production!
let getOk result =
match result with
| Ok v -> v
| Error _ -> failwith "Error not expected"
@swlaschin
swlaschin / AsyncExample.fs
Last active April 24, 2019 15:24
Async example
namespace AsyncExample
// requires Result.fs from https://github.com/swlaschin/DomainModelingMadeFunctional/blob/master/src/OrderTaking/Result.fs
open System
open System.Net
module SimpleAsyncExample =
let makeAsync name = async {
printfn "Started %s" name
@swlaschin
swlaschin / effective-fsharp.md
Last active March 8, 2024 03:10
Effective F#, tips and tricks

Architecture

  • Use Onion architecture

    • Dependencies go inwards. That is, the Core domain doesn't know about outside layers
  • Use pipeline model to implement workflows/use-cases/stories

    • Business logic makes decisions
    • IO does storage with minimal logic
    • Keep Business logic and IO separate
  • Keep IO at edges

@swlaschin
swlaschin / ndcoslo17_fp_track.md
Created July 5, 2017 19:38
Functional Track talks from NDC Oslo 2017

Functional Track talks from NDC Oslo 2017

Also, here is the list of all videos from NDC Oslo 2017:

Wednesday 2017-06-14

@swlaschin
swlaschin / ndclondon17_fp_track.md
Last active July 10, 2017 11:04
Functional Track talks from NDC London 2017

Functional Track talks from NDC London 2017

Also, here is the list of all videos from NDC London 2017:

Wednesday 2017-01-18

@swlaschin
swlaschin / 1-checkers-scratch-design.fsx
Last active March 17, 2022 16:06
Example of Domain Driven Design for the game of checkers. There are two files: a scratch file with a series of designs, and a final version.
(*
Example of domain-driven design for Checkers
Rules from here: https://www.itsyourturn.com/t_helptopic2030.html
A SERIES OF SCRATCH DESIGNS
*)
// As we go through the rules, and learn things, we create a series of designs
module Version1 =
@swlaschin
swlaschin / CsvProvider.fsx
Created April 21, 2016 17:00
Updated version of R to F# code (from https://gist.github.com/ovatsus/5354187)
#r "packages/FSharp.Data/lib/net40/FSharp.Data.dll"
open FSharp.Data
type OzoneFile = CsvProvider<"http://faculty.washington.edu/heagerty/Books/Biostatistics/DATA/ozone.csv">
let csv = new OzoneFile()
//What are the column names of the dataset?
csv.Headers