Add functions traceWith, traceShowWith, traceEventWith.
As discussed at https://github.com/haskell/core-libraries-committee/issues/36. Copying the motivation from there:
I'd frequently find these functions useful when debugging, to give me just a small part of the large data structure being produced. But since I don't keep Debug.Trace imported long-term, I'm not going to have these defined as helper functions anywhere, so I basically just end up writing the definition inline - where I want traceShowWith f a
I'd write (\x -> traceShow (f x) x) a
which is awkward and obscures the actual code I'm trying to debug.
(I think flip traceShow <*> f
is the same, but I wouldn't be confident I've remembered it correctly - and when I'm debugging, the last thing I want is to be wondering whether my debugging functions are doing what they should.)
This is admittedly only a mild quality-of-life improvement. But I think it's low cost. There's potential breakage because it adds exports, but I'd strongly expect there to be little-or-none in practice, and it's easy to fix where it does show up.
(Does this need tests? I couldn't find any for traceId
or traceShowId
, so I don't really know what they'd look like.)