Purely functional Haskell implementation for <https://github.com/alexander-b/master-thesis>.