Add taggedTrace to Debug.Trace
ben at smart-cactus.org
Thu Jun 7 15:40:45 UTC 2018
Yuji Yamamoto <whosekiteneverfly at gmail.com> writes:
> Nice to meet you, GHC Developers!
> I'm new to contributing to GHC.
Thanks for your proposal.
I think this is likely best handled by the Core Libraries Committee
(CC'd). Let's see what they say.
> Today let me suggest new APIs of the Debug.Trace
> module, named:
> - taggedTraceShowId :: Show a => String -> a -> a
> - taggedTraceWith :: (a -> String) -> String -> a -> a
> These are inspired by Elm's Debug.log
> The prefix "tagged" is named after its argument
> I mean, these new APIs prepend a string as a tag to the output by
> traceShowId etc.
> It helps us recognize what the printed values stand for.
> I frequently want such functions and write them manually or copy-and-paste
> from the Debug.TraceUtils.
> I'm tired of that. That's why I made this suggestion.
> *Comparison with the existing solution*
> - Debug.TraceUtils
> - Essentially, this suggestion is to add APIs already implemented by
> - As the document of TraceUtils suggests, we can copy and paste the
> functions from its source, but it's still tiresome.
> - Combine Debug.Trace.traceShowId with Debug.Trace.trace:
> - e.g. trace "Tag" $ traceShowId x
> - A bit hard to type.
> - trace always prints a newline, which makes it difficult to tell the
> tags from the printed value.
> After receiving some feedback here, I'm going to submit to
> Thanks in advance!
Personally, I do like the "With" variant as I regularly find myself
needing things like this. I'm a bit unsure of whether we want to bake
the "tag" notion into the interface, however.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 487 bytes
Desc: not available
More information about the ghc-devs