[Haskell-beginners] Implementation question about directed acyclic graph