Learning Haskell, again

Haskell is one of those languages that I would like to learn, but haven’t ever really learned. Since now is as good time as ever to learn something new, I picked it up again and started slowly working through some books and examples.

My first try learning Haskell was sort of half-hearted one. I read some forums, checked couple tutorials and wondered about monads. This of course didn’t lead to much success, unsurprisingly.

Next time I actually started doing a course that has lecture notes and assignments available online. This time I actually started learning something useful and was making decent progress, until I decided that I would like to make a game. I ended up finding LambdaHack, a really cool roguelike engine written in Haskell. It was easy enough to get started modifying it and soon enough I had a game running, thanks to Mikolaj Konarski. But because I didn’t really understand what I was doing, I soon lost interest and gave up.

Third time is a charm, or so they say. This time I’m trying to work my way through the couse, do all assignments and read all the suggested chapters. It does help that I have played quite a bit with Hy and Hymn in the meantime, as maybe now I have slightly better understanding on functional programming (and monads, thanks to Philip Xu). This time I’m trying to fight the urge to code complicated game projects, before I understand the language better (although I have this neat idea for a tiny game, that I could maybe code someday).

So far the course has been familiar, since I worked my way through these things before. It’s basically an introduction anyway at this stage, going through various syntactic structures and their uses, recursion and such (although I must add that I’m still fascinating how neat the solution for Tower of Hanoi puzzle is):

type Peg = String
type Move = (Peg, Peg)[Move]
hanoi :: Integer -> Peg -> Peg -> Peg -> [Move]

hanoi 1 a b _ = [(a, b)]
hanoi n a b c =
   hanoi (n - 1) a c b ++ hanoi 1 a b c ++ hanoi (n - 1) c b a

*Main> hanoi 3 "a" "b" "c"

So, here’s hoping that this time I manage to concentrate on important things first and try my hand at writing games a little bit later.


2 thoughts on “Learning Haskell, again

    • Thanks, good luck to you too. So far so good and I’m having fun learning new things again. Although, this afternoon I’m going to spend tinkering with my lisp project. Always so hard to juggle between many projects, but I just can’t choose just one, heh.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s