Skip to content

Instantly share code, notes, and snippets.

View gertverhoog's full-sized avatar

Gert Verhoog gertverhoog

View GitHub Profile
@ordnungswidrig
ordnungswidrig / handler-protocol.clj
Created June 22, 2011 22:27
Define events a protocol methods
;; On my journey into event sourcing in clojure I'm trying different approaches
;; of modeling events and event handling in clojure.
;; A little ceremony to pay homage to the gods of clojure:
(ns handler-protocol
(:use clojure.contrib.trace)
(:use clojure.pprint)
(:use clojure.test))
;; My example problem domain for this will be a very simple sketch of twitter.
@ordnungswidrig
ordnungswidrig / state-is-a-fold.clj
Created June 16, 2011 15:50
State is a fold over events
(ns state-is-a-fold
(:use clojure.test))
;;; After all, state is a fold of events. For example let's say the events are a sequence of numbers
;;; and we are folding by addition:
(deftest simple
(let [events [1 5 2 4 3]
state (reduce + events)]
(is (= 15 state))))