Algorithms for matchings in graphs in Haskell