[Haskell-beginners] no instance for monad

Emmanuel Touzery etouzery at gmail.com
Sat Oct 20 22:12:39 CEST 2012


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?
 If that's the case I wish Buildable would only accept Text and if you
really want to give a String you could always pack it. But maybe I'm
missing something. Is there no way to get a more compact line in this case?
Although most of the time it's true that the parameters for the print will
in fact be other values which were assigned and which type was determined
previously in the program.

 Anyway thank you a lot, you unblocked me!

Emmanuel


On Sat, Oct 20, 2012 at 10:02 PM, Daniel Trstenjak <
daniel.trstenjak at gmail.com> wrote:

>
> On Sat, Oct 20, 2012 at 09:53:09PM +0200, Emmanuel Touzery wrote:
> > Thank you! And yes that works...
> >
> > But what if i do want to give several parameters to hprint? In my second
> > email i noted i get a different error message in that case?
> > so for instance:
> > TF.hprint handle " {} {}" "a" "b"
>
> Look at the instances of the type class Params:
>
> http://hackage.haskell.org/packages/archive/text-format/0.3.0.8/doc/html/Data-Text-Format-Params.html#t:Params
>
> It tells us, that for multiple parameters you can use a list '["a", "b"]'
> or a tuple
> with up to ten elements '("a", "b")'.
>
>
> 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/20121020/87e2f86d/attachment.htm>


More information about the Beginners mailing list