代码之家  ›  专栏  ›  技术社区  ›  bbarker

当使用CSV管道时,为什么有时会出现“没有使用‘intosv’产生的CSV文本实例”呢?

  •  1
  • bbarker  · 技术社区  · 7 年前

    {-# LANGUAGE OverloadedStrings #-}
    
    module Foo where
    
    import           Conduit
    import           Data.CSV.Conduit
    
    textToCSV :: Text -> Vector (MapRow Text)
    textToCSV txt = replicateC 1 txt
      .| intoCSV defCSVSettings
      .| sinkVector & runConduitPure & runIdentity
    

        * No instance for (CSV Text (Vector (MapRow Text)))
            arising from a use of `intoCSV'
        * In the first argument of `(.|)', namely `intoCSV defCSVSettings'
          In the second argument of `(.|)', namely
            `intoCSV defCSVSettings .| sinkVector'
          In the first argument of `(&)', namely
            `replicateC 1 txt .| intoCSV defCSVSettings .| sinkVector'
        |
    156 |   .| intoCSV defCSVSettings
        |      ^^^^^^^^^^^^^^^^^^^^^^
    
    
        * No instance for (Data.Vector.Generic.Base.Vector
                             Identity (Vector (MapRow Text)))
            arising from a use of `sinkVector'
        * In the second argument of `(.|)', namely `sinkVector'
          In the second argument of `(.|)', namely
            `intoCSV defCSVSettings .| sinkVector'
          In the first argument of `(&)', namely
            `replicateC 1 txt .| intoCSV defCSVSettings .| sinkVector'
        |
    157 |   .| sinkVector & runConduitPure & runIdentity
        |      ^^^^^^^^^^
    

    当然,我同意 CSV Text Text 不存在。但是与我现在所做的相比 sourceFile 似乎有一个 similar usage . 关于向量的第二个错误我也很困惑。

    :

    textToCSV 函数及其它几个辅助函数在my的构造中的应用 processCSV

    processCSV :: (MonadResource m, MonadThrow m, PrimMonad m) =>
      ConduitT FilePath Void m (Vector (Vector (MapRow Text)))
    processCSV = mapMC (readCSVFile defCSVSettings) .| sinkVector
    
    0 回复  |  直到 7 年前
    推荐文章