[Haskell-cafe] AW: Example for formatted show in HStringTemplate

Kemps-Benedix Torsten Torsten.Kemps-Benedix at sks-ub.de
Tue Jul 14 06:20:19 EDT 2009


thanks for your answer, but HStringtemplate has instance definitions for Date.Time.Day. The question is more on the script side: How do I have to write the ST calls with ";format=" embedded in HTML?



-----Ursprüngliche Nachricht-----
Von: John MacFarlane [mailto:fiddlosopher at gmail.com] 
Gesendet: Dienstag, 14. Juli 2009 08:20
An: Kemps-Benedix Torsten
Cc: HAppS at googlegroups.com; haskell-cafe at haskell.org
Betreff: Re: Example for formatted show in HStringTemplate

+++ Kemps-Benedix Torsten [Jul 13 09 23:56 ]:
> Hello,
> is there a working example of how to use the format clause with HStringTemplate, e.g. for Data.Time.Day? I think, if there is a parameter $day$, a reasonable template might contain e.g.:
> $day;format="%d.%b.%Y"$
> But I only get "toModifiedJulianDay: [54960]" as the result which corresponds to the unformatted show.

You probably need to define a StringTemplateShows instance for
Data.Time.Day, and then use stShowsToSE to define a ToSElem instance.
Something like

instance StringTemplateShows Day
  where stringTemplateFormattedShow formatString = formatTime defaultTimeLocale formatString 
   {- or whatever -- I'm not sure what the correct time-formatting function is -}

instance ToSElem Day
  where toSElem = stShowsToSE


More information about the Haskell-Cafe mailing list