Tracer for Haskell showing substitutions

Hi all, I was wondering if someone has written a tracer/debugger that shows you how a given Haskell expression is evaluated, by generating all the intermediate states of the expression until it is in normal form? For instance, given the following code:
take' 0 xs = [] take' n (x:xs) = x : take' (n-1) xs exp = take' 2 [1,2,3,4,5,6]
the trace of 'exp' would generate something like this:
exp = take' 2 [1,2,3,4,5,6] exp = (\n (x:xs) -> x : take' (n-1) xs) 2 [1,2,3,4,5,6] exp = 1 : take' (2-1) [2,3,4,5,6] exp = 1 : take' 1 [2,3,4,5,6] exp = 1 : (\n (x:xs) -> x : take' (n-1) xs) 1 [2,3,4,5,6] exp = 1 : 2 : take' (1-1) [3,4,5,6] exp = 1 : 2 : take' 0 [3,4,5,6] exp = 1 : 2 : (\0 xs -> []) 0 [3,4,5,6] exp = 1 : 2 : [] exp = [1,2]
That is, all the substitutions performed when evaluating 'exp' from left to right. I was thinking that something like this could be rather useful when teaching or learning Haskell. Thanks, Ulrik

From the site: Hat helps locating errors in programs. Furthermore, it is useful for understanding how a (correct) program works, especially for teaching and
Hi, "Hat": The Haskell Tracer. http://www.haskell.org/hat/ program maintenance. Hat is not a time or space profiler. Hat can be used for programs that terminate normally, that terminate with an error message or that terminate when interrupted by the programmer. "Vital"/"Pivotal": it's dead, but it may be interesting to you anyway. http://www.cs.kent.ac.uk/projects/pivotal/ http://www.cs.kent.ac.uk/projects/vital/
From the site: Pivotal has similar goals to its predecessor system, Vital. In particular: * Documents are live in the sense that, if a document is changed, the displayed values are automatically re-evaluated. Thus documents are always in a consistent state. * Direct manipulation of ADT values is supported. That is, an end user is able to manipulate the text of a Haskell module simply by point-and-click mouse operations on displayed values.
Pen and paper work too. Ezra. Ulrik Rasmussen-2 wrote:
Hi all,
I was wondering if someone has written a tracer/debugger that shows you how a given Haskell expression is evaluated, by generating all the intermediate states of the expression until it is in normal form?
For instance, given the following code:
take' 0 xs = [] take' n (x:xs) = x : take' (n-1) xs exp = take' 2 [1,2,3,4,5,6]
the trace of 'exp' would generate something like this:
exp = take' 2 [1,2,3,4,5,6] exp = (\n (x:xs) -> x : take' (n-1) xs) 2 [1,2,3,4,5,6] exp = 1 : take' (2-1) [2,3,4,5,6] exp = 1 : take' 1 [2,3,4,5,6] exp = 1 : (\n (x:xs) -> x : take' (n-1) xs) 1 [2,3,4,5,6] exp = 1 : 2 : take' (1-1) [3,4,5,6] exp = 1 : 2 : take' 0 [3,4,5,6] exp = 1 : 2 : (\0 xs -> []) 0 [3,4,5,6] exp = 1 : 2 : [] exp = [1,2]
That is, all the substitutions performed when evaluating 'exp' from left to right.
I was thinking that something like this could be rather useful when teaching or learning Haskell.
Thanks,
Ulrik _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- View this message in context: http://old.nabble.com/Tracer-for-Haskell-showing-substitutions-tp27421880p27... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
participants (2)
-
Ezra Lalonde
-
Ulrik Rasmussen