Skip to content

Instantly share code, notes, and snippets.

@joshcough
Created January 29, 2015 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshcough/b01b763f78faff55ae52 to your computer and use it in GitHub Desktop.
Save joshcough/b01b763f78faff55ae52 to your computer and use it in GitHub Desktop.
injectCycle :: ModuleGraph -> Gen ModuleGraph
injectCycle g = do
ks <- infiniteListOf (elements $ HM.keys g)
let cycl = zip ks (takeWhile (head ks /=) (tail ks) ++ [head ks])
return $ foldl (flip addDep) g cycl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment