Inspired by the ease with which Joe Gregorio put together a framework
in Python using some components [1] I'm inspired to create some
components of my own so the same thing can be done in Haskell. I'm
aiming for creating some thing /really/ simple and I want to start
with writing a templating system or a database wrapper. But first,
what has been done in this area already already? I'm aware of at least
some template like efforts [2]. For the templating system I don't
think I want a DSL like approach (ala Lisp with (body (h1 "Foo")) etc.
but rather a solution where code and templates are kept separate.
Here's a really simple interface.
compileTemplate :: Stringable a => a -> Template
renderTemplate :: (Show a, Stringable b) => Template -> Map Stringable a -> b
Or something along those lines. Compiling the template makes
subsequent rendering faster and ByteString adds even more speed.
With some templating language like so:
<html>
<head>...</head>
<body>
<h1>{{ title }}</h1>
</body>
</html>
'title' is looked up in the Map when the template is rendered. The
other option would be inline Haskell code:
<html>
<head>...</head>
<body>
<h1><% postTitle title %></h1>
</body>
</html>
Where 'title' is a record data type. There's also a middle ground like
with Django's templates that supports restricted inline code. I guess
the restriction is unnecessary in Haskell as we can disallow mutation
of values quite easily (?).
1. http://bitworking.org/news/Why_so_many_Python_web_frameworks
2. http://blog.moertel.com/articles/2006/10/18/a-type-based-solution-to-the-st…
Henning,
This link is broken for me...
On 4/3/07, Henning Thielemann <lemming(a)henning-thielemann.de> wrote:
>
> It was argued that people avoid Haskell because of terms from Category
> theory like 'Monad'. This problem can now be solved by a wrapper which
> presents all the WWW without monads! Start e.g. at
> http://saxophone.jpberlin.de/MonadTransformer?source=http%3A%2F%2Fwww%2Ehas…
> Of course the tool is written in Haskell, that is, Haskell helps solving
> problems which only exist because of Haskell.
> Bug reports and feature requests can be tracked at
> https://sourceforge.net/projects/parallelweb
> _______________________________________________
> Haskell mailing list
> Haskell(a)haskell.org
> http://www.haskell.org/mailman/listinfo/haskell
>