The HaskellTorrent package

HaskellTorrent provides a BitTorrent client, based on the CML library
for concurrency. This is an early preview release which is capable of
downloading files from various torrent trackers, but have not yet
demonstrated to be correct in all aspects.
It is expected that the package currently contains numerous and even
grave bugs. Patches to fix any problem are welcome!

Debugging

For debugging, jlouis tends to use the following:

make conf build test

This builds HaskellTorrent with the Debug flag set and also builds the software with profiling
by default so it is easy to hunt down performance regressions. It also runs the internal test-suite
for various values.

Reading material for hacking HaskellTorrent:

Protocol specification - BEP0003:
This is the original protocol specification, tracked into the BEP
process. It is worth reading because it explains the general overview
and the precision with which the original protocol was written down.

Bittorrent Enhancement Process - BEP0000
The BEP process is an official process for adding extensions on top of
the BitTorrent protocol. It allows implementors to mix and match the
extensions making sense for their client and it allows people to
discuss extensions publicly in a forum. It also provisions for the
deprecation of certain features in the long run as they prove to be of
less value.

wiki.theory.org
An alternative description of the protocol. This description is in
general much more detailed than the BEP structure. It is worth a read
because it acts somewhat as a historic remark and a side channel. Note
that there are some commentary on these pages which can be disputed
quite a lot.

"Concurrent Programming in ML" - John. H. Reppy
This book describes the CML system which HaskellTorrent uses. The basic
idea of CML is that of higher order events. That is, events which can
be abstractly manipulated before being synchronized on. For instance,
CML events are a Functor instance, though the code currently does not
reflect that. This also provisions for fair selective receives
with dynamic choice of which events may fire.