jeanqasaur/markov-tweets — pull request #1 by yamadapc (2014-11-21 06:53:33+00:00)
Title: Updates and optimisation

Clean-up
--------
This refactors the code, trying to make the style consistent all around
changing as little as possible of the core principles and making more
use of pattern matching and guards.

Optimisation
------------
It also optimises the code by:
- Using a "cached" `length currChain` value instead of recomputing it
every time (this has a serious impact on time)
- Using a linked list throughout the process (that decreases allocation
in the `buildChainHelper` function, but have minimal impacts on time)

On my machine, these two changes make our code compiled with `-O2` go
from spending 12-15 seconds per generation of a Markov chain from a
`323K` file to 0.2-0.42 seconds. That makes our implementation not look
too sad compared to the `go` implementation - which takes about
0.07-0.08 seconds with the same input.

Though this is good enough, it'd be nice seeing how much would have to
be done to obtain a performance boost from parallelizing the code - vs
the same changes in an imperative language.

Zulip Bot
---------
A zulip bot was also added for creating generalized text generation chat
bots from a set of text files. I don't really know if this is useful and
it's possible to disable the compilation of the bot and it's
dependencies with `cabal install -fno-zulipbot`. I'll gladly make the
bot's compilation disabled by default, since that's only like that
because having all dependencies integrates better with tooling.