Skip to content

Instantly share code, notes, and snippets.

// adapted from https://github.com/gregoryyoung/m-r/blob/master/SimpleCQRS/CommandHandlers.cs
// actual code https://github.com/thinkbeforecoding/m-r/tree/FSharp/FsSimpleCQRS
module Commands =
//[<Abstract>]
type DeactivateInventoryItem =
{
InventoryItemId: Guid
OriginalVersion: int // version I'm acting on, for checking to make sure my change only fires if the data the change was based on is still unchanged
@debach
debach / Aggregate.hs
Created June 19, 2020 12:24 — forked from Fristi/Aggregate.hs
DDD/Event Sourcing in Haskell. Implemented an aggregate as a type class and type families to couple event, command and error types specific to the aggregate. Errors are returned by using Either (Error e) (Event e). Applying Applicative Functors fits here well to sequentially check if the command suffice.
{-# LANGUAGE TypeFamilies #-}
import Data.Function (on)
import Control.Applicative
data EventData e = EventData {
eventId :: Int,
body :: Event e
}