hanjoosten | 14 May 15:03 2013
Picon

Trouble with Debug.Trace when using a library

My project is split in two packages, A and B, where B uses A. All together,
there are about 100 haskell modules.
Currently, there seems to be a loop somewere, that only seems to occur when
working with rather large datastructures. I use trace (from Debug.Trace) to
see what exactly is going on. 
As long as I trace functions from B, trace works as expected. However, at
some point I need to trace into functions supplied by package A.

In package A I have a function like this: (I have simplified the function)

fA :: SomeInput -> SomeResult
fA a =  let x = f a
          in trace ("Entering fA") x

(The function f is defined in package A)

In package B, I have a function like this:

fB :: SomeInput -> SomeResult
fB a = let x = fA a
         in trace ( "Entering fB") x

At runtime, I get the message
Entering fB

and then nothing more. a lot of cpu is used, but no more output.

I have made some wrappers like the ones above. As long as they are in the
same package, trace works fine. However, when entering a function from the
other package, there is no more debug output. 
(Continue reading)

Thomas Horstmeyer | 15 May 11:18 2013
Picon

Re: Trouble with Debug.Trace when using a library

Perhaps x is evaluated earlier than you think, i.e. before the trace 
(due to some strictness analysis?). But this is a just a guess.

I usually use trace outermost in my expression, not within a let. I 
never had a problem with it:

fA :: SomeInput -> SomeResult
fA a =  trace ("Entering fA") $ f a

-- or even:
fA a = trace ("Entering fA") $
        f a

HTH
Thomas

Am 14.05.2013 15:03, schrieb hanjoosten:
> My project is split in two packages, A and B, where B uses A. All together,
> there are about 100 haskell modules.
> Currently, there seems to be a loop somewere, that only seems to occur when
> working with rather large datastructures. I use trace (from Debug.Trace) to
> see what exactly is going on.
> As long as I trace functions from B, trace works as expected. However, at
> some point I need to trace into functions supplied by package A.
>
> In package A I have a function like this: (I have simplified the function)
>
> fA :: SomeInput -> SomeResult
> fA a =  let x = f a
>            in trace ("Entering fA") x
(Continue reading)


Gmane