QED 17: Pythagoras

Share:

Listens: 0

Q.E.D. Code

Technology


The Pythagoreans were a cult of Greek mathematicians that believed that all things were composed of large enough integers. Their leader, Pythagoras, is best known for the proof that the square of the hypotenuse of a right triangle is equal to the sum of the squares of the two sides. Unfortunately, this theorem leads to the conclusion that some numbers cannot be expressed as the ratio of large enough integers, and so proof destroyed their beliefs. Monads are an extremely useful category of type. Whereas Applicatives let us build pipelines of single values, Monads support forking within that pipeline. They provide a "bind" method that joins a function returning another Monad to the end of the pipeline, and then flattens out the result. We can use this to build queries, to eliminate null reference exceptions, and even to execute asynchronous code without nested callbacks. Event Sourcing, popularized by Greg Young, is the practice of storing the events that have occurred in a system, instead of the current state of the system. The benefits are auditability, replayability, and reconciliation. Mathematically speaking, an event sourced system looks like a left fold operation. Starting with the initial state of the system, we apply a function that computes the next state of the system after an event has occurred. This left fold operation computes the current state from the sequence of events.