Haskell - can't generate and use Image file in threepenny

114 Views Asked by At

I will try to be as specific as possible. I am trying to make a graph visualization GUI using Haskell, Threepenny and DOT

I have created buttons that modify the graph, and I am trying to save the modified graph in the image and load that image Every Time the graph is modified

However, I can run the Threepenny gui, but I CANT write the image and update it thrown function.

RunGraphviz Function returns IO () and Threepenny GUI uses UI (). I am trying to use "liftIO" but it is generating some error "Prelude head.empty list". Here is the snippet

url <- GL.loadFile sl "graph.png"
   img <- GL.img # set GL.src url
   getBody window #+ [return img] #+ [br]

GL.on GL.click button2 $ \_ -> do
   -- number <- get GL.value noOfNodes
    currentGraph <- GL.get GL.value ini
    no<- GL.get GL.value noOfNodes
    let (Just g1) = readMaybe (currentGraph) :: Maybe AdjList
    let f1 = addnode (read no::Int) g1
    set GL.value (show f1) (element ini)
    liftIO (visualize f1)
    getBody window #+ [GL.string "New Nodes Added"] #+ [br]

visualize g = void $ do 
    runGraphviz (graphToDot myParams (myGraph g)) Png ("C:/Users/Tabish/Desktop/Barira/graph.png")
0

There are 0 best solutions below