
On Sun, Jul 25, 2010 at 1:00 PM, Mark Bradley
Implementing that feature was amazingly simple. I'm still not 100% sold on the syntax, as I'm worried it's complicated Hamlet too much. But having
On Sun, Jul 25, 2010 at 3:40 AM, Michael Snoyman
wrote: the feature available probably isn't too dangerous. It also doesn't cause any problems with existing code as far as my tests go. As a bonus, the $forall/$maybe issue was very easy to solve: just surround it with parentheses. [$hamlet| $forall ((foo bar) baz) bin $bin$ |]
well done on being so quick. I didn't even get a chance to try and implement it myself.
The code looks very clean and accurate. Should the spaces allowed argument be propagated to the sub expression parser derefParens?
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.
Also doesn't parsec have a between combinator?
i.e. derefParens as = between (char '(') (char ')') (deref as) derefSingle as = derefParens as <|> fmap DerefLeaf ident deref spaceAllowed = do let delim = if spaceAllowed then (char '.' <|> (many1 (char ' ') >> return ' ')) else char '.' x <- derefSingle spaceAllowed xs <- many $ delim >> derefSingle return $ foldr1 DerefBranch $ x : xs
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. Michael