<div dir="ltr"><br><br><div class="gmail_quote">On Sun, Jul 25, 2010 at 1:00 PM, Mark Bradley <span dir="ltr"><<a href="mailto:barkmadley@gmail.com">barkmadley@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Sun, Jul 25, 2010 at 3:40 AM, Michael Snoyman <<a href="mailto:michael@snoyman.com">michael@snoyman.com</a>> wrote:<br>
> Implementing that feature was amazingly simple. I'm still not 100% sold on<br>
> the syntax, as I'm worried it's complicated Hamlet too much. But having the<br>
> feature available probably isn't too dangerous. It also doesn't cause any<br>
> problems with existing code as far as my tests go.<br>
> As a bonus, the $forall/$maybe issue was very easy to solve: just surround<br>
> it with parentheses.<br>
> [$hamlet|<br>
> $forall ((foo bar) baz) bin<br>
> $bin$<br>
> |]<br>
<br>
</div>well done on being so quick. I didn't even get a chance to try and<br>
implement it myself.<br>
<br>
The code looks very clean and accurate. Should the spaces allowed<br>
argument be propagated to the sub expression parser derefParens?<br>
<br></blockquote><div>It's not necessary; the only reason to disallow spaces is when dealing with a $forall et al. However, once inside parentheses, we can allow the spaces without ambiguity.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Also doesn't parsec have a between combinator?<br>
<br>
i.e.<br>
derefParens as = between (char '(') (char ')') (deref as)<br>
derefSingle as = derefParens as <|> fmap DerefLeaf ident<br>
deref spaceAllowed = do<br>
let delim = if spaceAllowed<br>
then (char '.' <|> (many1 (char ' ') >> return ' '))<br>
else char '.'<br>
x <- derefSingle spaceAllowed<br>
xs <- many $ delim >> derefSingle<br>
return $ foldr1 DerefBranch $ x : xs<br><font class="Apple-style-span" color="#888888"><br></font></blockquote><div>I wasn't aware of between, cleaned up the code nicely. Thanks! Unless there's objections, I'll release the new code as Hamlet 0.4.1.</div>
<div><br></div><div>Michael</div></div></div>