80

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?
Community
  • 1
  • 1
deceze
  • 510,633
  • 85
  • 743
  • 889
  • 11
    I don't think this is a duplicate. The other question is asking about learning Haskell as a first language, for doing web development. This question is specifically asking what frameworks, template engines and web servers exist. Maybe this question can be reworked? – Tom Lokhorst Aug 10 '09 at 08:05
  • 2
    That's exactly why I branched it off of the other question, which was mainly getting answers with recommendations to learn other languages. This question has a different focus, specifically web-focused projects in the ecosystem for Haskell. :-/ – deceze Aug 10 '09 at 08:37
  • 7
    I would like this open – CiscoIPPhone Aug 10 '09 at 08:50
  • @deceze I've reworked your question a bit. Specifically, I've made the title more distinct from the other question. – Tom Lokhorst Aug 10 '09 at 08:56
  • @Tom Thanks! Hope this distinguishes it a bit better. – deceze Aug 10 '09 at 08:58
  • The bullet points make this sound more like "development components/libraries", than dev ecosystem. If this question aims to encompass ecosystem, shouldn't it entail: testing, continuous integration, documentation, building, deployment, etc, etc? There are many aspects of a "dev ecosystem" that you might be specifically looking for or want to exclude. Maybe my definition of ecosystem is broader than yours though. – StevenC Aug 10 '09 at 18:18
  • @StevenC: I want to know whether it's feasible to write websites in Haskell at all. Testing, deployment etc. solutions would be icing on the cake, feel free to add those in an answer. :) – deceze Aug 10 '09 at 23:43
  • Voted to reopen too. Anyone else would like to have an up to date answer for this question ? – jhegedus Oct 08 '15 at 14:45
  • @skaffman how many reopens are needed ? – jhegedus Oct 08 '15 at 14:47

5 Answers5

36

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
  • 2,239
  • 3
  • 25
  • 26
18

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
  • 13,658
  • 5
  • 55
  • 71
14

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.

Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555
luntain
  • 4,560
  • 6
  • 37
  • 48
9
  • 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
  • 137,316
  • 36
  • 365
  • 468
7

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
  • 3,928
  • 22
  • 21