Current trace accepts Print s as to-be-printed text which is almost always inconvenient.
Common use cases of using trace:
Indicate some steps (rarely, traceM fits better):
trace "Stage n" $ ...
Print an item with tag (tag is required for any long debugging run):
trace ("An item: " <> show item) $ ...
In both of these cases a text put into trace has type IsString s => s, and compiler cannot infer s when trace is itself polymorphic over its first argument. Thus trace which accepts a text of specific type is more convenient.
Formatting libraries like fmt and formatting may provide a way to produce text of specifc type (like fmt combinators and operators produce Builder and sformat produces text), but it may be irritating to add imports for a temporal debugging code.
Current
trace
acceptsPrint s
as to-be-printed text which is almost always inconvenient.Common use cases of using
trace
:Indicate some steps (rarely,
traceM
fits better):Print an item with tag (tag is required for any long debugging run):
In both of these cases a text put into
trace
has typeIsString s => s
, and compiler cannot infers
whentrace
is itself polymorphic over its first argument. Thustrace
which accepts a text of specific type is more convenient.Formatting libraries like
fmt
andformatting
may provide a way to produce text of specifc type (likefmt
combinators and operators produceBuilder
andsformat
produces text), but it may be irritating to add imports for a temporal debugging code.