On May 13, 2011, at 4:08 AM, Neil Mitchell wrote:
> Hi,
>
> I am thinking of doing a project using Hamlet (and perhaps a little of
> Yesod, I'm not quite sure). As I was reading through the book
> (excellent resource!) I was surprised by the syntax for $maybe, in
> particular that you get case matching on only the Maybe type. Being
> used to Haskell I'm a fan of general solutions, so I commented on the
> book (
http://www.yesodweb.com/book/templates#c5). Since book comments
> aren't really the right place to discuss something technical I thought
> I'd move it here.
>
> Currently Hamlet has:
>
> $if a; $elseif b; $else
>
> $maybe x <- ma; $nothing
>
> I think if $if was expanded to be pattern guards, rather than boolean
> expressions, it would be more powerful, yet remain just as easy to
> use. So, I'd like:
>
> $if Just x <- ma
>
> To be equivalent to:
>
> $maybe x <- ma
>
> Then $else and $nothing also become equivalent.
>
> If you also allow commas you can write things like:
>
> $if Just x <- age, x > 18
> adults
> $else
> kids
>
> These have a very simple explanation - they're just pattern guards.
> Michael wants Hamlet to remain simple, in order to allow designers to
> use it without knowing programming. I think that's a reasonable goal,
> but I don't think a richer syntax for $if would make it any harder in
> the common case. I also think that if inexperienced people have to do
> more advanced tricks - i.e. converting their ADT into nested Maybe
> values in order to do some case analysis, it's going to end up harder
> in the long run.
>
> I had two other, smaller thoughts, while reading the book:
>
> 1) $for x <- xs, x > 12 could be used to generalise $for to list
> comps. However, I notice you've got $for working over anything
> Foldable, rather than just lists, so it's not necessarily such a clear
> conversion. It's probably also less useful - since filter isn't too
> bad - and you can always do $for x <- [x | x <- xs, x > 12]
>
> 2) CoffeeScript makes Javascript much more useful. It would be very
> cool if as well as Julius there was something more like CoffeeScript,
> or perhaps exactly CoffeeScript. I also idly wondered if you could
> translate Haskell syntax to Javascript (without the types), but
> perhaps that isn't such a great idea.
>
> Thanks, Neil
>
> _______________________________________________
> web-devel mailing list
>
web-devel@haskell.org
>
http://www.haskell.org/mailman/listinfo/web-devel
_______________________________________________
web-devel mailing list
web-devel@haskell.org
http://www.haskell.org/mailman/listinfo/web-devel