Brandon S. Allbery KF8NH wrote:
On Nov 29, 2007, at 17:13 , Thomas Hartman wrote:
but there's no risk using trace is there?
If you're doing any other I/O, you may be surprised by where the trace
output shows up relative to it.
How about if the I/O is to write to a different stream?
On Thu, 29 Nov 2007, Thomas Hartman wrote:
but there's no risk using trace is there?
'trace' is really only for debugging. It should not appear in shipped
libraries or programs.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
@haskell.org
cc
Subject
Re: [Haskell-cafe] Progress indications
On Wed, Nov 28, 2007 at 05:58:07PM -0500, Thomas Hartman wrote:
maybe Debug.Trace? like...
import Debug.Trace
t = foldr debugf 0 [1..1]
f :: Int - Int - Int
f = (+)
-- same typesig as f
debugf :: Int - Int - Int
debugf
, [EMAIL PROTECTED]
cc
Subject
Re: [Haskell-cafe] Progress indications
Obviously heaps better than what I initially proposed.
However, I would argue to go boldly with unsafePerformIO, which is the
same thing Debug.Trace uses
http://darcs.haskell.org/ghc-6.6/packages/base/Debug/Trace.hs
Lazy evaluation can sometimes be helpful here. I once wrote a
raytracer that computed the resulting image using a pure function that
returned a list of the RGB colors of the pixels: [(Word8, Word8,
Word8)]
When plotting the pixels to the screen in the IO monad, the value of
each pixel would be
Bit Connor wrote:
I was new to haskell when I made this program and when I ran the
program for this first time I was expecting to experience a long pause
and then a display of the final image. I was very surprised to see
progressive rendering!
Neat, isn't it? :-)
On the other hand, if you
Bit Connor wrote:
computation is. And since it's all calls to map and filter et al., it's
...it's not immediately clear how to provide any feedback
on how much longer there is to wait.
Andrew Coppin wrote:
It seems unsafePerformIO is the way to go here.
...unsafeInterleaveIO
I disagree. The
To
Andrew Coppin [EMAIL PROTECTED]
cc
haskell-cafe@haskell.org
Subject
Re: [Haskell-cafe] Progress indications
Bit Connor wrote:
computation is. And since it's all calls to map and filter et al., it's
...it's not immediately clear how to provide any feedback
on how much longer
On Nov 29, 2007, at 17:13 , Thomas Hartman wrote:
but there's no risk using trace is there?
If you're doing any other I/O, you may be surprised by where the
trace output shows up relative to it.
--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system
Andrew Coppin [EMAIL PROTECTED] writes:
(BTW, what's the difference between unsafePerformIO and unsafeInterleaveIO?)
Prelude :m + System.IO.Unsafe
Prelude System.IO.Unsafe :t unsafePerformIO
unsafePerformIO :: IO a - a
Prelude System.IO.Unsafe :t unsafeInterleaveIO
unsafeInterleaveIO :: IO
In a normal programming language, you might write something like this:
for x = 1 to 100
print x
...do slow complex stuff...
next x
In Haskell, you're more likely to write something like
result k = filter my_weird_condition $ map strange_conversion $
unfoldr ...
That means that
On Wed, Nov 28, 2007 at 05:58:07PM -0500, Thomas Hartman wrote:
maybe Debug.Trace? like...
import Debug.Trace
t = foldr debugf 0 [1..1]
f :: Int - Int - Int
f = (+)
-- same typesig as f
debugf :: Int - Int - Int
debugf x y | y `mod` 1000 == 0 = x + (trace (show y) y)
debugf x
12 matches
Mail list logo