Html To Haskell
Posté par alpheccar le29 Jan 2007 à 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 !


Merci
Posté par Squark le25 Jui 2007 à11:43 CEST
Merci :)
Posté par alpheccar le24 Jui 2007 à20: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
Posté par Squark le24 Jui 2007 à20: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!