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

John MacFarlane fiddlosopher at gmail.com
Tue Jul 14 02:20:10 EDT 2009


+++ 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

John


More information about the Haskell-Cafe mailing list