Graph implementation in Haskell