[Haskell-cafe] Looking at program execution

Thomas Hartman thomas.hartman at db.com
Fri Aug 17 10:52:43 EDT 2007

hartthoma at linuxpt:~>cat test.hs
import Debug.Trace

foo = foldl (\first second ->
  (trace ( "first: " ++ ( show first) ) first)
  (trace ( "second: " ++ (show second) ) second) ) 0 [1,2,3]

bar = foldl (+)

traceIt x = trace ("\nTraceIt:\n"++show x++"\n") x
hartthoma at linuxpt:~>ghc -e foo test.hs
first: 0
second: 1
first: 1
second: 2
first: 3
second: 3
hartthoma at linuxpt:~>

hope this helps.

Ian Duncan <iand675 at gmail.com> 
Sent by: haskell-cafe-bounces at haskell.org
08/16/2007 08:20 PM

haskell-cafe at haskell.org

[Haskell-cafe] Looking at program execution

Is there any way to view the steps that a haskell program goes 
through step by step?
I'm thinking something similar to what I've seen in things I've been 
reading. For example:
foldl (+) 0 [1..10]
=> (0+1)
=> ((0+1)+2)
=> (((0+1)+2)+3)
=> etc.
I've seen these sorts of line-by-line execution steps, but I was 
curious if there was any way to simply type in a function and its 
arguments and have ghci or hugs or something print out this sort of 
visual representation of what's going on. Anyone know of something 
like this?
Haskell-Cafe mailing list
Haskell-Cafe at haskell.org


This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070817/57c2c7e6/attachment-0001.htm

More information about the Haskell-Cafe mailing list