<div dir="ltr"><div>Yes! Importing GenericStandard() solved the problem! Thank you very much!<br></div>And big thanks for the HStringTemplate itself - awesome library!<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jun 21, 2015 at 8:22 PM, S. Clover <span dir="ltr"><<a href="mailto:s.clover@gmail.com" target="_blank">s.clover@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You probably also need to import Text.StringTemplate.GenericStandard to bring the instance for Data into scope. It was originally exported seperately to be compatible with either syb or syb-with-class. But syb-with-class is no longer supported because it did not come into widespread use. GenericStandard should probably be exported by default these days, especially since orphan instances are more frowned upon than when the package was written.<br>
<br>
-S<br>
<div><div class="h5"><br>
<br>
On June 21, 2015 at 7:35:14 AM, Ilya Seleznev (<a href="mailto:itsuart@gmail.com">itsuart@gmail.com</a>) wrote:<br>
> Hello Haskellers,<br>
><br>
> I hope I chose proper mailing list, if not I apologize. And thanks for<br>
> reading this!<br>
><br>
> I run into a problem with HStringTemplate (<br>
> <a href="http://hackage.haskell.org/package/HStringTemplate" rel="noreferrer" target="_blank">http://hackage.haskell.org/package/HStringTemplate</a>) that I have never seen<br>
> before.<br>
> Code, similar to<br>
><br>
> {-# LANGUAGE OverloadedStrings, DeriveDataTypeable, NoImplicitPrelude #-}<br>
> module Main where<br>
> import Data.Data<br>
> import qualified Data.Text as T<br>
> import qualified Text.StringTemplate as Template<br>
><br>
> renderTextTemplate :: (Template.ToSElem a) => T.Text -> a -> IO T.Text<br>
> renderTextTemplate name input = do<br>
> templatesGroup <- Template.directoryGroup "templates"<br>
> case Template.getStringTemplate (T.unpack name) templatesGroup of<br>
> Nothing -> return $ "Internal Error: template '" `mappend` name<br>
> `mappend` "' can not be rendered"<br>
> Just template -> return $ Template.render (Template.setAttribute "it"<br>
> input (template:: Template.StringTemplate T.Text))<br>
><br>
> data Foo = Foo {value:: T.Text} deriving (Data, Typeable)<br>
><br>
> main :: IO ()<br>
> main = do<br>
> content <- renderTextTemplate "test" $ Foo {value = "oh hi there!"}<br>
> putStrLn content<br>
><br>
> with a simple template like this:<br>
> Just a test $it.value$!<br>
><br>
> started to cause complaints from GHC (7.8.2 and 7.8.4 on Linux x86_64):<br>
> No instance for (Template.ToSElem Foo)<br>
><br>
> Problem is - it didn't do that before. What even more confusing, older<br>
> project[0] uses same approach, compiles (same machine, same compiler) and<br>
> works just fine!<br>
> I've exhausted all means to fix the problem that I could think off:<br>
> - Adding 'instance Template.ToSElem Foo' allows code to compile but it<br>
> doesn't work and prints message in console like this:<br>
> Main.hs:30:10-29: No instance nor default method for class operation<br>
> Text.StringTemplate.Classes.toSElem<br>
> - Tried to use same version of HStringTemplate deps (syb was different)<br>
> - All kinds of desperate messing around (exporting records from modules,<br>
> changing field names...)<br>
> - Updated ghc from 7.8.2 to 7.8.4<br>
> - Googled error messages<br>
> to no avail.<br>
><br>
> I hope almighty All would give me some ideas/directions because I have none<br>
> left.<br>
><br>
> [0] Function:<br>
> <a href="https://github.com/itsuart/fdc_archivist/blob/master/src/HttpUtils.hs#L59" rel="noreferrer" target="_blank">https://github.com/itsuart/fdc_archivist/blob/master/src/HttpUtils.hs#L59</a><br>
> Data:<br>
> <a href="https://github.com/itsuart/fdc_archivist/blob/master/src/ViewModels/HomeViewModel.hs" rel="noreferrer" target="_blank">https://github.com/itsuart/fdc_archivist/blob/master/src/ViewModels/HomeViewModel.hs</a><br>
> Usage:<br>
> <a href="https://github.com/itsuart/fdc_archivist/blob/master/src/HomeViewFeature.hs#L59" rel="noreferrer" target="_blank">https://github.com/itsuart/fdc_archivist/blob/master/src/HomeViewFeature.hs#L59</a><br>
> --<br>
> With best regards,<br>
> Ilya Seleznev<br>
</div></div>> _______________________________________________<br>
> Haskell-Cafe mailing list<br>
> <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
><br>
<br>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">With best regards,<br>Ilya Seleznev</div>
</div>