[Haskell-beginners] no instance for monad

Emmanuel Touzery etouzery at gmail.com
Sun Oct 21 11:42:30 CEST 2012


Thank you for the further tips.
The root of my problem, the reason I decided to use that text-format
library though, is because I thought Text.Printf is mangling unicode
characters because it's working on String and not on Data.Text.
However I realized now that even using text-format the unicode characters
were still not written correctly in the file (well there was an error
saving the file, invalid character, same as with Text.Printf). And I found
the correct fix: I must add:

    hSetEncoding fileH utf8

After opening the file and before writing it in. If I do that, the unicode
characters are written OK, and even if I use the usual Text.Printf (and
even on windows - on linux where the locale is anyway utf8 it was working
from the start). So now I'm wondering should I even use text-format since
after all Text.Printf does the job? The author of text-format claims it's
written more efficiently but then again I don't believe there is any kind
of bottleneck there.

Emmanuel

On Sun, Oct 21, 2012 at 10:24 AM, Daniel Trstenjak <
daniel.trstenjak at gmail.com> wrote:

>
> On Sat, Oct 20, 2012 at 10:34:27PM +0200, Daniel Trstenjak wrote:
> > 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.
>
> Well, now I didn't read the error message properly. You have been
> absolutely right with your analysis.
>
> > Instead of giving each element a type you could give the whole list a
> type:
> > ["a", "b"] :: [T.Text]
>
> Or you could add a helper function:
>
> hprintT :: (MonadIO m) => Handle -> TF.Format -> [T.Text] -> m ()
> hprintT = TF.hprint
>
>
>
> Greetings,
> Daniel
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20121021/567cb4a1/attachment-0001.htm>


More information about the Beginners mailing list