views:

1979

answers:

5

Inspired by this question and a recent affair, I'm wondering what's involved with Haskell web development.

  • Are there any Haskell web frameworks or template engines?
  • How would hosting a Haskell site work, are there suitable web servers?
  • Is Haskell too complex for the usual rapid development and prototyping based workflow often used in web development?
  • Are there examples of existing Haskell web applications?
+12  A: 

First of all, a disclaimer: I've never done any Haskell web development, so I don't speak from experience.

If you look at the Web category on Hackage, there are lots of web-related packages.

I think most Haskell web application run on a custom server (possibly using Apache's mod_proxy or IIS's Advanced Request Routing as a front end). However, there are also some FastCGI bindings.

The most prominent Haskell webserver/framework/datastorage infrastruction is Happstack, which is interesting for several reasons, the most obvious being that it stores all its state in-memory and doesn't use a relational database.

Another more recent webserver interface is hack, which I don't know much about except that the 1 minute tutorial looks interesting.

There are many more webservers/frameworks in Haskell, but these two are just the ones I know of the top of my head.

Tom Lokhorst
+2  A: 

First, damn if that "affair" link wasn't one of the funniest things ever!

Now, while I posted an answer on the other link, I don't think much is happening in Haskell web land. You've got Happstack and maybe a few other frameworks that don't seem to go anywhere. Then you've got FastCgi.

If your like me, then FastCgi is probably good enough for most of your needs. Most clients, I find, don't really have scale issues (and, besides, its good enough for the Ruby folks, right).

If FastCgi ain't your speed...well, perhaps yaws or lift (Erlang and Scala, respectively) are worth a look.

Shaun
+4  A: 
  • Are there any Haskell web frameworks or template engines?

There are many web frameworks. Look in the Web category: http://hackage.haskell.org/packages/archive/pkg-list.html#cat:web

For templating, HStringTemplate seems to be the brand leader: http://hackage.haskell.org/package/HStringTemplate

  • How would hosting a Haskell site work, are there suitable web servers?

Statically linked binaries running their own web server (e.g. happstack-server or one of the other Haskell web servers), Haskell binaries talking to Apache, ... pretty much every combination you could think of.

  • Is Haskell too complex for the usual rapid development and prototyping based workflow often used in web development?

No. And you'll get stronger guarantees the app isn't faulty thanks to the type system.

  • Are there examples of existing Haskell web applications?

hpaste is a simple demo for happstack. Tupil.com entire business is Haskell web apps. Deutsche Bank gave a talk at CUFP last year on their internal Haskell web frameworks (based on happstack).

Don Stewart
Well, Tupil also does a lot of iPhone app development (in Objective C). They don't _just_ do Haskell web apps.
Tom Lokhorst
Yes, very good point, Tom.
Don Stewart
+8  A: 

I have done real production web applications in Haskell. Here is the stack I used:

  • PostgreSQL database backend
  • HDBC Postgres to connect to it
  • XHTML to generate Html. It is a bit of a funny syntax, but at least you have lambda-abstraction.
  • Fastcgi to connect the backend to the lighttpd, doing the web serving.

The whole web application is a single haskell program, compiled to native code ghc. I wrote the code to do request routing (and reverse routing) by hand.

Phil
+3  A: 

I have used Happstack to create a simple webapp/webservice for our local intranet.

  • It stores data in memory with a transaction log for recovery (standard with Happstack). You will not find SQL in the code anywhere.
  • No templates. What one would usually do with templates, I do in Javascript. Just get the data in JSON format, and put it into the DOM.

There are just 169 lines of Haskell code, all in Main.hs, which define the server. The rest is Javascript for presentation, and some Python for testing.

It is open source, you can check it out on github, and maybe use it as a starting point.

luntain
Line 82, you forget a closing quote.
Rayne
Haskell allows for quotes in identifiers. Sad, that github's syntax highlighting falls over that.
luntain