These are chat archives for vu3rdd/functorrent

26th
Jul 2015
Ramakrishnan Muthukrishnan
@vu3rdd
Jul 26 2015 02:19
Yes, I agree. We should spend more time and effort to make our code more idiomatic Haskell. For that we should know what idiomatic Haskell mean. And for that we should read a lot of other's code, which mostly look like (in my case) reading a line and then scratching the head for the next 10 min, firing up ghci and looking at the types and getting some aha moment 10 minutes later.
.. and then I forget about it and don't ever use it when it comes to writing my own code. Perhaps we don't write haskell everyday and that's the reason.
Jaseem Abid
@jaseemabid
Jul 26 2015 02:21
Could be. I dont mind the aha moments, so I'm happy and ok
Ramakrishnan Muthukrishnan
@vu3rdd
Jul 26 2015 02:26
But yeah, we will get there. I am quite sure about it.
Jaseem Abid
@jaseemabid
Jul 26 2015 02:26
Code samples from the book
Stuck on a horribly small internet. git cloning that is gonna overshoot my monthly FUP :(
Better than dealing with MVars ddirectly
^ one file is so elegantly done. In terms of code, concepts, ideas as well as performance.
Ramakrishnan Muthukrishnan
@vu3rdd
Jul 26 2015 02:31
I haven't yet started reading the STM portions of the book.
Jaseem Abid
@jaseemabid
Jul 26 2015 02:32
startTorrent :: Log -> [Metainfo] -> IO () in src/Main.hs is dead code. I should look for some dead code detection tools
How's the file download coming along?
Ramakrishnan Muthukrishnan
@vu3rdd
Jul 26 2015 02:39
download works. Single peer, single thread.
only that the single peer should have all the pieces. :D
but it is easy to modify to make it ask other peers if one peer does not have everything. the data structures are in place and works.
Jaseem Abid
@jaseemabid
Jul 26 2015 02:41
Lets get that merged asap.
Also, we havent checked in a long while if Haddock works
Ramakrishnan Muthukrishnan
@vu3rdd
Jul 26 2015 02:46
so scared to use my phone now. It reboots randomly when I wake it by pressing the power button.
yes, I will merge and send a PR sometime this week. Tomorrow onwards, the drudgery starts
Jaseem Abid
@jaseemabid
Jul 26 2015 02:48
Should I read the code on a topic branch? Integrating into the whole thread business will need some work
Ramakrishnan Muthukrishnan
@vu3rdd
Jul 26 2015 02:50
yeah, that will be great. I have it on the master branch itself. Should have worked on a topic branch.
Peer.hs has most of my additions.
Jaseem Abid
@jaseemabid
Jul 26 2015 02:53
Okay. Its trivial to rename master to topic
Jaseem Abid
@jaseemabid
Jul 26 2015 03:04
Is this expression (doInitialization >=> mainLoop) >> doExit equivalent to
controlThreadMain :: ControlThread -> IO ()
controlThreadMain ct =
    doExit =<< (mainLoop <=< doInitialization) ct
?
The first gives me an impression that data flows from left to right. Like pipes. The second (current code) makes it one large composition
Looks like its not. The code compiles, but the types dont look right to me :/
Jaseem Abid
@jaseemabid
Jul 26 2015 03:10
This seems right ((doInitialization >=> mainLoop) ct) >>= doExit. Which is lot more elegant in the opposite direction.
Ramakrishnan Muthukrishnan
@vu3rdd
Jul 26 2015 05:51
somewhat off topic: anyone here reading "Cakes, custard and category theory"? wonderful book, highly recommended. And cheap as well.
I have seen a lot of code defined using the flipped Bind.
perhaps defining controlThreadMain is the above way using =<< is not so intuitive, why think in the opposite direction?
Ramakrishnan Muthukrishnan
@vu3rdd
Jul 26 2015 08:15
I am going to refactor msgLoop. Will merge only after that is done. It is so ugly at the moment.
reviews and suggestions always welcome.
Jaseem Abid
@jaseemabid
Jul 26 2015 09:17
That needs simplification :/
Ramakrishnan Muthukrishnan
@vu3rdd
Jul 26 2015 23:14
I am thinking about changing some data structures that will automatically lead to simplifications.
Ramakrishnan Muthukrishnan
@vu3rdd
Jul 26 2015 23:27
I wanted to implement the msgloop as a state machine
we start out being notInterested and choked.
after handshake, we send an Interestedmsg.
if we get back an unchoke msg, we can get into business of downloading pieces.
if not, we are stuck, so we knock at another peer or wait for an unchoke msg from the same peer with whom we got interested.
perfect thing to implement with a state machine.
But implementing a state machine in haskell would probably need a continuation monad.