[Haskell-cafe] Why is my 'text' missing an instance?

amindfv at mailbox.org amindfv at mailbox.org
Tue Nov 17 23:54:58 UTC 2020


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.

    $ cat test.hs
    import qualified Data.Text as T
    import qualified Data.Binary as B
    
    main = print $ B.encode $ T.pack "hello"
    
    $ /usr/local/bin/ghci --version
    The Glorious Glasgow Haskell Compilation System, version 8.10.2
    
    $ /usr/local/bin/ghci test.hs
    GHCi, version 8.10.2: https://www.haskell.org/ghc/  :? for help
    [1 of 1] Compiling Main             ( test.hs, interpreted )
    
    test.hs:4:16: error:
        • No instance for (B.Binary T.Text)
            arising from a use of ‘B.encode’
        • In the second argument of ‘($)’, namely
            ‘B.encode $ T.pack "hello"’
          In the expression: print $ B.encode $ T.pack "hello"
          In an equation for ‘main’: main = print $ B.encode $ T.pack "hello"
      |
    4 | main = print $ B.encode $ T.pack "hello"
      |                ^^^^^^^^^^^^^^^^^^^^^^^^^
    Failed, no modules loaded.
    
    $ /usr/local/bin/ghc-pkg list text
    /usr/local/lib/ghc-8.10.2/package.conf.d
        text-1.2.3.2
    /home/name/.ghc/x86_64-linux-8.10.2/package.conf.d
        text-1.2.4.1

    $ ghc-pkg-8.10.2 list text
    [same result]

    $ /usr/local/bin/ghci -package text-1.2.3.2 test.hs
    GHCi, version 8.10.2: https://www.haskell.org/ghc/  :? for help
    [1 of 1] Compiling Main             ( test.hs, interpreted )
    Ok, one module loaded.

    $ /usr/local/bin/ghci -package text-1.2.4.1 test.hs
    GHCi, version 8.10.2: https://www.haskell.org/ghc/  :? for help
    [1 of 1] Compiling Main             ( test.hs, interpreted )
    
    test.hs:4:16: error:
        • No instance for (B.Binary T.Text)
            arising from a use of ‘B.encode’
        • In the second argument of ‘($)’, namely
            ‘B.encode $ T.pack "hello"’
          In the expression: print $ B.encode $ T.pack "hello"
          In an equation for ‘main’: main = print $ B.encode $ T.pack "hello"
      |
    4 | main = print $ B.encode $ T.pack "hello"
      |                ^^^^^^^^^^^^^^^^^^^^^^^^^
    Failed, no modules loaded.

Both text-1.2.3.2 and text-1.2.4.1 have a Binary instance for Text. What's going on?

(After writing this out I rebuilt an unmodified clone of text-1.2.4.1 but I see the same results.)

Thanks,
Tom



More information about the Haskell-Cafe mailing list