[Haskell-cafe] Haskell Web Framework

Marc Weber marco-oweber at gmx.de
Mon Jan 26 06:57:20 EST 2009


Hi Michael Snoyman, Donnie Jone,

I don't think cross posting to web-devel and haskel-cafe is a good idea.
Maybe do that but then advice people to either reply to cafe or to
web-devel. So I suggest that we continue this discussion on web-devel.

First of all there have been some attempts already to provide web
frameworks for haskell.

If you don't konw WASH yet please do have a look at the examples.
I find the idea behind WASH pretty neat.
It does also solve parts of the strict XHTML problem. you can only add
valid tags and attributes. However it doesn't pay attention to order.
(I don't think it was possible that time WASH was written).

I've tried to make it better and verify that only valid XHTML is
generated.

The result is a finate state machine implented using functional
dependencies.

You can get the code from here git://mawercer.de/vxml..

However while doing so I noticed that this starts turning into a typing
hell.. Why?
There are some tags which require one or more childs (example : <ul>).
So to distinguish both states (empty ul, ul with at least one element
which may be closed) you need two different types. Thus you can no
longer do
  myUl = ul $ map (li . show) [1...]

My solution was to switch to a weak checking which only allows valid sub
tags but does no longer care about order etc.

So by now I'd vote for a partial validation only. a total validation
isn't worth the effort. But it would be nice to to derive that from some
specification (such as XHTML). So maybe have a look at my library and
use the weak validation mode.

About Ajax:
I've developped some Ajax applications beeing written in PHP using
MySQL..

In WASH everything is simple: You have one state (it doesn't know about
AJAX). From that state you can go on, duplicate it etc. The state is
passed to the client using an hidden input. So there is not that much
you have to care about. But you can't write that much interaction easily
either.

When starting to write a web application (say a web shop).. it would be
best if the client page keeps a state knowing about the basket and its
content as well. And if you start implenting fancy features such as drag
and drop I'm no longer sure which is the best way to handle this
"client" state. I even don't know wether it can be abstracted on server
side (using any language)..

I'll watch you, keep posting to this list about your progress.

Comments about the blog post (http://blog.snoyman.com/2009/01/25/haskell-web-framework/)

  Maybe the first step is writing down differences between existing
  haskell web frameworks. Probably the haskell wiki would be a good place
  to start.

  Another first step might be writing kind of abstraction so that an
  application can use either HAppS or apache or (fast)-CGI etc..

  Encrypted cookies :-) Nice idea..
  However this does mean a lot more traffic, doesn't it?
  It also depends on your storage enginge. If you have once keeping stuff
  in memory this won't hurt that much.
  But you're right. I'll think about that option

  About 13.:
    We should be able to simply specify the algorithm necessary to
  calculate an age from a birthday, and the framework will convert this
  into both client- and server-side code

  There is already a haskell -> JS converter..
  However this will cause a lot more traffic. And if you have many users
  only loading the front page ..
  How do you want to utilize the power of existing script frameworks (eg
  Mootools) ?
  Should the engine be aware about those?

  What about CSS abstraction ? I mean ie6 does read some CSS properties
  quite different..

  What about JS automatic compression (maybe even rewriting names to
  shorter ones)?

Sincerly
Marc Weber


More information about the Haskell-Cafe mailing list