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

Rafael Cunha de Almeida rafael-lists at kontesti.me
Sun Feb 13 17:07:38 CET 2011

Dmitry Kurochkin <dmitry.kurochkin at gmail.com> disse:
> On Sun, 13 Feb 2011 13:26:24 -0200, Rafael Cunha de Almeida <rafael-lists at kontesti.me> wrote:
>> 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.
> I join the question! I have some style-related constants in Style
> module, e.g. sizes and colors. Then I want to do computations using
> these constants in Cassius, something similar to SCSS. E.g. width:
> #{Style.width1 + Style.width2} (not talking about appending "px" suffix
> for now). Currently, because of artificial limitations on Hamlet
> interpolations, I have to define (plus = (+)) (minus = (-)) and so
> on. Would be nice if it allowed full-featured Haskell.

I had a similar problem. I solved it by creating a CssDefinitions
module. The good thing about it is that I can share it among all widgets
of my application. That way I have a single place to configure all
layout constants of the entire site. It might be a bad solution for a
big site with a lot of CSSs, widgets, etc. But for my use case it's
completely manageble.

More information about the web-devel mailing list