The free monad in (almost) real life

Tweet about this on TwitterShare on LinkedInShare on FacebookShare on Google+Share on Reddit

Now that we have a fairly good understanding of what the free monad is and how it works. Let’s see what it looks like to write a real program based on this concept. This time we won’t implement Free ourselves but use the cats library for that. If you don’t know all the theory behind the free monad and just want to see how to use it then read on as this post builds an application from scratch.

In this post we’ll write simple DSLs, lift them into the free monad and even combine them into one program. There is some boiler plate around but I want to get a feeling of what it looks like to combine more DSLs and see how we can architecture a whole application around the free monad. Continue reading “The free monad in (almost) real life”

The Free monad explained – part 2

Tweet about this on TwitterShare on LinkedInShare on FacebookShare on Google+Share on Reddit

Remember in part 1 we implemented a little program to interact with the user. We nicely separated the business logic from the implementation. And as good as it is we now need to add more functionality to our application and this exactly what we’re going to cover here.

The idea is to define a new language for user authentication and then combine it with the user interaction language to build a more complex program.
Continue reading “The Free monad explained – part 2”

The Free monad explained – part 1

Tweet about this on TwitterShare on LinkedInShare on FacebookShare on Google+Share on Reddit

My next series of blog posts will be on the Free monad.  Don’t be scared by the name, it’s not so difficult to grasp it (if explains correctly) and your code could greatly improve.

Why ? Because it allows a clear separation between the program definition (i.e. the business logic) and its implementation. That means if one day you decide to change your implementation (e.g change your persistent storage) you just need to re-write your interpreter – leaving the business logic untouched.
Continue reading “The Free monad explained – part 1”

Distributed training of neural networks

Tweet about this on TwitterShare on LinkedInShare on FacebookShare on Google+Share on Reddit

Distributed training of neural networks is something I’ve always wanted to try but couldn’t find much information about it. It seems most people train their models on a single machine.

In fact it makes sense because training on a single machine is much more efficient than distributed training. Distributed training incurs additional cost and is therefore slower than training on a single machine so it must be reserved only for cases where the neural network or the data (or both) don’t fit on a single machine.
Continue reading “Distributed training of neural networks”

Multi-Paxos

Tweet about this on TwitterShare on LinkedInShare on FacebookShare on Google+Share on Reddit

Last week we’ve seen how basic Paxos works. Today we’re going to extend it in order to run a distributed state machine  – a state machine with the same state on all the nodes.

The idea is to use a distributed log to run the state machine. Each entry in the log is an operation to apply to the state machine. If the log is the same on every node then the same operations are applied in the same order on all the nodes and therefore the state machines are all in the same state.

2 nodes in cluster using paxos to maintain a distributed log to replicate a state-machine
2 nodes in cluster using paxos to maintain a distributed log to replicate a state-machine

The question is :

How to make sure the log is the same on all the nodes?

The solution is to run basic-Paxos for every log entry (plus add some tweaks to solve some issues and improve performance)
Continue reading “Multi-Paxos”