为什么putStrLn似乎可以更改IO monad中的预期类型?

时间:2019-01-14 04:53:23

标签: haskell

我有以下基于csv-conduit的简单功能,它正在为#foo s调用自定义catMaybes实现。

Vector

如果我用retrieveSmaXtec :: IO (Vector SxRecord) retrieveSmaXtec = do rows <- sourceFile "unordered.csv" .| intoCSV defCSVSettings .| sinkVector & runConduitRes putStrLn $ show $ size rows -- DEBUG putStrLn $ show $ size $ (fmap fromRow rows) -- DEBUG rows & fmap fromRow & catMaybes & return 删除了两行,则所有类型都会检查,尽管代码似乎确实存在一些问题-尽管单元测试表明putStrLn正常工作,但我似乎仍然得到当我知道我不应该返回空向量时。我之所以提及,只是因为它可能相关。我的实际问题是,为什么在添加fromRow调用时出现错误:

putStrLn

更新:正如评论中所暗示的那样,src/FDS/Data/SmaXtec.hs:64:25: error: * Couldn't match type `Map k0 (Maybe SxRecord)' with `Vector (Maybe SxRecord)' Expected type: Map k0 (Maybe SxRecord) -> Vector SxRecord Actual type: Vector (Maybe SxRecord) -> Vector SxRecord * In the second argument of `(&)', namely `catMaybes' In the first argument of `(&)', namely `rows & fmap fromRow & catMaybes' In a stmt of a 'do' block: rows & fmap fromRow & catMaybes & return * Relevant bindings include rows :: Map k0 (MapRow Text) (bound at src/FDS/Data/SmaXtec.hs:58:3) | 64 | rows & fmap fromRow & catMaybes & return | ^^^^^^^^^ 不是我想要的功能。我需要size

0 个答案:

没有答案