yesod - Could not deduce (blaze-markup-0.6.3.0:Text.Blaze.ToMarkup Day) arising from a use of ‘toHtml’ -
i'm trying use yesod build simple web site , i'm starting code max tagher's excellent intro on youtube, yesodscreencast. i've forked code github, , add date posting indicate when published, i'm running problem can't quite figure out given low experience haskell , beginner's experience yesod. i've been unable find answer via googleplex.
yesod provides native dayfield
in yesod.form.fields
, thought needed add postdate field
in blogpost following config/models using day
:
blogpost title text postdate day article markdown
and add blogpostform
in postnew.hs
:
blogpostform :: aform handler blogpost blogpostform = blogpost <$> areq textfield (bfs ("title" :: text)) nothing <*> areq dayfield (bfs ("postdate" :: day)) nothing <*> areq markdownfield (bfs ("article" :: text)) nothing
when compiles following error message:
handler/home.hs:16:11: not deduce (blaze-markup-0.6.3.0:text.blaze.tomarkup day) arising use of ‘tohtml’ context (persistentity blogpost) bound pattern constructor entity :: forall record. persistentity record => key record -> record -> entity record, in lambda abstraction @ handler/home.hs:16:11-34 in first argument of ‘aswidgett ghc.base.. towidget’, namely ‘tohtml (blogpostpostdate post_apzp)’ in stmt of 'do' block: (aswidgett ghc.base.. towidget) (tohtml (blogpostpostdate post_apzp)) in expression: { (aswidgett ghc.base.. towidget) ((blaze-markup-0.6.3.0:text.blaze.internal.preescapedtext ghc.base.. data.text.pack) "<h4><li><a href=\""); (geturlrenderparams >>= (\ urender_apzq -> (aswidgett ghc.base.. towidget) (tohtml (\ u_apzr -> urender_apzq u_apzr [] (postdetailsr id_apzo))))); (aswidgett ghc.base.. towidget) ((blaze-markup-0.6.3.0:text.blaze.internal.preescapedtext ghc.base.. data.text.pack) "\">"); (aswidgett ghc.base.. towidget) (tohtml (blogpostpostdate post_apzp)); .... }
if change day
text
, works expect. i'm not sure why yesod can't deal day
since has dayfield
in yesod.form.fields
expect handle this. figure simple, can't seem determine need fix error.
it appears there no instance tomarkup date
datatype.
you supply instance yourself:
instance tomarkup date tomarkup = tomarkup . show
which turns date string , converts markup. if default show instance doesn't fit needs supply formatter , put in place of show
.
Comments
Post a Comment