[web-devel] yesod in five minutes

George Colpitts george.colpitts at gmail.com
Tue May 31 00:22:17 CEST 2011


I tried yesod in five minutes <http://www.yesodweb.com/five-minutes> and I'm
having a problem trying to add a date and time string that would update on

I just want to add it to the simple page you get with yesod in 5 minutes. I
can embed a date and time string that is the value of a Haskell variable but
that won't refresh on update to the current date and time. My simplistic
approach was to put a line in Handler/root.hs:

currTimeAndDate = getClockTime

but that won't compile:

    No instance for (blaze-html-
                       (IO ClockTime))
      arising from a use of `toHtml'
    Possible fix:
      add an instance declaration for
      (blaze-html- (IO ClockTime))
    In the second argument of `(.)', namely `toHtml'
    In the expression:
        hamlet-0.8.2:Text.Hamlet.Quasi.htmlToHamletMonad . toHtml
    In a stmt of a 'do' expression:
        (hamlet-0.8.2:Text.Hamlet.Quasi.htmlToHamletMonad . toHtml)

I'm sure it would compile if I wrapped getClockTime with unsafePerformIO to
get a String but then refresh of the page wouldn't give me  the current
time. In addition it doesn't seem like the right way to do this.

I'm sure my problem is due to my lack of knowledge of Haskell IO and monads
which I do plan to learn thoroughly but right now I'd just like to get this
to work. It seems like  I could do it with a form in Yesod but that seems
like overkill and wouldn't have the look I want.

I'm very impressed with the software, the book and the source code for the
www.haskellers.com. It is a testimony to the quality of all three that I
have got this far, particularly considering how little I know. Any help
would be greatly appreciated.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/web-devel/attachments/20110530/63986eba/attachment.htm>

More information about the web-devel mailing list