[1] https://hackage.haskell.org/package/base-4.18.0.0/docs/Debug...
No need for extensions, just compile and run your program slightly differently. That's the power of declarative languages.
[1] https://hackage.haskell.org/package/base-4.18.0.0/docs/Debug...
No need for extensions, just compile and run your program slightly differently. That's the power of declarative languages.
I also object to that "everywhere". It is far easier to just dump an extra 'print' line somewhere inside a for-loop than into a `foldl (*) 1 $ map (+ 3) [17, 11, 19, 23]`. And that is an easy one...
I develop with Haskell professionally. That foldl example of yours is pretty rare and usually dealt with the QuickCheck [1], mother of all other quickchecks. Usually, the trace will be outside of the foldl application, but you can have it there in the foldl argument, of course.
The "correct" answer to `foldl` would be `scanl` and printing the result of it.
https://hackage.haskell.org/package/base-4.18.0.0/docs/Prelu...
In my opinion, eventlog traces make much better logging than almost anything I've seen.
Right now, developing with C++, I miss the power of Haskell's RTS.
Haskell's (GHC's) Eventlog is nice, but a binary format and not comparable to text output.
So actually not everywhere. And QuickCheck does something else entirely.
The foldl example of yours should be split into a property checking and controlling for expected properties of the input. The first part is done via quickcheck and second part usually is done with assertions and/or traces.
But nothing preclude you from having your trace there, inside foldl argument. This is clearly wrong place to have it, but still you can have it there.
So I repeat, you can have your traceEvents everywhere.
Also, a link to a useful library is not a bad thing for anyone curious about Haskell. Thus, there's a bit of education there.
If it looks like improv, I am here every evening till Friday.