<div dir="ltr"><div><div>Hello Haskellers,<br><br></div>I hope I chose proper mailing list, if not I apologize. And thanks for reading this!<br><br>I run into a problem with HStringTemplate (<a href="http://hackage.haskell.org/package/HStringTemplate">http://hackage.haskell.org/package/HStringTemplate</a>) that I have never seen before.<br></div><div>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 `mappend` "' can not be rendered"<br>    Just template  -> return $ Template.render (Template.setAttribute "it" 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></div><div>with a simple template like this:<br>Just a test $it.value$!<br></div><div><br></div><div><div><div>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></div><div>Problem is - it didn't do that before. What even more confusing, older project[0] uses same approach, compiles (same machine, same compiler) and works just fine!<br></div><div>I've exhausted all means to fix the problem that I could think off:<br></div><div>- Adding 'instance Template.ToSElem Foo' allows code to compile but it doesn't work and prints message in console like this:<br>  Main.hs:30:10-29: No instance nor default method for class operation Text.StringTemplate.Classes.toSElem<br></div><div>- Tried to use same version of HStringTemplate deps (syb was different)<br></div><div>- All kinds of desperate messing around (exporting records from modules, changing field names...)<br></div><div>- Updated ghc from 7.8.2 to 7.8.4<br></div><div>- Googled error messages<br></div><div>to no avail.<br><br></div><div>I hope almighty All would give me some ideas/directions because I have none left.<br></div><div><br></div><div>[0] Function: <a href="https://github.com/itsuart/fdc_archivist/blob/master/src/HttpUtils.hs#L59">https://github.com/itsuart/fdc_archivist/blob/master/src/HttpUtils.hs#L59</a><br></div><div>     Data: <a href="https://github.com/itsuart/fdc_archivist/blob/master/src/ViewModels/HomeViewModel.hs">https://github.com/itsuart/fdc_archivist/blob/master/src/ViewModels/HomeViewModel.hs</a><br></div><div>     Usage: <a href="https://github.com/itsuart/fdc_archivist/blob/master/src/HomeViewFeature.hs#L59">https://github.com/itsuart/fdc_archivist/blob/master/src/HomeViewFeature.hs#L59</a><br></div><div>-- <br><div>With best regards,<br>Ilya Seleznev</div>
</div></div></div></div>