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

Sterling Clover s.clover at
Tue Jul 14 10:33:49 EDT 2009

What I suspect that you've encountered is an infelicity when importing
GenericStandard. The ToSElem instance defaults to that provided by (Data a)
context. However, there is no special handler for Data.Time types in the
`extQ` chain. I could add one, but that would require relying on the
Data.Time library being the latest (since Typeable isn't provided until
then) or on conditional compilation and standalone deriving, which is a
pain. As the new time package comes into widespread use, I'll fix up the
gToSElem function with the appropriate handlers, but until then I'm afraid
that standard generics won't play well with Data.Time. GenericWithClass, on
the other hand, might yield better results.

There is, by the way, (thanks to the efforts of Luke Plant) now an
HStringTemplate page on the haskellwiki: Edits, improvements,
etc. of course welcome by all.

You may want to post this question and answer there.

By the way, I plan to have a new version with a real announcement and a fair
share of bugfixes in the next week or so.


Kemps-Benedix Torsten wrote:
> John,
> 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?
> regards,
> Torsten 
> -----Ursprüngliche Nachricht-----
> Von: John MacFarlane [mailto:fiddlosopher at] 
> Gesendet: Dienstag, 14. Juli 2009 08:20
> An: Kemps-Benedix Torsten
> Cc: HAppS at; haskell-cafe at
> 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
> John
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at

View this message in context:
Sent from the Haskell - Haskell-Cafe mailing list archive at

More information about the Haskell-Cafe mailing list