On Mon, Jul 5, 2010 at 11:56 PM, Simon Michael <simon@joyful.com> wrote:
Thanks!


On 7/5/10 12:59 PM, Michael Snoyman wrote:
* hamletToRepHtml handles the rendering, calling toContent, and wrapping in a RepHtml. So your line 120 could be
rewritten as:

     hamletToRepHtml$  template  req  msg  as  ps  "hledger"  s

Indeed - see line 121. When I comment 120 and uncomment 121 I get:

 Hledger/Cli/Commands/WebYesod.hs:122:22:
   Couldn't match expected type `Hledger.Cli.Commands.WebYesod.R:RoutesHledgerWebApp'
          against inferred type `[Char]'
     Expected type: Routes HledgerWebApp -> String
     Inferred type: [Char] -> String
   In the second argument of `($)', namely
       `template req msg as ps "hledger" s'
   In the expression:

         hamletToRepHtml $ template req msg as ps "hledger" s

Perhaps there's something else forcing the type, I haven't seen it yet..


There were a few places where you used the @-interpolation with strings, which resulted in the "Hamlet String" datatype. The first patch addresses that, and adds a bunch of type signatures.

The second patch may not be exactly what you're looking for, but I'm pretty sure it's correct: in generals, you don't need to capture multiple values for GET parameters, so I just changed the data types of "as" and "ps" throughout the code to be "String" instead of "[String]". This allowed me to use the special URL-params interpolation sequence of Hamlet:

@?url@

with url :: (urlDatatType, [(String, String)])

The big advantages of this approach versus the previous approach are you keep type safety in your URLs, and Yesod does proper HTML escaping as necessary.

* On line 228, you use a non-breaking space. I'm not sure if you *need* that, or are just trying to work around Yesod's
whitespace rules. If the latter, there's a relatively new feature that allows you to put a backslash at the beginning of
the content to bypass the whitespace rules.[3]

Interesting. I'm just forcing the account fields to be a bit indented here.


* I'm impressed to see you found the getMessage/setMessage API. I keep meaning to blog about it, but haven't had a chance.

Yup, I have been digging through all docs. The above was just what I wanted.


* On line 212, I see you drop to plain XHTML syntax. If you just want to get XHTML closing-tag rules and keep the Hamlet
syntax, use "$xhamlet" instead of "$hamlet" at the beginning of your quasi-quoter.

I was happy when I realised you can write plain HTML in a hamlet template, if you want to. I'm not getting exactly what you meant above, but I'm sure I will soon.


All I meant is that Hamlet comes in multiple flavors: a plain HTML version by default, and an XHTML variant. It takes the exact same input, but produces different code at the end. For example:

[$hamlet|%br|]  becomes  <br>
[$xhamlet|%br|] becomes <br />
 
Let me know if you have any other questions, I've been interested in hledger for a while now, so it's very gratifying to
see it move over to Yesod.

Current status is hledger-darcs can be installed with -fweb (loli/hsp/hack/simpleserver) or -fwebyesod (yesod/hamlet/wai/simpleserver). I'm going to focus on the latter now, I just feel the need to keep the former around as yesod requires 6.12 and I'm always trying to reduce installation pain.


I agree with that decision, I was not happy upon realizing that Template Haskell for GHC 6.10 didn't support type families. I considered taking out the type family stuff (at the time it was just the Routes associated type), but decided I'd rather have a more powerful framework. And then persistent came along and was completely based on type families, so there's not really *any* choice now.
 
I'm looking forward to trying this.


Michael