I am learning about GHCi's :break feature. JS has a built in statement called debugger; which acts as a breakpoint if debugging is in progress, does nothing otherwise.
Is there a similar statement/function for Haskell/GHCi?
I am thinking something along the lines of Debug.Trace.trace :: String -> a -> a.
It is okay if it uses unsafePerformIO internally, or relies on something GHCi specific as it is only meant for debugging.
Or if there is nothing yet, couldn't something like this be achieved with :set -fbreak-on-exception and having a function that throws an exception and catches it immediately? (unsafePerformIO may be needed here as well, so that the function can be placed in pure code.)
You don't need it.
It is much better to have your code clean than full of debugging insertions.
With ghci you can set a breakpoint by function name or by line number wherever you want. From ghci :help
:break [<mod>] <l> [<col>] set a breakpoint at the specified location
:break <name> set a breakpoint on the specified function
Alternative :
Even more, you can keep a list of breakpoints in a project based ./.ghci command batch file, loaded automatically at ghci start.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With