Yesod Hamlet type error in for all loop is confusing -


i have yesod handler returning list of type [(category, [product])] trying loop through in hamlet template.

$if null rows     <p>no products $else   <div class="list-group menu">     $forall (category, products) <- rows       <h4>#{categoryname category}        $forall product <- products         <p>#{productname product} - #{productprice product}</p> 

when compile though error message:

handler/menu.hs:11:7:     couldn't match type ‘[(category, [product])]’                    ‘(category, t0 product)’     expected type: readert sqlbackend m1 (category, t0 product)       actual type: readert sqlbackend m1 [(category, [product])]     in second argument of ‘data.foldable.mapm_’, namely ‘rows’     in stmt of 'do' block:       data.foldable.mapm_         (\ (category_aiv7, products_aiv8)            -> { (aswidgett ghc.base.. towidget)                      ((blaze-markup-0.7.0.3:text.blaze.internal.preescapedtext                        ghc.base.. data.text.pack)                         "<div class=\"list-group-item\"><h4 class=\"list-group-item-heading\">");                    (aswidgett ghc.base.. towidget)                      (tohtml (categoryname category_aiv7));                    .... })         rows 

i don't understand why expecting , can make work. many thanks.

update: handler.

getmenur :: handler html getmenur =   let rows = query    defaultlayout $     $(widgetfile "menu")  query =   cats <- selectlist [] [asc categoryname]   form cats $ \(entity catid cat) ->       products <- selectlist           [productcategory ==. catid]           [asc productname]       return (cat, map entityval products) 

after michael easy replacing let rows = query rows <- rundb query


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -