I wrote in an earlier post about how the brew build of unison is broken due to it defaulting to ocaml 4.02. Back then it was possible to checkout an old version of ocaml but since then changes to brew seem to have closed that option. Instead of being able to use brew to install a particular version of unison I had to install it from source and include the correct version of ocaml. This is how I did it.
First uninstall any existing brew installations of unison and ocaml
brew unlink unison brew unlink ocaml
Then download ocaml 4.01 and compile from source.
wget http://caml.inria.fr/pub/distrib/ocaml-4.01/ocaml-4.01.0.tar.gz tar -xvzf ocaml-4.01.0.tar.gz cd ocaml-4.01.0 ./configure make world.opt sudo su umask 022 make install exit
Finally, download unison 2.40.102 and compile from source
wget http://www.seas.upenn.edu/~bcpierce/unison/download/releases/unison-2.40.102/unison-2.40.102.tar.gz tar -xvzf unison-2.40.102.tar.gz cd unison-2.40.102 make UISTYLE=text
The unison binary is in the current directory. Just copy it to a location within your path and you should be set to go.
Featured photo by Kuba Bożanowski (https://www.flickr.com/photos/jbozanowski/4132669334/).