Skip to content

Instantly share code, notes, and snippets.

@swlaschin
swlaschin / duplicate_load.md
Last active December 20, 2020 18:59
Example of duplicate #load

The duplicate #load problem and how to fix it

Symptom: A weird error such as:

error FS0001: This expression was expected to have type
    'FSI_0011.MyType'
but here has type
    'FSI_0012.MyType'
@swlaschin
swlaschin / functional_logging_transactions.md
Last active December 15, 2020 22:55
Functional approach to Logging and Transactions

"What is a functional approach to logging and transactions" is a question I get asked sometimes. So here's my take.

First, there is never a perfect answer! It depends on your tolerance for impurity, what's compatible with the rest of the code and what other maintainers expect.

Logging

I use F#, which generally has a pragmatic approach to this kind of thing.

In Haskell or purist FP Scala (e.g. with Cats/Scalaz) the standard approach would be to use a writer monad, but for F#/OCaml/ReasonML etc, that would probably be overkill.

@swlaschin
swlaschin / dmmf_workshop.md
Last active January 16, 2023 22:09
Setup instructions for my 16 hr (2 full day or 4 half day) Domain Modeling Made Functional workshop

Setup instructions for the 16 hr (2 full day or 4 half day) Domain Modeling Made Functional workshop

Requirements:

  • Git (optional)
  • F#

I will assume that you have git already installed.

Install F#

@swlaschin
swlaschin / fsharpjobs.md
Last active February 23, 2024 03:23
My suggestions on how to look for F# jobs

How to find F# jobs

People often ask me how to find F# jobs. I don't have any special connections to companies using F#, and I don't have any special tricks either. I wish I did!

So, given that, here's my take on F# jobs.

Job hunting

For job hunting my suggestions are:

@swlaschin
swlaschin / booklist.md
Last active May 2, 2024 11:29
Some recommended books for improving as a software developer

Some recommended books for improving as a software developer

Most software books are too language specific and go out of date too quickly. What I find has stayed with me are books about bigger concepts, such as systems thinking and complexity, and also so-called "soft skills" such as management and psychology.

User experience

These are all really about developing empathy for other people :)

  • "The Design of Everyday Things" by Donald Norman
@swlaschin
swlaschin / NewsDomainDtoExample.fsx
Last active November 17, 2019 07:18
Demonstrates DTO validation for a news feed domain
(*
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 August 16, 2019 09:29
Merge with custom update/insert/delete actions
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 May 6, 2024 17:20
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
swlaschin / linq2fs.md
Last active March 7, 2023 22:15
C# LINQ -> F# equivalent