[英]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.