Banner

Html To Haskell

Posted by alpheccar - Jan 29 2007 at 18:51 CEST

I am a coder and I am very very bad at graphics. I have some friends who are good at graphics but very very bad at programming. And, unfortunately, most web frameworks are using templating systems which are mixing code and html. Either the templating system is useful for graphic people and weak on programming or it is providing all the power of a functional programming language but it is not very easy to use for graphic people.

So, I decided to experiment. Would not it be cool to be able to embed the Html inside the programming language ? I mean : having an Haskell function written with an embedded DSL and whose output is the original Html document.

In any other language than Haskell, I would never have attempted such a thing. But, in Haskell and thanks to some powerful librairies (HXT) it was a 100 line hack ! and I wrote some comments !

Of course, I am not taking into account all cases. It is a very quick and dirty hack just for fun and experiment. Nevertheless, it was really easy and quick to write it. The more I code with Haskell and the more I enjoy it.

The source code is attached to this post. Have fun !

Tags | |

Attachments

Comments

Add a comment...

Merci

Posted by Squark - Jul 25 2007 at11:43 CEST

Merci :)

Posted by alpheccar - Jul 24 2007 at20:17 CEST

Cela convertit un fichier HTML en un fichier Haskell qui, lorsqu'il sera executé, générera l'HTML d'origine en utilisant le module Text.XML.HXT.

Initialement, je voulais créer un préprocesseur Haskell me permettant de mettre de l'HTML directement dans mon code Haskell.

Je n'ai pas bien compris

Posted by Squark - Jul 24 2007 at20:02 CEST

Je n'ai pas bien compris à quoi servait ce code alors je vous demande si vous pouviez expliquer ça en français en quelques lignes :) Merci d'avance!