Days 17 to 21 - Reader, Writer, State, Parser Combinators and The International 2016

These five days have been pretty damn long. My progress has slowed down to a crawl lately but far from giving up on it. Bunch of personal issues popping up, so I tend to spend a lot of time thinking about all of it. And lately, I’m having tendencies to lose my patience and get angry really quickly, even at seemingly trivial things. So, trying to work that side of life out a bit. Also, this has nothing to do with me playing the position 5, solo-support/wardbitch in cancerous SEA Dota2 pubs with 3 morons who don’t leave the jungle in forever.

On the #100DaysOfCode side of things, I’ve finished reading up on the Reader and Writer monads, the State monad and a chapter on Parser Combinators. Very interesting and new stuff. I think the chapter on Reader from the Haskell Book has been the first chapter on the book where I actually struggled quite a bit. And I’m probably not the first one to crawl this path.

The thing is, to explain the Reader monad, you first need to learn the Functor and Applicative instances for the (->) r, or the functor/applicative of functions. It’s really spooky at first, but my advice is to just sit down tight, stare at the types and break them down slowly.

Basically, the Monad instance for (->) r is the Reader monad, which lets us read arguments from a shared environment. The confusion for the most part arises at the fact that it is wrapped in a newtype wrapper (Reader), which by the way, isn’t how Reader is actually used in Haskell code. The same thing goes for Writer and State. When learning, just remember that these newtypes are there to help you grasp the concepts. They are actually implemented and used using Monad Transformers, which is something I’m going to study in the next two chapters.

The book doesn’t cover the Writer monad but if you understand the Reader monad, Writer is actually easier. The chapter on State monad kinda felt all over the place. But if you read through it slowly, and google a bit, it isn’t terribly bad. The first part of the chapter focuses on how random numbers are generated in a language like Haskell. The second part is about the State newtype, which also is actually defined as the State monad transformer. Some functions aren’t explained in detail, so a bit of googling around might be needed. The major takeaway from these chapters is to understand what the concept is behind these abstractions, the rest will hopefully be clarified in the upcoming chapters.

The chapter on Parser Combinators was pretty interesting. It goes on to show a LOT of new typeclasses from a bunch of libraries. It uses the Trifecta library for most of the parsing functions. It also covers the Aeson library for parsing JSON. It doesn’t go into a lot of detail, just enough to give the reader a good idea to be able to go out and explore the libraries more on their own.

With that said, here’s a list of useful links regarding these topics that I used during these five days of study.

Alright, so that’s the bunch of stuff I read besides the book chapters to get a better handle on things. I feel like I’ve got them, but I still have those little bits of doubts left. I wanna see if they remain after the chapter on Monad Transformers, because things such as Reader and State get their real-life usage through monad transformers. So getting the view from that angle will probably help me out a lot more.

Other than all of that, Dota2’s The International 2016 tournament just ended a few days ago. 2016 has to be the year of the underdogs. I was originally rooting for OG, like most people. Kinda sad that they got kicked into the lower brackets after placing first in Group A and then eliminated by TnC of all people. TnC is like all the rage in SEA doto right now because it’s a new team and it’s Filipino, so everyone in my pubs now think they are better than 9k MMR.

Digital Chaos came second, beating Evil Geniuses in the Lower Bracket finals. Very exciting matches. Wings played really amazing and definitely deserved the Aegis this year. They were able to play a really diverse set of heroes compared to most other teams. That obviously led to them being able to fit in different drafts and respond to opponents accordingly. Also, I learnt very late that iceice is not iceiceice.

Secret, Na’Vi and Alliance did very poor given their reputation. Make Dendi fountain hook again. Which reminds me, a kinda short film or whatever you wanna call it on Fountain Hooking was released as well, featuring Dendi’s fountain hooks with Pudge, Puppey’s Chen teleportation, rekt TongFu players with extremely commendable sportsmanship, and best of all, a salty Loda. Watch it HERE.

Short Films this year were pretty awesome as well. Maxofs2D won it for the second time in a row. You can check the top three winners HERE, presented by Slacks and Kaci.

On the organizing side of things, I’m really surprised how well Valve managed this big of an event. The hero drafts were shown using some pretty slick Augmented-reality magic on the stream. I’m thoroughly impressed. They even interviewed the team and showed how they made everything happen on the final day. Games started on time, Slacks and Kaci fooling around and interviewing people was pretty chilled and entertaining, Purge became Purge the Weatherman, and most of his laning stage analysis after the matches were really on-point and insightful. The casters were brilliant as well, Twitch chat was cancerous like usual, crowd was pretty hyped. Also, Slacks interviewed a bunch of Dota 2 characters, thanks to the Augmented-reality magic they had set up, which some found to be cringe, but personally, I found it very….Slacksy…geddit? HERE is the one with Windranger. Now that I look back at it, Slacks is probably the best thing that happened in TI 6.

Oh and Valve finally decided to release Pitlord, or Underlord now, during the All-stars match between Team Kaci and Team Slacks, where Slacks switched out n0tail’s selection for Underlord. You can find the clip HERE. It should hit the client on August 23rd, or at least that’s what they said.

That’s great news, but Valve literally dropped the bomb by announcing a new hero for Dota 2 finally. Introducing the Monkey King, inspired by the character Sun Wukong from Journey to the West. From the teaser, it seems like he will be an illusion-based character, with some sort of disguise skill, a knockback attack/nuke and such. Who knows, maybe even a true-strike passive, given that a lot of Dota 2 items are based off character skills. But that probably wouldn’t happen since it’ll just annihilate heroes like Phantom Assassin and Windranger from the game. The hero is supposed to arrive with “The New Journey Update” this fall, so we’ll probably find out then.

Overall, pretty amazing TI this year. I really enjoyed the different panels, the format of the stream, the Augmented-reality stuff, the interviews, the awesome games and upsets, the rise of underdog teams and so on. Now though, let’s enjoy the Post-TI team shuffles and any drama that erupts from it.

Also, this is iceice after winning TI. XD iceice after winning TI 6

I’ll wrap up here today. I’ll be covering Monad Transformers in the next few days, probably won’t have the time for a full tutorial but I will link any and all resources I use along the way. Hope everyone else is having a great time!

comments powered by Disqus