I want to print my dot graph taken from mongoDB and then convert into an image.
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. 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.