2016-08-04 13 views
1

mongoDBから取得したドットグラフを印刷してイメージに変換します。実際のタイプ 'IO()'で 'Control.Monad.Trans.Reader.ReaderT MongoContext IO a0'と一致しませんでした

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 

答えて

3

あなたはPrelude.putStrLnの左にliftIO $が必要ですが、次回は、行番号とそのように完全なエラーを貼り付けます。 doブロックはIOを含むReaderT MongoContext IOのモナドにありますので、その中にはIOアクションを実行できますが、最初に持ち上げる必要があります。

+0

ありがとうGurkenglas、それは動作します:) – David

関連する問題