[web-devel] [Yesod] Creating a static link

Rafael Cunha de Almeida rafael-lists at kontesti.me
Sun Feb 13 16:26:24 CET 2011


Michael Snoyman <michael at snoyman.com> disse:
> You could go either way on that one. The content of an interpolation
> is specifically *not* a fully-powered Haskell expression.

Why is that? I have a little experience with RoR, there I could do
something like this:

    - @people.each do |person|
        = person.name

I think you don't want to have a fully-powered Haskell expression to
avoid people adding too much code to the view (thinking in MVC pattern).
However, it's not like people can't do it just because it's a little
harder. Meanwhile, there are a lot of useful things that could be done
if all (or most) haskell syntax was allowed to be interpolated.

Instead of having special syntax like $forall, wouldn't it be better to
just provide monad tranformers to allow for those sort of loops? 
Something like Control.Monad.LoopWhile module provides. That way hamlet
would need only to provide a ${} syntax that allow for adding haskell
code which will be evaluated but won't print anything to the site. That
way things could work a lot like in ruby, which I think makes things a
lot simpler.

Allowing for a new sort of interpolation and any sort of haskell
expression to be interpolated, hamlet wouldn't need to create its own
flow control statements. The user could write their views freely using
only haskell syntax when code logic is required.

[]'s
Rafael



More information about the web-devel mailing list