traceM and traceShowM

Ben Franksen ben.franksen at online.de
Mon Oct 19 12:57:48 EDT 2009


Twan van Laarhoven wrote:

> Martijn van Steenbergen wrote:
> 
>> Joachim Breitner wrote:
>> 
>>>     join traceShow :: (Show a) => a -> a
>> 
>> 
>> Yes, you're right. I rarely use trace directly. I either use traceM,
>> join trace or join traceShow. I can't think of good names for these last
>> two functions, though. But if someone else can, I'm all in favour.
> 
> Perhaps traceShow should have had type (Show a) => a -> a, but assuming we
> don't want to remove existing functions, how about
> 
>      withTrace :: (Show a) => a -> a
>      withTrace x = trace (show x) x
> 
> and perhaps
> 
>      withTraceMsg :: (Show a) => String -> a -> a
>      withTraceMsg msg x = trace (msg ++ ": " ++ show x) x
>                           -- not sure about formating

+1 these are good names (and very useful functions that everyone using
Debug.trace has implemented for themselves at least once).

Cheers
Ben



More information about the Libraries mailing list