Skip to content

Instantly share code, notes, and snippets.

@gregoryyoung
Created June 24, 2015 13:25
Show Gist options
  • Save gregoryyoung/a3e69ed58ae066b91f1b to your computer and use it in GitHub Desktop.
Save gregoryyoung/a3e69ed58ae066b91f1b to your computer and use it in GitHub Desktop.
Event Sourcing as 3 functions.
f(events) -> state
match f(state, event) -> state
f(state, command) -> events
@fride
Copy link

fride commented Jun 25, 2015

I'm not sure about the semantics of ' match f(state, event) -> state'. Care to explain?

@jbrains
Copy link

jbrains commented Jun 25, 2015

I'm guessing it's "figure out which ones of events apply to state, then apply it."

@fride
Copy link

fride commented Jun 30, 2015

Sounds sensible.

@kijanawoodard
Copy link

Given a state and a event, produce a new state

match is how you progress through the collection of events - f(events)

@gregoryyoung
Copy link
Author

@kijanawoodard yes.

in some systems it may even be more complex than just match by type (see erlang/haskell)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment