[web-devel] Hamlet and functions that take multiple arguments
michael at snoyman.com
Sun Jul 25 07:53:32 EDT 2010
On Sun, Jul 25, 2010 at 1:00 PM, Mark Bradley <barkmadley at gmail.com> wrote:
> On Sun, Jul 25, 2010 at 3:40 AM, Michael Snoyman <michael at snoyman.com>
> > Implementing that feature was amazingly simple. I'm still not 100% sold
> > the syntax, as I'm worried it's complicated Hamlet too much. But having
> > 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
> > 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
Also doesn't parsec have a between combinator?
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the web-devel