PHP to Haskell: Part One

<PROMISE>I hereby solemnly promise not to show any example code ever, ever, ever, never ever on how to implement some utterly irrelevant and ivory-tower function like calculating Fibonnaci numbers, polynomials or bloody pointless recursive things to work out things that most programmers may have heard about when they were in school but ceased to have any meaningful value the minute school-life ended. Ever.</PROMISE>

Six years ago I taught myself LISP. Then a fews year back I tried everything 'functional' that I could get my hands on, leading to Erlang, Clojure and now, curse it, Haskell. I am not the sharpest tool in the shed by any stretch of the imagination. People tell me I'm "clever", but I know I am only clever enough to know how dumb I really am compared to the really clever people out there.

Like the people that invented Haskell. That's"clever".

If I was "clever" I'd be sat on my arse in my villa writing this whilst the butler knocks up another cocktail before lunch instead of slumming it in a 1934 built bungalow that, although the Luftwaffe missed it the weather didn't and now I don't have to go outside to see if it's raining.

So, this series of articles is all about the blood, sweat and tears that have passed on the way to learning how to use Haskell. I have a feeling this is going to be a life-long thing because in the last eight months, on and off (curse the day job) I have also started reading books on logic, proofs etc. in a bid to expand my mind and still remain this side of Da Law.

Purely Functional

LMFAO. ROFLCOPTER. Pass me the oxygen I can't breathe.

Purely functional of course refers to the nature of the language not the way I can use it. Mostly it seems that stuff I write doesn't functon and won't function until I get it past the evil mother-f*-ing type inference system. The most evil thing on the planet is the Haskell compiler. I hate it. Everytime I utter the incantation "ghc --make ..." I hold my breath and when it sometimes says "Linking..." and then finishes I stare in disbelief that I somehow managed to "sneak one past" the thing.

But seriously though, learning Haskell is not for the overly feint-of-heart! If you are happy to sit in your blub-pit and hack away writing "stuff" and not want to expand your horizons beyond that then stop now. If you choose to continue then think of Neo choosing between the red pill and the blue pill.

How bad can it be?

Imagine the worst day you ever had trying to debug something under pressure, on a client site, at 10 pm with the MD of your company and the oppostion sitting either side asking "Are we there yet?" and you wanting to bitch-slap them to a pulp with the empty Pizza boxes nearby.

It can be worse than that. And remember, you are probably suffering this on your own time. Quit. Stop now. Don't learn Haskell it's too hard for mere mortals.

Bollocks. Here is what I remember to be the fundamental tenet of NLP (neuro-linguistic programming), "What one man can do, another man can do." Not withstanding gender differences and all that, it's essentially on the money. All you need is a clear head, some peace and quiet and a willingness to learn something new.

How good can it be?

Awesome. A legal high if ever there was one. When you start to understand the type system and how it stops you from hanging yourself, once you learn to decipher the terrifying error messages that the compiler throws at you, it starts to feel positively Euphoric.

When do we start?

Now!

I am currently figuring out where to start, I'll be coming at it from a PHP angle as that's my normal day job hammer, although I am "this" close to getting to use Erlang soon. Sweeeeeet.

In the meantime I want you to watch this video as many times as you can until you come back and find I've written part 2.

Brian Beckman -- Don't fear the Monads

Don't really try to understand it. At first, just pick up on the sheer unbridled passion of the speaker and ask yourself "Why?". And when was the last time that you felt that excited about the language you use most of the time?

Watch it until you know it word for word and leave it at that. It will start to open your mind.

Bongggggg.....

Ah so Grasshopper, first lesson end now.

You may leave the monastery....

PS: Part two is ready!

Content Tags: 

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <pre> <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Syntax highlight code surrounded by the {syntaxhighlighter SPEC}...{/syntaxhighlighter} tags, where SPEC is a Syntaxhighlighter options string or class="OPTIONS" [title="the title"].
  • Lines and paragraphs break automatically.

Full HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Syntax highlight code surrounded by the {syntaxhighlighter SPEC}...{/syntaxhighlighter} tags, where SPEC is a Syntaxhighlighter options string or class="OPTIONS" [title="the title"].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.