Skip to content

Instantly share code, notes, and snippets.

@swlaschin
swlaschin / functional_logging_transactions.md
Last active Sep 6, 2020
Functional approach to Logging and Transactions
View functional_logging_transactions.md

"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 / fsharp_setup.md
Last active Sep 1, 2020
F# setup for workshops and training
View fsharp_setup.md
@swlaschin
swlaschin / fsharpjobs.md
Last active Nov 18, 2020
My suggestions on how to look for F# jobs
View fsharpjobs.md

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 Oct 11, 2020
Some recommended books for improving as a software developer
View booklist.md

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 Nov 17, 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 Nov 27, 2020
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 Nov 27, 2020
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
You can’t perform that action at this time.