Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block swlaschin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
swlaschin / NewsDomainDtoExample.fsx
Last active Sep 18, 2019
Demonstrates DTO validation for a news feed domain
View NewsDomainDtoExample.fsx
Demonstrates DTO validation for a news feed domain
// "result.fsx" comes from
#load "result.fsx"
module Domain =
type DocumentId = DocumentId of int
type EmailAddress = EmailAddress of string
swlaschin / merge.fsx
Created Aug 16, 2019
Merge with custom update/insert/delete actions
View merge.fsx
module Util =
/// Merge a new list into an old list.
/// The sortKey is used to sort and compare the keys.
/// The insert/update/delete actions are called as appropriate. They return Options so that
/// you can filter at the same time.
let merge oldList newList sortKey insertAction updateAction deleteAction =
let rec innerMerge oldList newList =
match oldList,newList with
swlaschin /
Last active Aug 16, 2019
F# to C# interop tips

Tips on exposing F# to C#

Api and Methods

I suggest that you create one or more Api.fs files to expose F# code in a C# friendly way.

In this file:

  • Define functions with PascalCase names. They will appear to C# as static methods.
  • Functions should use tuple-style declarations (like C#) rather than F#-style params with spaces.
swlaschin /
Last active Aug 14, 2019
C# LINQ -> F# equivalent
swlaschin / WorkflowTemplate.fsx
Created May 13, 2019
Workflow Template example
View WorkflowTemplate.fsx
#load "Result.fs"
// ==================================
// Example of workflows with Onion architecture
// ==================================
let notImplemented() = failwith "not implemented"
// ==================================
// pure workflow
swlaschin / testutils.fs
Last active Apr 29, 2019
Test utilities
View testutils.fs
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"
View AsyncExample.fs
namespace AsyncExample
// requires Result.fs from
open System
open System.Net
module SimpleAsyncExample =
let makeAsync name = async {
printfn "Started %s" name
swlaschin /
Last active Oct 6, 2019
Effective F#, tips and tricks


  • 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 /
Created Jul 5, 2017
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

You can’t perform that action at this time.