13 Event sourcing: A functional approach to persistence

This chapter covers

  • Thinking functionally about persisted data
  • Event sourcing concepts and implementation
  • Architecture of event-sourced systems

In chapter 11, you saw that in FP we avoid mutating state, especially global state. Did I mention that the database is also state, so it too should be immutable? What? Yes, didn’t you see this one coming? A database is, conceptually, just a data structure. Whether it’s stored in memory or on disk is ultimately just an implementation detail.

You saw in chapter 12 how functional data structures, although immutable, can evolve: you can create new states or new views of any given structure that are built on but don’t alter the original structure. ...

Get Functional Programming in C#, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.