Hello, Haskell (from the web)!
25 Dec 2012Introduction
The best part about technology is the ability to use anything you want. I’ve run across many frameworks all touting their own awesomeness. Sometimes though, you just need to smash a bit of output back to the client. Using the CGI and XHTML libraries available for Haskell, web programming is so simple. Just about every web server known to mankind can run a CGI program and if yours can’t, it may need a trip to the gym.
Show me some code
Excellent. This is where it gets very interesting. I realise at first, when you’re reading this code you’re going to be saying “well, duh - I can knock out a HTML page to be statically served much easier than this B.S.” If this is your train of thought, you may have missed the point. The example I provider here is only to demonstrate to the reader how we can get Haskell closer to the client generation.
This should be fairly easy to follow. There’s nothing out of the ordinary and it’s very simple. After reading this document I was impressed that this could be condensed down into the following:
Damn! Not bad. And, here’s the output that you get from running these CGI programs:
At the moment, I can see how this looks like a long way around and it certainly is a feathers over steam-train approach to delivering a static page but we’ve now got the power of Haskell behind our CGI program.