Bytestring - 包版本号不匹配

Bytestring - package version number mismatch

我正在尝试 运行 hafka 在我的系统上。对于相同的元素类型,Data.ByteString.Internal.ByteString、haskell 由于版本号不匹配而抛出错误。

Couldn't match expected type ‘bytestring-0.10.4.0:Data.ByteString.Internal.ByteString’
                with actual type ‘B.ByteString’
    NB: ‘bytestring-0.10.4.0:Data.ByteString.Internal.ByteString’
          is defined in ‘Data.ByteString.Internal’
              in package ‘bytestring-0.10.4.0’
        ‘B.ByteString’
          is defined in ‘Data.ByteString.Internal’
              in package ‘bytestring-0.10.6.0’

在我的系统上,当我 运行 ghc-pkg list | grep bytestring 时,它显示, bytestring-0.10.4.0.

ghc 没有使用 bytestring-0.14.0 版本的包。 haskell 从哪里获取实际类型版本 - bytestring-0.10.6.0?

我还没有看到任何语言会跨库版本检查类型安全。为什么 haskell 会那样做?

您可能正在使用沙箱,在这种情况下,您可以查看沙箱中有哪些包,例如,

cabal exec ghc-pkg list bytestring

I haven't seen any language that checks for type safety across library versions. Why does haskell do that?

没有先验的理由相信一个版本的包中名为 ByteString 的类型在语义上与另一个版本的包中具有相同名称的类型相同。作为一个保守的规则,GHC 根本不允许混合。请注意,检查这两种类型在语义上是否相同并不仅限于查看它们的数据表示;还需要比较它们的 type-class 实例,这显然是一个不可判定的问题。人们可能会想象未来的 GHC 会尝试在这方面做更多的分析,但这并不是迫切需要——通常,简单地针对每个依赖项的一个且仅一个版本构建您的包并不难。