In Mathematica, ShowIt
function is commonly used for debugging.
Basically, ShowIt
is an identity function that prints the value of its parameter to the console. I wonder, how it is possible to write the same function for Haskell. The issue with Haskell is that since the function does IO, it cannot have the same return type as the input type. I think we have to use unsafe IO to implement showIt
. But I have no idea how.
This already exists in the Debug.Trace
package. It's called traceShowId
. (And it does use unsafePerformIO
under the covers - you can see the implementation of trace
here.)
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