Hello. It seems that Codingame uses old version of fgl library. The following code works on my computer with fgl-5.5:
-- a graph with two nodes and string labels
let gr = mkGraph [(0, "zone 0 data"), (1, "zone 1 data")] [(0,1,())] :: Gr String ()
-- printing it
> prettyPrint gr
0:"zone 0 data"->[((),1)]
1:"zone 1 data"->[]
-- taking first node and putting it back again
> prettyPrint ((&) (fromJust $ fst $ match 0 gr) gr)
0:"zone 0 data"->[((),1)]
1:"zone 1 data"->[]
-- we've got the same graph, everything is ok
Almost same code on codingame is not:
let gr = mkGraph [(0, "zone 0 data"), (1, "zone 1 data")] [(0,1,())] :: Gr String ()
hPutStrLn stderr $ show $ gr --works
hPutStrLn stderr $ show $ ((&) (fromJust $ fst $ match 0 gr) gr) --not
0:“zone 0 data”->[((),1)]1:“zone 1 data”->[]Answer: Node Exception, Node: 0
It would be nice if you fix this, because without the ability to update graph nodes this library is basically useless.
Thanks in advance.