
On Sat, Oct 20, 2012 at 10:12:39PM +0200, Emmanuel Touzery wrote:
Thank you, you're right again. I had actually tried that but it failed and I didn't look at the compilation error hard enough.
It said: Ambiguous type variable `t0' in the constraints: (Data.Text.Buildable.Buildable t0) arising from a use of `TF.hprint' at JsonWriter.hs:94:17-25 (Data.String.IsString t0) arising from the literal `"b"' at JsonWriter.hs:94:49-51
And now that thanks to your email I knew this was the right direction, I read properly the error message and got to that working solution:
TF.hprint handle " {} {}" ["a" :: T.Text, "b" :: T.Text]
Unfortunately it's not very compact. I guess the problem is that this Buildable data can take either a String or a Text and because I build with OverloadedStrings the compiler doesn't know which one to prioritize?
The issue arises, because Text and a type of the Json library you're using, both have an instance for the type class IsString, which is the base for the OverloadedStrings extension. I don't now if there's a "nicer" way to tell GHC which one it should use. Instead of giving each element a type you could give the whole list a type: ["a", "b"] :: [T.Text] Greetings, Daniel