Proposal: Debug.Trace.traceWith

Theodore Lief Gannon tanuki at gmail.com
Sat Feb 10 02:32:29 UTC 2018


Hearty +1 one to this. Note:

traceShowId = traceWith id
traceShow   = traceWith . const


On Fri, Feb 9, 2018 at 5:08 PM, Kris Nuttycombe <kris.nuttycombe at gmail.com>
wrote:

> When using Debug.Trace for debugging, a very common operation is to prefer
> to trace only some subset or function of an intermediate result. As a
> consequence, I propose adding the following function to Debug.Trace:
>
> traceWith :: (Show b) => (a -> b) -> a -> a
> traceWith f a = trace (show $ f a) a
>
> While it's trivial to define, I have found this to be one of the most
> useful functions in my trace-based debugging toolkit, hence my proposal
> that it be added to base. It generalizes `traceShowId` in a meaningful and
> useful fashion.
>
> As this is the first such proposal I've put forth, please let me know if
> I'm doing anything wrong with it!
>
> Thanks,
>
> Kris Nuttycombe
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20180209/05e2e7db/attachment.html>


More information about the Libraries mailing list