<div dir="auto">Actually that can happen if there are two versions of text built against different versions of binary, but ghc (or cabal in old mode, which let ghc do it) picked the wrong version of binary for the version of text it chose.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 17, 2020, 19:15 Tikhon Jelvis <<a href="mailto:tikhon@jelv.is">tikhon@jelv.is</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">Wild guess—could there be an inconsistency between the version of the binary package the text library was built against and the version you got the class from in your failing example?<div dir="auto"><br></div><div dir="auto">I don't see how that would happen given your setup, but it's also the only way I can imagine seeing that particular error.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 17, 2020, 15:57 amindfv--- via Haskell-Cafe <<a href="mailto:haskell-cafe@haskell.org" rel="noreferrer noreferrer noreferrer" target="_blank">haskell-cafe@haskell.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">tl;dr: I seem to have two versions of 'text' on my system, both of which should have an instance for (Binary Text). However, one version seems to claim not to have that instance.<br>
<br>
$ cat test.hs<br>
import qualified Data.Text as T<br>
import qualified Data.Binary as B<br>
<br>
main = print $ B.encode $ T.pack "hello"<br>
<br>
$ /usr/local/bin/ghci --version<br>
The Glorious Glasgow Haskell Compilation System, version 8.10.2<br>
<br>
$ /usr/local/bin/ghci test.hs<br>
GHCi, version 8.10.2: <a href="https://www.haskell.org/ghc/" rel="noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">https://www.haskell.org/ghc/</a> :? for help<br>
[1 of 1] Compiling Main ( test.hs, interpreted )<br>
<br>
test.hs:4:16: error:<br>
• No instance for (B.Binary T.Text)<br>
arising from a use of ‘B.encode’<br>
• In the second argument of ‘($)’, namely<br>
‘B.encode $ T.pack "hello"’<br>
In the expression: print $ B.encode $ T.pack "hello"<br>
In an equation for ‘main’: main = print $ B.encode $ T.pack "hello"<br>
|<br>
4 | main = print $ B.encode $ T.pack "hello"<br>
| ^^^^^^^^^^^^^^^^^^^^^^^^^<br>
Failed, no modules loaded.<br>
<br>
$ /usr/local/bin/ghc-pkg list text<br>
/usr/local/lib/ghc-8.10.2/package.conf.d<br>
text-1.2.3.2<br>
/home/name/.ghc/x86_64-linux-8.10.2/package.conf.d<br>
text-1.2.4.1<br>
<br>
$ ghc-pkg-8.10.2 list text<br>
[same result]<br>
<br>
$ /usr/local/bin/ghci -package text-1.2.3.2 test.hs<br>
GHCi, version 8.10.2: <a href="https://www.haskell.org/ghc/" rel="noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">https://www.haskell.org/ghc/</a> :? for help<br>
[1 of 1] Compiling Main ( test.hs, interpreted )<br>
Ok, one module loaded.<br>
<br>
$ /usr/local/bin/ghci -package text-1.2.4.1 test.hs<br>
GHCi, version 8.10.2: <a href="https://www.haskell.org/ghc/" rel="noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">https://www.haskell.org/ghc/</a> :? for help<br>
[1 of 1] Compiling Main ( test.hs, interpreted )<br>
<br>
test.hs:4:16: error:<br>
• No instance for (B.Binary T.Text)<br>
arising from a use of ‘B.encode’<br>
• In the second argument of ‘($)’, namely<br>
‘B.encode $ T.pack "hello"’<br>
In the expression: print $ B.encode $ T.pack "hello"<br>
In an equation for ‘main’: main = print $ B.encode $ T.pack "hello"<br>
|<br>
4 | main = print $ B.encode $ T.pack "hello"<br>
| ^^^^^^^^^^^^^^^^^^^^^^^^^<br>
Failed, no modules loaded.<br>
<br>
Both text-1.2.3.2 and text-1.2.4.1 have a Binary instance for Text. What's going on?<br>
<br>
(After writing this out I rebuilt an unmodified clone of text-1.2.4.1 but I see the same results.)<br>
<br>
Thanks,<br>
Tom<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>