2016-12-10 46 views
0

我正在处理ByteStrings流。我已经通过进口的字节串:Data.ByteString.Char8不会导出stripSuffix

import qualified Data.ByteString as B 

我可以从字节串库例如为:

reverseBS :: Monad m => Conduit B.ByteString m B.ByteString 
reverseBS = CL.map B.reverse 

这工作按预期调用各项功能。

我需要一个函数从ByteString中删除尾随的换行符。我选择使用ByteStringstripSuffix。我的代码如下所示:

removeNewline :: Monad m => Conduit B.ByteString m B.ByteString 
removeNewline = CL.map $ B.stripSuffix "\n" 

但我的代码将无法编译,并提供了以下错误:

Not in scope: ‘B.stripSuffix’ 

我试图安装最新版本的GitHub字节串,但是这并没有帮帮我。

编辑:

我注意到,有什么问题我GHC-PKG列表。它给我下面的输出:

Thomass-MacBook-Pro:src ThomasVanhelden$ ghc-pkg list 
/Applications/ghc-7.10.3.app/Contents/lib/ghc-7.10.3/package.conf.d 
    Cabal-1.22.5.0 
    array-0.5.1.0 
    base-4.8.2.0 
    bin-package-db-0.0.0.0 
    binary-0.7.5.0 
    bytestring-0.10.6.0 
    containers-0.5.6.2 
    deepseq-1.4.1.1 
    directory-1.2.2.0 
    filepath-1.4.0.0 
    ghc-7.10.3 
    ghc-prim-0.4.0.0 
    haskeline-0.7.2.1 
    hoopl-3.10.0.2 
    hpc-0.6.0.2 
    integer-gmp-1.0.0.0 
    pretty-1.1.2.0 
    process-1.2.3.0 
    rts-1.0 
    template-haskell-2.10.0.0 
    terminfo-0.4.0.1 
    time-1.5.0.1 
    transformers-0.4.2.0 
    unix-2.7.1.0 
    xhtml-3000.2.1 
/Users/ThomasVanhelden/.ghc/x86_64-darwin-7.10.3/package.conf.d 
    WAVE-0.1.3 
    abstract-deque-0.3 
    abstract-par-0.3.3 
    async-2.1.1 
    attoparsec-0.13.1.0 
    base16-bytestring-0.1.1.6 
    base64-bytestring-1.0.0.1 
    blaze-builder-0.4.0.2 
    bytestring-0.10.8.2 
    bytestring-lexing-0.5.0.2 
    cereal-0.5.4.0 
    chunked-data-0.3.0 
    conduit-1.2.8 
    conduit-combinators-1.0.8.3 
    conduit-extra-1.1.15 
    exceptions-0.8.3 
    extensible-exceptions-0.1.1.4 
    fail-4.9.0.0 
    hashable-1.2.4.0 
    lifted-base-0.2.3.8 
    mmorph-1.0.9 
    monad-control-1.0.1.0 
    monad-par-0.3.4.8 
    monad-par-extras-0.3.3 
    mono-traversable-1.0.1 
    mtl-2.2.1 
    mwc-random-0.13.5.0 
    network-2.6.3.1 
    network-conduit-1.1.0 
    parallel-3.2.1.0 
    parallel-io-0.3.3 
    parseargs-0.2.0.8 
    primitive-0.6.1.0 
    random-1.1 
    resourcet-1.1.8.1 
    scientific-0.3.4.9 
    semigroups-0.18.2 
    split-0.2.3.1 
    stm-2.4.4.1 
    streaming-commons-0.1.16 
    tagged-0.8.5 
    text-1.2.2.1 
    transformers-base-0.4.4 
    transformers-compat-0.5.1.4 
    unix-compat-0.4.2.0 
    unordered-containers-0.2.7.1 
    vector-0.11.0.0 
    vector-algorithms-0.7.0.1 
    void-0.7.1 
    word8-0.1.2 
    zlib-0.6.1.2 

看起来它正在寻求在包两个不同的目录和两个不同版本的字节串的可能是问题的原因。我该如何解决这个问题?有没有简单的方法来卸载bytestring-0.10.6.0?

+0

你是如何编译的? –

回答

2

首先,值得一提的是stripSuffix确实是在版本0.18中引入的字节串。引用the changelog

0.10.8.0 Duncan Coutts [email protected] May 2016

[etc.]

  • Added stripPrefix and stripSuffix for lazy and strict bytestrings

那伤心,以后你的问题:

Is there a simple way to uninstall bytestring-0.10.6.0?

没有,没有,因为,作为GHC-PKG输出告诉你的,0.10.6.0版本是全球安装的软件包之一(即全系统而不是每个用户)。卸载它将打破以前安装的所有其他软件包,这些软件包取决于bytestring。当您从GitHub安装bytestring时,它将转到您的每个用户包数据库。为了避免进一步的头痛,我建议的第一件事就是摆脱新字节字符串已安装,具有:

ghc-pkg unregister bytestring-0.10.8.2 

然后,以获取最新字节字符串,您应该更新在哈斯克尔安装你的系统(例如,最新的minimal Haskell Platform带有bytestring-0.10.8.1)。或者,您可以使用Stack为您的项目管理多个GHC版本(以及它们的适当包数据库)。

+1

升级GHC看起来像是过度杀伤。为什么不给出使用用户包数据库(已经有适当版本的bytestring可用)构建的说明? –

+0

@DanielWagner也许我错过了一些东西,但是不需要重建所有依赖* bytestring *(包括全局数据库中的* binary *和* unix *)以及大量用户的已安装包数据库)? – duplode

+0

是的,管理构建工作是cabal的发明。 –