Category Archives: Haskell

First Step on Learning Haskell

As part of my practicing in functional programming, working on some Haskell program for several weeks. It’s great experience, but the learning cost is pretty high around I/O and Types. I’m pretty much struggling, but there are many nice resource online, and gradually grasping the underling concept.

Especially, http://learnyouahaskell.com/ is a great resource to learn its concept step by step. With some experience on funcational aspect of Erlang/Elixir/Ruby, gradually getting to understand them, though the Monad or IO Action part is difficult to digest yet. Anyway, its declarative expressions are powerful and concise and impressive.

Then, it starts with fibonacci as always.

The pattern match is pretty nice as always. The lazy evaluation and memoziation would be one Haskell’s key factor, and it works nicely.

(on my MacBook Air)

% /usr/bin/time -p runhaskell fib.hs 40
102334155
real        11.71
user        11.49
sys          0.22

% /usr/bin/time -p runhaskell fib_memoize.hs 40
102334155
real         0.30
user         0.16
sys          0.05

References