
Hello! Many/Some RoR folks swear at Haml/Sass (http://haml-lang.com/) and I see there is Hamlet project at Github (http://github.com/snoyberg/hamlet) saying "Haml-like template files that are compile-time checked", so I'm curious if it targets to be Haml-compatible or just "haml-like" ? Sincerely, Gour -- Gour | Hlapicina, Croatia | GPG key: F96FF5F6 ----------------------------------------------------------------

On Sun, Apr 11, 2010 at 10:53 PM, Gour
Hello!
Many/Some RoR folks swear at Haml/Sass (http://haml-lang.com/) and I see there is Hamlet project at Github (http://github.com/snoyberg/hamlet)
saying "Haml-like template files that are compile-time checked", so I'm curious if it targets to be Haml-compatible or just "haml-like" ?
Sincerely, Gour
Funny to see this mentioned right now; I'm in the middle of incorporating it into Yesod. It's most definitely haml-like: haml itself allows embedding of arbitrary Ruby code, so that's not really something I'm interested in here. I'll put up a mini tutorial on it when it's polished, but there's really not much to the syntax. Just to give an idea of the niche it's trying to fill: * Quasi-quoted templates are embeddable directly in your Haskell files and included in the binary. * All variables are compile-time checked. * Allows for on-demand loading of IO values, eg you can have conditionals in the template and only load data from a database if needed. * It uses enumerators for looping, so it should fit nicely in memory. * Deals with the string problem by having a very simple datatype: data Html = Encoded Text | Unencoded Text (Html will probably be renamed to something else). * Has a monadic interface so you can use the nice features of the Hamlet monad without using the Hamlet syntax and quasi-quoter. * Allows embedding of other templates. The code for integration into Yesod is literally being written right now (just took a break to check my e-mail), so I should have more to say soon. If anyone's dying to know the details, send me an e-mail and I'll try to put together a blog post. Michael

On Sun, 11 Apr 2010 23:14:15 -0700
"Michael" == Michael Snoyman wrote:
Michael> Funny to see this mentioned right now; I'm in the middle of Michael> incorporating it into Yesod. It's most definitely haml-like: Heh...somehow I've stumbled upon Haml/Sass after researching about static-site generators (StaticMatic supports Haml) and then thought about Haskell...which has brought me to Hamlet. :-) The wikipedia page (http://en.wikipedia.org/wiki/Haml#Implementations) lists severeal implementations, that's why I've asked if Hamlet could be counted as one? Michael> haml itself allows embedding of arbitrary Ruby code, so that's Michael> not really something I'm interested in here. Same here. No interest in Ruby. Michael> I'll put up a mini tutorial on it when it's polished, but Michael> there's really not much to the syntax. Just to give an idea of Michael> the niche it's trying to fill: Michael> Michael> * Quasi-quoted templates are embeddable directly in your Michael> Haskell files and included in the binary. Michael> * All variables are compile-time checked. Michael> * Allows for on-demand loading of IO values, eg you can have Michael> conditionals in the template and only load data from a Michael> database if needed. Michael> * It uses enumerators for looping, so it should fit nicely in Michael> memory. Michael> * Deals with the string problem by having a very simple Michael> datatype: data Html = Encoded Text | Unencoded Text (Html will Michael> probably be renamed to something else). Michael> * Has a monadic interface so you can use the nice features of Michael> the Hamlet monad without using the Hamlet syntax and Michael> quasi-quoter. Michael> * Allows embedding of other templates. It looks very good. *thumb up* Michael> The code for integration into Yesod is literally being written Michael> right now (just took a break to check my e-mail), so I should Michael> have more to say soon. If anyone's dying to know the details, Michael> send me an e-mail and I'll try to put together a blog post. No rush here. ;) (We'll use Hakyll for now.) Sincerely, Gour -- Gour | Hlapicina, Croatia | GPG key: F96FF5F6 ----------------------------------------------------------------

Gour wrote:
On Sun, 11 Apr 2010 23:14:15 -0700
> "Michael" == Michael Snoyman wrote:
Michael> Funny to see this mentioned right now; I'm in the middle of Michael> incorporating it into Yesod. It's most definitely haml-like:
Heh...somehow I've stumbled upon Haml/Sass after researching about static-site generators (StaticMatic supports Haml) and then thought about Haskell...which has brought me to Hamlet. :-)
The wikipedia page (http://en.wikipedia.org/wiki/Haml#Implementations) lists severeal implementations, that's why I've asked if Hamlet could be counted as one?
Michael> haml itself allows embedding of arbitrary Ruby code, so that's Michael> not really something I'm interested in here.
Same here. No interest in Ruby.
The use of Ruby is orthogonal to Haml. Ruby implementations allow for inserting Ruby. There's no reason any other implementation has to do that. It's meant to output (x)html. A Haskell version could have inline Haskell. Or not. (That said, I can't stand Haml, and it's popularity among Rubyists is depressing. I'd avoid it just as much were it part of any Haskell lib.) James -- Neurogami - Smart application development http://www.neurogami.com james@neurogami.com

On Thu, Apr 15, 2010 at 12:16 AM, James Britt
Gour wrote:
On Sun, 11 Apr 2010 23:14:15 -0700
>> "Michael" == Michael Snoyman wrote:
Michael> Funny to see this mentioned right now; I'm in the middle of Michael> incorporating it into Yesod. It's most definitely haml-like:
Heh...somehow I've stumbled upon Haml/Sass after researching about static-site generators (StaticMatic supports Haml) and then thought about Haskell...which has brought me to Hamlet. :-)
The wikipedia page (http://en.wikipedia.org/wiki/Haml#Implementations) lists severeal implementations, that's why I've asked if Hamlet could be counted as one?
Michael> haml itself allows embedding of arbitrary Ruby code, so that's Michael> not really something I'm interested in here.
Same here. No interest in Ruby.
The use of Ruby is orthogonal to Haml. Ruby implementations allow for inserting Ruby. There's no reason any other implementation has to do that. It's meant to output (x)html. A Haskell version could have inline Haskell. Or not.
I really was saying that I don't want to allow embedding of arbitrary code in templates.
(That said, I can't stand Haml, and it's popularity among Rubyists is depressing. I'd avoid it just as much were it part of any Haskell lib.)
Out of curiosity, why? I've never really used it large-scale before, but it seems to work rather nicely.
Michael

Michael Snoyman wrote:
Out of curiosity, why? I've never really used it large-scale before, but it seems to work rather nicely.
Mostly because of its absolutist use of whitespace, and it insists I treat HTML as a set of DOM nodes instead of as a document. Plus, it's ugly. You can read my willfully rant-y explanation here: http://www.jamesbritt.com/2009/4/29/thoughts-on-haml James -- Neurogami - Smart application development http://www.neurogami.com james@neurogami.com

Notably in your rant you site static indentation and "most forms" of static
typing as "solving problems that don't come up in real life code". Haskell
would seem to be an interesting choice for your development efforts in both
cases then no? ;)
I think you make a fine point about xhtml being a great tool, but if you
plan to embed some form of syntax into your templates and avoid data binding
Haml is one of the better solutions out there.
Best
John
PS I assume the forms of static typing you were referring too look a bit
more like Java/C#/C++ and less like Haskell.
On Fri, Apr 16, 2010 at 11:17 PM, James Britt
Michael Snoyman wrote:
Out of curiosity, why? I've never really used it large-scale before, but
it seems to work rather nicely.
Mostly because of its absolutist use of whitespace, and it insists I treat HTML as a set of DOM nodes instead of as a document.
Plus, it's ugly.
You can read my willfully rant-y explanation here:
http://www.jamesbritt.com/2009/4/29/thoughts-on-haml
James
--
Neurogami - Smart application development
james@neurogami.com
_______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel

John Bender wrote:
Notably in your rant you site static indentation and "most forms" of static typing as "solving problems that don't come up in real life code". Haskell would seem to be an interesting choice for your development efforts in both cases then no? ;)
Oh, yes. :) I think if Haml, Yaml, and other hard-line indentation formats used Haskell's off-side rule I'd find them easier to work with. Haml, for example, demands a very specific indentation; off by one extra space and you get slapped, even if visually it is quite clear what is going on. It makes for extra work for me. The offside rule for Haskell also seems to make more sense in the context of function equations (e.g. this-side = that-side). Having Haskell tell me "Think of this code as a set of equations" makes sense. Haml's "Think of your essay document with embedded metadata as a rigid hierarchy of nodes" feels forced.
I think you make a fine point about xhtml being a great tool, but if you plan to embed some form of syntax into your templates and avoid data binding Haml is one of the better solutions out there.
Almost all of the Haml I've had to deal with is used in Rails projects, and data binding and embedded code is all over the place. Sort of the worst of both worlds. :) (And I find it harder to fix other people's code when it's in Haml. Haml seems to favor writing over re-writing. But I'm ranting again.) I don't mind mixing code in with templates, I'd much prefer I be given the choice as to when that is appropriate. I just try to avoid it since it makes things harder in the long run. But for knocking something out just to explore an idea it's great. For example, I used to do JSP and ASP development, and I could write large chunks of code inline the page markup to see if something was a useful path. If so, I would then refactor the code out of the markup up and bundle it up in something faster/cleaner/easier to test. But with everything in the page I could refresh the browser and see my results and avoid having to run the compiler, etc. The risk, though, is that being undisciplined can lead to the stereotypical worst-case PHP kind of code. James

On Sat, Apr 17, 2010 at 10:52 AM, James Britt
John Bender wrote:
Notably in your rant you site static indentation and "most forms" of static typing as "solving problems that don't come up in real life code". Haskell would seem to be an interesting choice for your development efforts in both cases then no? ;)
Oh, yes. :)
I think if Haml, Yaml, and other hard-line indentation formats used Haskell's off-side rule I'd find them easier to work with.
Haml, for example, demands a very specific indentation; off by one extra space and you get slapped, even if visually it is quite clear what is going on. It makes for extra work for me.
The offside rule for Haskell also seems to make more sense in the context of function equations (e.g. this-side = that-side).
Having Haskell tell me "Think of this code as a set of equations" makes sense. Haml's "Think of your essay document with embedded metadata as a rigid hierarchy of nodes" feels forced.
I'm sorry, I'm not familiar enough with the indentation rules you're referring to; could you explain it more throughly? This might be a case where I accidentally solved a problem ;).
I think you make a fine point about xhtml being a great tool, but if you plan to embed some form of syntax into your templates and avoid data binding Haml is one of the better solutions out there.
Almost all of the Haml I've had to deal with is used in Rails projects, and data binding and embedded code is all over the place. Sort of the worst of both worlds. :) (And I find it harder to fix other people's code when it's in Haml. Haml seems to favor writing over re-writing. But I'm ranting again.)
I don't mind mixing code in with templates, I'd much prefer I be given the choice as to when that is appropriate. I just try to avoid it since it makes things harder in the long run. But for knocking something out just to explore an idea it's great.
For example, I used to do JSP and ASP development, and I could write large chunks of code inline the page markup to see if something was a useful path. If so, I would then refactor the code out of the markup up and bundle it up in something faster/cleaner/easier to test. But with everything in the page I could refresh the browser and see my results and avoid having to run the compiler, etc.
The risk, though, is that being undisciplined can lead to the stereotypical worst-case PHP kind of code.
James
_______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel

Michael Snoyman wrote:
I'm sorry, I'm not familiar enough with the indentation rules you're referring to; could you explain it more throughly? This might be a case where I accidentally solved a problem ;).
Haml expects that where there is to be indentation, that indentation is to be exactly 2 spaces. Not 1, not 3, or 4, but 2. It isn't enough that a line start in a new column further to the right, it has to start in a very specific column relative to its parent. However, there are cases where the content is such that I want to emphasize it or offset it in some way using whitespace. My experience has been that this isn't allowed. James

On Wed, Apr 21, 2010 at 4:01 PM, James Britt
Michael Snoyman wrote:
I'm sorry, I'm not familiar enough with the indentation rules you're referring to; could you explain it more throughly? This might be a case where I accidentally solved a problem ;).
Haml expects that where there is to be indentation, that indentation is to be exactly 2 spaces. Not 1, not 3, or 4, but 2. It isn't enough that a line start in a new column further to the right, it has to start in a very specific column relative to its parent.
However, there are cases where the content is such that I want to emphasize it or offset it in some way using whitespace.
My experience has been that this isn't allowed.
Oh, I'm certainly glad I strayed from the Haml specs then! Hamlet allows arbitrary indentation. In fact, some might argue that the indentation rules are *too* lax, but we'll let experience be the deciding factor on that.
Basically, here's the rules: * a tab is 4 spaces. I considering not allowing tabs at all, but hopefully people know not to mix spaces and tabs already. * each line has its indentation level calculated * a line is nested within the first line above it with a lower indentation level I actually think that sums things up completely. I have just added a page[1] on the documentation site to explain these rules, thank you for pointing out that it was lacking. Michael [1] http://docs.yesodweb.com/hamlet/indentation.html

On Sat, 17 Apr 2010 10:52:32 -0700
"James" == James Britt wrote:
James> Almost all of the Haml I've had to deal with is used in Rails James> projects, and data binding and embedded code is all over the James> place. Sort of the worst of both worlds. :) Hamlet /= Haml ;) Sincerely, Gour -- Gour | Hlapicina, Croatia | GPG key: F96FF5F6 ----------------------------------------------------------------
participants (4)
-
Gour
-
James Britt
-
John Bender
-
Michael Snoyman