[Haskell-cafe] Why is my 'text' missing an instance?
Viktor Dukhovni
ietf-dane at dukhovni.org
Wed Nov 18 00:19:05 UTC 2020
On Tue, Nov 17, 2020 at 06:54:58PM -0500, amindfv--- via Haskell-Cafe wrote:
> 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.
>
> $ /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’
Hard to say what's different on your system, but on a Fedora 31 system
with GHC 8.10.2 and text-1.2.4.1, I'm unable to reproduce the symptoms
you report.
$ ghci -package text-1.2.4.1
GHCi, version 8.10.2: https://www.haskell.org/ghc/ :? for help
Prelude> import qualified Data.Text as T
Prelude T> import qualified Data.Binary as B
Prelude T B> main = print $ B.encode $ T.pack "hello"
Prelude T B> main
"\NUL\NUL\NUL\NUL\NUL\NUL\NUL\ENQhello"
The interface file for Text 1.2.4.1 has the expected instances:
$ ghc-pkg list
~/.local/ghc-8.10/lib/ghc-8.10.2/lib/package.conf.d
...
text-1.2.4.1
...
~/.ghc/x86_64-linux-8.10.2/package.conf.d
(no packages)
$ ghc --show-iface ~/.local/ghc-8.10/lib/ghc-8.10.2/lib/x86_64-linux-ghc-8.10.2/text-1.2.4.1/Data/Text.hi | grep '^instance'
instance [orphan] Data.Binary.Class.Binary [Data.Text.Internal.Text]
instance [orphan] Data.Data.Data [Data.Text.Internal.Text]
instance [orphan] GHC.Classes.Eq [Data.Text.Internal.Text]
instance [orphan] GHC.Exts.IsList [Data.Text.Internal.Text]
instance [orphan] Data.String.IsString [Data.Text.Internal.Text]
instance [orphan] Language.Haskell.TH.Syntax.Lift [GHC.Types.LiftedRep,
instance [orphan] GHC.Base.Monoid [Data.Text.Internal.Text]
instance [orphan] Control.DeepSeq.NFData [Data.Text.Internal.Text]
instance [orphan] GHC.Classes.Ord [Data.Text.Internal.Text]
instance [orphan] Text.Printf.PrintfArg [Data.Text.Internal.Text]
instance [orphan] GHC.Read.Read [Data.Text.Internal.Text]
instance [orphan] GHC.Base.Semigroup [Data.Text.Internal.Text]
--
Viktor.
More information about the Haskell-Cafe
mailing list