Skip to content

Instantly share code, notes, and snippets.

@Fristi
Fristi / Aggregate.hs
Last active November 6, 2022 20:50
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
}
@sordina
sordina / demo1A.agda
Created July 4, 2012 17:28
A quick introduction to Agda
-- Hello Agda Enthusiasts!
-- Let's play with Agda.
-- Firstly, since we're editing demo1A.agda, let's name our module correctly:
module demo1A where -- Load the file with C-c C-l - Like that!
-- Syntax is highlighted by Emacs