
oops, forgot to reply to all ---------------------------- addWidget doesn't work. when I replace addHamlet with addWidget and ^{form} with ^{formW} I get the errors below. Its not that I'm that bothered by having to write extractBody, but since you say I dont have to I feel like this means I'm doing something. Again, I feel like I can get widgets and hamlet and html to work, but I feel like I'm hacking it and dont really understand whats going on. when you say polymorphic hamlet is going away, what will replace it? everything is a widget then? S4M/Server/Handler/Admin.hs:49:11: No instance for (Eq (Route master0)) arising from a use of `widgetToPageContent' Possible fix: add an instance declaration for (Eq (Route master0)) In the expression: widgetToPageContent In a stmt of a 'do' expression: pc <- widgetToPageContent $ do { addWidget ($(Settings.hamletFile "admin/purch-dtl")) } In a stmt of a 'do' expression: (_, formW, et, nonce) <- runFormPost (purchFormlet purch ocrRefs) S4M/Server/Handler/Admin.hs:51:19: The lambda expression `\ render[aCFb] -> hamlet-0.8.0:Text.Hamlet.Debug.unsafeRenderTemplate "hamlet/admin/purch-dtl.hamlet" ... render[aCFb]' has one argument, but its type `GGWidget master0 (GHandler sub0 master0) ()' has none In the expression: \ render[aCFb] -> hamlet-0.8.0:Text.Hamlet.Debug.unsafeRenderTemplate "hamlet/admin/purch-dtl.hamlet" [(["mPsiPkv"], Text.Hamlet.RT.HDMaybe (fmap (\ _var[aCFc] -> ...) mPsiPkv)), (["act"], Text.Hamlet.RT.HDUrl act), ....] render[aCFb] In the result of the splice: $(Settings.hamletFile "admin/purch-dtl") To see what the splice expanded to, use -ddump-splices In the first argument of `addWidget', namely `$(Settings.hamletFile "admin/purch-dtl")' S4M/Server/Handler/Admin.hs:51:19: The lambda expression `\ render[aCKe] -> hamlet-0.8.0:Text.Hamlet.Debug.unsafeRenderTemplate "hamlet/admin/purch-dtl.hamlet" ... render[aCKe]' has one argument, but its type `GGWidget master0 (GHandler sub0 master0) ()' has none In the expression: \ render[aCKe] -> hamlet-0.8.0:Text.Hamlet.Debug.unsafeRenderTemplate "hamlet/admin/purch-dtl.hamlet" [(["mPsiPkv"], Text.Hamlet.RT.HDMaybe (fmap (\ _var[aCKf] -> ...) mPsiPkv)), (["act"], Text.Hamlet.RT.HDUrl act), ....] render[aCKe] In the result of the splice: $(Settings.hamletFile "admin/purch-dtl") To see what the splice expanded to, use -ddump-splices In the first argument of `addWidget', namely `$(Settings.hamletFile "admin/purch-dtl")' On May 4, 2011, at 1:15 PM, Michael Snoyman wrote:
Firstly, polymorphic Hamlet is going the way of the do-do. (Sorry everyone, the train ride worked out differently than expected, so the blog post explaining this isn't ready yet.) So going forward these things should be less of a problem.
I think the reason you're running into trouble is the use of "addHamlet"; try replacing it with "addWidget" and see what happens.
On Tue, May 3, 2011 at 4:33 PM, Max Cantor
wrote: I've heard that its unnecessary, but I can't seem to get out it of my code. for instance, here is a simple route which should return a small HTML snippet for AJAX requests:
getAdmPurchDetailRh :: EncPurchId -> Handler RepHtml getAdmPurchDetailRh epid = withEncPersistKey epid $ \(purchId, purch) -> do -- purchImgData <- runDB $ selectList [] [] 50 offset -- _TODO this will be done FOR EACH Purchase. need to cache the OcrRefs ocrRefs <- map snd <$> runDB ( selectList [] [] 50 0) mPsiPkv <- runDB (getBy $ PurchImgUnq purchId True) (_, formW, et, nonce) <- runFormPost (purchFormlet purch ocrRefs) let act = AdminRb pc <- widgetToPageContent $ do form <- extractBody formW addHamlet $(Settings.hamletFile "admin/purch-dtl") hamletToRepHtml [$hamlet|\^{pageBody pc}|]
and the hamlet file:
<div> $maybe psiPkv <- mPsiPkv
$nothing missing image <form action=@{act} enctype=#{et}> #{nonce} ^{form} <input type=submit>
if I drop the extractBody formW call and replace ^{form} with ^{formW} it fails to compile.
also, is there a way to get rid of the widgetToPageContent call and then extracting it with pageBody pc? hamletToRepHtml fails when the hamlet references any widgets it seems.
sidenote, i understand that there is alot of polymorphism going on here but I'm still not exactly clear on what i "should" be doing in terms of hamlet, widgets, snippets etc. any style hints are appreciated.
max
_______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel