Debug function to stop execution after x amount of times
Motivation
Would be very handy to have a debug function that stops execution when it's been hit x amount of times. This is good for debugging code that goes stuck in an infinite loop. It's not so easy to manually setup such a function because you need to pass it an IORef, while for the sake of this function that is "an implementation detail" spreading over other parts of your program. Function would have signature :: Int -> a -> a probably.
Proposal
I'm not sure how to solve this. Whether it's possible to create some IOrefs behind the scenes for debug purposes only.