[web-devel] Re: On the state of Haskell web frameworks

Chris Eidhof chris at eidhof.nl
Wed Sep 22 12:27:26 CEST 2010

Hi Chris,

First of all: this is an excellent writeup, and very useful for future reference. Thanks a lot for sharing.

On 19 sep 2010, at 12:49, Christopher Done wrote:

> 3. Takusen: I needed to talk to a PostgreSQL database to save/read
> pastes, just a few lines (for setup) in an isolated module:
> http://github.com/chrisdone/amelie/blob/master/src/Amelie/DB.hs

Would you use this for larger projects? I always feel that this is too low-level (coming from Rails). There is Michael's work on his persistence library, Kevin's work, and I'm also playing around in this area.

> All of these libraries are perfect, they do one thing and do it well.
> I just imported them and they did the work for me. You can see also
> how they are modules in themselves, not interdependent as part of some
> grand framework. It seems that with good libraries, the architecture
> of your web app just designs itself. Personally I've always thought
> the "MVC" approach isn't particularly novel and follows naturally from
> good design. I'm not saying mine is good design, but without putting
> much conscious thought towards it, I've ended up with a DB module
> (model), a Pages module (controller) and a HTML module (view). To make
> this into the MVC approach, I'd just rename them to Model.hs,
> Controller.hs and View.hs.

That is great. Maybe, in larger projects the boundaries might not be so clear. I think design patterns are overrated for small projects, but become really beneficial once you scale up.

> 7. URI routing:
> http://github.com/chrisdone/amelie/blob/master/src/Amelie/Routes.hs
> How to receive requests and map that into a page + parameters to that
> page (e.g. paste/pid/30196 -> pastePage [("pid","30196")]), how to
> *generate* a URL with parameters.
> And how to generate a *pretty* URL:
> http://github.com/chrisdone/amelie/blob/master/src/Amelie/Links.hs A
> URL that maps back to a normal URL (e.g.
> http://hpaste.org/30196/half_a_proof is actually rewritten by nginx to
> http://hpaste.org/paste/id/30196). I think there probably are quite a
> few URI routing libraries out there but I only gave it a cursory
> glance.

Have you looked at the web-routes package? Again, this might only be useful for more complex applications. The idea is that you use datatypes to encode all possible URLs, and linking is then done by building a value of that datatype: it is not possibly anymore to build invalid URLs.


More information about the web-devel mailing list