2016-08-04 19 views
1

Ich möchte mein Punktdiagramm aus mongoDB drucken und dann in ein Bild konvertieren.Konnte den erwarteten Typ 'Control.Monad.Trans.Reader.ReaderT MongoContext IO a0' mit dem tatsächlichen Typ 'IO()' nicht übereinstimmen.

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 

Antwort

3

Sie müssen liftIO $ links von Prelude.putStrLn, aber das nächste Mal die komplette Fehler mit Zeilennummern und so einfügen. Ihr Do Block ist in der ReaderT MongoContext IO Monade, die IO enthält, so dass Sie IO Aktionen tun können, aber Sie müssen sie zuerst heben.

+0

danke Gurkenglas, es funktioniert :) – David

Verwandte Themen