简体   繁体   English

无法匹配期望类型'Control.Monad.Trans.Reader.ReaderT MongoContext IO a0'与实际类型'IO()'

[英]Couldn't match expected type 'Control.Monad.Trans.Reader.ReaderT MongoContext IO a0' with actual type 'IO ()'

I want to print my dot graph taken from mongoDB and then convert into an image. 我想打印从mongoDB中获取的点图,然后转换为图像。

run = do

    docs <- timeFilter -- function to fetch [Document] from mongoDB
    let dot = onlyDot docs -- exclude extra field from the documents
    let dotObject = getObjId dot -- convert into an object
    -- converting dot graph to string and then string to text to pass it on to parseDotGraph function
    let xDotGraph = parseDotGraph (B.pack (show dotObject)) :: G.DotGraph String
    Prelude.putStrLn $ B.unpack $ renderDot $ toDot xDotGraph -- this is not working, want to print
    -- addExtension (runGraphviz xDotGraph) Png "graph" -- this is not working, want to draw as an image
    printDocs dot

You need liftIO $ to the left of Prelude.putStrLn , but next time paste the complete error with line numbers and such. 您需要liftIO $到左侧Prelude.putStrLn ,但下一次粘贴行号和这样完整的错误。 Your do block is in the ReaderT MongoContext IO monad, which contains IO so you can do IO actions in it but you have to lift them first. 你的do块是在ReaderT MongoContext IO monad中,它包含IO所以你可以在其中执行IO操作,但你必须首先解除它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.io.BufferedReader().map 无法推断类型参数<T>从流(流<? extends T> ) - java.io.BufferedReader().map Cannot infer type argument(s) for <T> fromStream(Stream<? extends T>) 找不到类型类调试错误的 PersistentEntity - Couldn't find PersistentEntity for type class debug error socket.io无法按预期在Mac上运行 - socket.io does not run on Mac as expected Reactive Mongo - DeleteAllBy... 查询 - 找不到类型 class java.lang.Void 的 PersistentEntity - Reactive Mongo - DeleteAllBy… query - Couldn't find PersistentEntity for type class java.lang.Void 返回 MongoDB 中字段的实际类型 - Return actual type of a field in MongoDB 将 List&lt;[KnownType]&gt; 转换为 List<T> 匹配函数的返回类型? - Casting List<[KnownType]> to List<T> to match function's return type? "<i>Couldn&#39;t find type java.sql.Date.<\/i>找不到类型 java.sql.Date。<\/b> <i>Are you missing a dependency on your classpath?<\/i>您是否缺少对类路径的依赖?<\/b>" - Couldn't find type java.sql.Date. Are you missing a dependency on your classpath? MongoDB错误:无法确定要反序列化为接口类型的对象的实际类型 - MongoDB error: Unable to determine actual type of object to deserialize for interface type MongoDB 用 $type 匹配一个数组? - MongoDB Match an array with $type? 无法使用MongoChef连接到Compose.io - Can't connect to Compose.io with MongoChef
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM