[Haskell] updating graphs non-destructively