Skip to content

Instantly share code, notes, and snippets.

swlaschin

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
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 https://github.com/swlaschin/DmmfWorkshop/blob/master/src/E-ModelingErrors/Result.fsx
#load "result.fsx"
module Domain =
type DocumentId = DocumentId of int
type EmailAddress = EmailAddress of string
@swlaschin
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
swlaschin / FsCsInterop.md
Last active Aug 16, 2019
F# to C# interop tips
View FsCsInterop.md

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
swlaschin / linq2fs.md
Last active Aug 14, 2019
C# LINQ -> F# equivalent
View linq2fs.md
@swlaschin
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
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 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 Oct 6, 2019
Effective F#, tips and tricks
View effective-fsharp.md

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 Jul 5, 2017
Functional Track talks from NDC Oslo 2017
View ndcoslo17_fp_track.md

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.