What is the ecosystem for Haskell web development?

Haskell

Haskell Problem Overview


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?

Haskell Solutions


Solution 1 - Haskell

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.

Solution 2 - Haskell

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.

Solution 3 - Haskell

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.

Solution 4 - Haskell

  • 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).

Solution 5 - Haskell

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondecezeView Question on Stackoverflow
Solution 1 - HaskellPhilView Answer on Stackoverflow
Solution 2 - HaskellTom LokhorstView Answer on Stackoverflow
Solution 3 - HaskellluntainView Answer on Stackoverflow
Solution 4 - HaskellDon StewartView Answer on Stackoverflow
Solution 5 - HaskellShaunView Answer on Stackoverflow