Salil Wadnerkar wrote:Normally, in any program, if it is not working, I would add some debug statements to understand why I am not getting the expected result. Since debug statements are not allowed in a pure function, how the expert Haskell programmers debug their programmers?
With a debugger. Just like most other languages. See
https://stackoverflow.com/questions/6724434/how-to-debug-haskell-code
Debug statements aren't that common in languages like
Java these days except for the most trivial stuff. It takes too long to stuff in the extra code and there's always a chance that you can accidentally introduce new bugs when you do so - especially if you don't freely bracket conditional constructs.
Instead we use the interactive debugger in our
IDE. And/or add permanent logging statements that can be switched on and off without having to change the source code.