Skip to content

Instantly share code, notes, and snippets.

@swlaschin
swlaschin / FsCsInterop.md
Last active April 7, 2024 20:33
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 / 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 / ConstrainedTypesExamples.fsx
Last active March 1, 2024 18:19
Examples of creating constrained types in F#
// General hints on defining types with constraints or invariants
//
// Just as in C#, use a private constructor
// and expose "factory" methods that enforce the constraints
//
// In F#, only classes can have private constructors with public members.
//
// If you want to use the record and DU types, the whole type becomes
// private, which means that you also need to provide:
// * a constructor function ("create").
(*
RecursiveTypesAndFold-2.fsx
Related blog post: http://fsharpforfunandprofit.com/posts/recursive-types-and-folds-2/
*)
// ==============================================
// PART 2 - Introducing Folds
// ==============================================
@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:

(*
ParserLibrary.fsx
Final version of a parser library.
Related blog post: http://fsharpforfunandprofit.com/posts/understanding-parser-combinators-3/
*)
module TextInput =
open System

Setup instructions for the 8 hour Domain Modeling Made Functional workshop

Requirements:

  • Git (optional)
  • F#

I will assume that you have git already installed.

Install F#

@swlaschin
swlaschin / DomainModelingMadeFunctional_outline.md
Last active November 11, 2023 11:40
Workshop outline: "Domain Modeling Made Functional"

Workshop: Domain Modeling Made Functional

Functional programming and domain-driven design might not seem to be a good match, but in fact functional programming can be an excellent approach to designing decoupled, reusable systems with a rich domain model. This workshop will show you why.

This will be a hands-on workshop designed for beginners in functional programming. We'll do lots of exercises and build some small projects that take us all the way from high-level design to low-level implementation.

A response to http://ayende.com/blog/170849/why-ravendb-isnt-written-in-f-or-the-cost-of-the-esoteric-choice

Why my F# projects don't use RavenDB, or the cost of the esoteric choice

As you know, I generally recommend using SqlServer for data storage.

But many people have suggested that using RavenDB rather than SqlServer would dramatically reduce the development effort.

My reply to that was that using RavenDB would also lead to a lot more complexity, reduced support by other teams, harder to find DBAs and increased costs all around.

@swlaschin
swlaschin / booklist.md
Last active October 1, 2023 07:42
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