Skip to content

Instantly share code, notes, and snippets.

View sheridanchris's full-sized avatar
🦥
Domain driven laziness

Christian Sheridan sheridanchris

🦥
Domain driven laziness
  • 03:35 (UTC -06:00)
View GitHub Profile
@Savelenko
Savelenko / Program.fs
Last active November 14, 2022 12:56
A modeling exercise in two acts with banning or verifying users in F# and the Onion architecture
(*
An exercise in modeling. Users can be verified or banned. A user can be banned only if their username is "offensive".
We assume the Onion architecture. Modules `User` and `Verification` belong to the model. Module `UserVerification`
belongs to the application layer. Data access layer is omitted completely; it should be fairly trivial.
Note that the verified/banned aspect of a user is modeled "externally" to the notion of user itself. In particular,
there are no "aggregates" below which combine all aspects of a user.
*)
@Banashek
Banashek / prettmaps-fablepy.fs
Created July 21, 2022 19:42
Quick and dirty fable-py prettymaps. Very dynamic for proof of concept.
open Fable.Core
open Fable.Core.PyInterop
open Fable.Python.Json
[<ImportAll("sys")>]
let sys: obj = nativeOnly
let prettymaps: obj = importAll "prettymaps"
let matplotlib: obj = importAll "matplotlib"
@akhansari
akhansari / event-sourced-user.fsx
Last active December 16, 2022 00:09
F# : Event Sourcing in a nutshell
// ========= Event Sourcing in a nutshell
(*
FriendlyName: string
Aggregate friendly name.
Initial: 'State
Initial (empty) state we will start with.
Decide: 'Command -> 'State -> 'Event list
@JordanMarr
JordanMarr / DragDropPage.fs
Last active October 11, 2024 06:00
Fable bindings for "react-dnd" using HTML5 provider
module DragDropPage
open Feliz
open Fable.React
open Fable.React.Props
open ReactDND
type Language = {
Name: string
}
@swlaschin
swlaschin / effective-fsharp.md
Last active October 20, 2024 12:47
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

(*
CapabilityBasedSecurity_ConfigExample.fsx
An example of a simple capability-based design.
Related blog post: http://fsharpforfunandprofit.com/posts/capability-based-security/
*)
/// Configuration system
module Config =