File: index.html

package info (click to toggle)
hat 2.02-12
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 8,296 kB
  • ctags: 668
  • sloc: haskell: 64,394; ansic: 6,112; sh: 888; makefile: 451
file content (340 lines) | stat: -rw-r--r-- 11,496 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<html>

<head><title>Hat - the Haskell Tracer</title></head>
<body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B"
      alink="#FF0000">

<center>
  <img src="hat.gif" alt="Hat Logo">
  <h1>Hat - the Haskell Tracer</h1>
</center>
<hr>

<table><tr>
<td width=50% valign=top>
<p>
<center><b>about</b></center>
<font face="Helvetica">
<dl>
<dd><a href="#intro">What is Hat?</a></dd>
<dd><a href="#tools">How do I view a trace?</a></dd>
<dd><a href="feature-table.html">Coverage of Haskell 98 + extensions</a></dd>
<dd><a href="bugs.html">Known bugs</a></dd>
<dd><a href="libraries.html">Libraries supported by <b>Hat</b></a></dd>
<dd><a href="faq.html">Frequently asked questions</a></dd>
<dd><a href="copyright.html">Copyright and licence information</a></dd>
</dl>
</font>

</td><td width=50% valign=top>

<p>
<center><b>download/build/install</b></center>
<font face="Helvetica">
<dl>
<dd><img src="new_tiny.gif" alt="new">
    Version 2.02 released 26th March 2003.</dd>
<dd><a href="download.html">Download <b>Hat</b></a></dd>
<dd><a href="requirements.html">System requirements</a></dd>
<dd><a href="install.html">Build and install instructions</a></dd>
<dd><a href="config.html">Configuration options</a></dd>
<dd><a href="status.html">Recent changes</a></dd>
</dl>
</font>

</td></tr><tr><td width=50% valign=top>

<p>
<center><b>user guides</b></center>
<font face="Helvetica">
<dl>
<dd>A simple tutorial introduction:<br>
    &nbsp;&nbsp;
    <a href="tutorial1.html">(HTML)</a>
    <a href="tutorial1.tex">(TeX)</a>
    <a href="tutorial1.ps">(PostScript)</a>
    <a href="tutorial1.pdf">(PDF)</a>
    </dd>
<dd>A more advanced tutorial:<br>
    &nbsp;&nbsp;
    (not yet available)
    </dd>
<dd>The Hat user manual:<br>
    &nbsp;&nbsp;
    <a href="hatuser.html">(HTML)</a>
    <a href="hatuser.tex">(TeX)</a>
    <a href="hatuser.ps">(PostScript)</a>
    <a href="hatuser.pdf">(PDF)</a>
    </dd>
<dd><a href="hat-trans.html">Reference Guide (hat-trans)</a></dd>
<dd><a href="hat-tools.html">Reference Guide (browsers)</a></dd>
</dl>
</font>

</td><td width=50% valign=top>

<p>
<center><b>development</b></center>
<font face="Helvetica">
<dl>
<dd><a href="publications.html">Technical publications</a></dd>
<dd><a href="bugs.html">Known bugs</a></dd>
<dd><a href="todo.html">Wish list</a></dd>
<dd><a href="cvs.html">Anonymous CVS repository</a></dd>
</dl>
</font>

</td></tr><tr><td width=50% valign=top>

<p>
<center><b>community</b></center>
<font face="Helvetica">
<dl>
<dd><a href="maillist.html">
    Mailing list for everything <b>Hat</b>-related</a></dd>
<dd><a href="http://haskell.org/mailman/listinfo">
    More general Haskell mailing lists</a></dd>
<dd><a href="http://www.haskell.org/">
    Other Haskell systems and resources</a></dd>
</dl>
</font>

</td><td width=50% valign=top>

</td></tr></table>

<p align=center>
<font size=1>
Development of Hat was funded by grant number GR/M81953 from the Engineering
and Physical Sciences Research Council of the United Kingdom.
</font>

<hr>

<a name="intro">
<h2>What is Hat?</h2></a>
<p>
<b>Hat</b> is a source-level tracer for 
<a href="http://www.haskell.org/"><em>Haskell 98</em></a>, the
standard lazy functional programming language.  Hat is a tool that
gives the user access to otherwise invisible information about a
computation.

<p>
<b>Hat</b> is portable between compilers: it works with both
<em>ghc</em> and <em>nhc98</em>.  It also supports various language
extensions, such as the FFI, multi-parameter type classes, functional
dependencies, and hierarchical module namespaces.

<h3>What is it good for?</h3>
<p>
Hat helps locating errors in programs.  Furthermore, it is useful for
understanding how a (correct) program works, especially for teaching
and program maintenance.  Hat is <em>not</em> 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.

<h3>How does it work?</h3>
<p>
Tracing a program with Hat consists of two phases: First the specially
compiled program runs as normal, except that additionally a trace is
written to file. Second, after the program has terminated, the trace
is viewed with a browsing tool.
The trace consists of high-level information about the computation. It
describes each reduction, that is, the replacements of an instance
of a left-hand side of an equation by an instance of its right-hand
side, and the relation of the reduction to other reductions.
Because the trace describes the whole computation, it is huge. Hat
comes with several tools to selectively view the fragments of the trace
that are of interest. Each tool shows fragments of the computation
in a particular way, highlighting a specific aspect.

<a name="tools">
<h2>How can I view a trace?</h2>

Because the trace describes the whole computation, it is huge. Hat
comes with several tools to selectively view the fragments of the trace
that are of interest. Each tool shows fragments of the computation
in a particular way, highlighting a specific aspect.

<p>
All tools show function arguments in evaluated form, more precisely: as
far evaluated as the arguments are at the end of the computation. For
example, although in a computation the unevaluated expression <kbd>(map
(+5) [1,2])</kbd> might be passed to the function <kbd>length</kbd>,
the tools will show the function application as <kbd>length
[1+5,2+5]</kbd> or <kbd>length [_,_]</kbd>.

<ul>

<li><strong>Hat-observe</strong> (inspired by <a
href="http://haskell.org/hood">Hood</a>) <br>

Hat-observe is an interactive tool that shows how top-level functions
are used.  That is, for a given top-level function name it shows
all the arguments with which it is called during the computation,
together with the respective results.

<p>
For example, for the computation of the faulty program
<pre>
main = let xs :: [Int]
           xs = [4*2,5 `div` 0,5+6]
       in  print (head xs,last' xs)

last' (x:xs) = last' xs
last' [x] = x
</pre>

gives the result
<pre>
(8, No match in pattern.
</pre>
and the hat-observe tool can be used to explore its behaviour as follows:

<pre>
$ hat-observe Example

                hat-observe 2.00    (:h for help, :q to quit)

hat-observe&gt; main
<font color=blue>1</font>  main = IO (print (8,_|_))
hat-observe&gt; print
<font color=blue>1</font>  print (8,_|_) = IO (print (8,_|_))
hat-observe&gt; last'
<font color=blue>1</font>  last' [8,_,_] = _|_
<font color=blue>2</font>  last' [_,_] = _|_
<font color=blue>3</font>  last' [_] = _|_
<font color=blue>4</font>  last' [] = _|_
hat-observe&gt; :quit
$
</pre>
<p>

<li><strong>Hat-trail</strong><br>

Hat-trail is an interactive tool that enables exploring a computation
<em>backwards</em>, starting at the program output or an error message
(with which the computation aborted).  This is particularly useful
for locating an error.  You start at the observed faulty behaviour
and work backwards towards the source of the error.

<p>
Every reduction replaces an instance of the left-hand side of a program
equation by an instance of its right-hand side. The instance of the
left-hand side ``creates'' the instance of the right-hand side and is
therefore called its <em>parent</em>. With hat-trail you can obtain
the parent of any expression.

<p>
(Note: if you cannot see any highlighting in the following diagram,
try changing the fixed-width font in your browser to something like
Courier text.)  Each line of the trail is the parent of the highlighted
subexpression directly above it.

<pre>
<strong>Error: -------------------------------------------------------</strong>
<font color=red>No match in pattern.</font>
<strong>Output: ------------------------------------------------------</strong>
(8,
<strong>Trail: ---------------------- </strong>Example.hs line: 2 col: 12<strong> -----</strong>
&lt;- <font color=red>last' []</font>
&lt;- <font color=red>last' [_]</font>
&lt;- <font color=red>last' [_,_]</font>
&lt;- last' [<font color=red>8</font>,_,_]
&lt;- <font color=red>4 * 2</font>
&lt;- <strong><font color=magenta>xs</font></strong>
</pre>
<p>
Here, the error message is chosen as the starting point, rather
than any of the output.  The first trail is therefore
<kbd>last' []</kbd>, because its evaluation caused the error message.
The parent of <kbd>last' []</kbd> is
<kbd>last' [_]</kbd>.  The parent of <kbd>last' [_]</kbd>
is <kbd>last' [_,_])</kbd>, etc. The parent of the
subexpression <kbd>8</kbd> is <kbd>4*2</kbd> whose parent is
<kbd>xs</kbd>.
<p>

<li><strong>Hat-detect</strong> (inspired by <a
href="http://www.ida.liu.se/~henni/">Freja</a>) <br>
Hat-detect is an interactive tool that enables the semi-automatic
location of an error in a program by answering a sequence of yes/no
questions.  Each question asked by hat-detect concerns the reduction
of a redex - that is, a function application - to a value.  You have to
answer <em>yes</em>, if the reduction is correct with respect to your
intentions, and <em>no</em> otherwise.  After a number of questions
hat-detect states which reduction is the cause of the observed faulty
behaviour - that is, which function definition is incorrect.

<p>
Example session (y/n answers are given by the user):
<pre>
$ hat-detect Example

                hat-detect 2.0x    (:h for help, :q to quit)

<font color=blue>1</font>  main = IO (print [3,3,3])   ? n
<font color=blue>2</font>  sort [3,2,1] = [3,3,3]   ? n
<font color=blue>3</font>  insert 1 [] = [1]     ? y
<font color=blue>4</font>  insert 2 [1] = [2,2]     ? n
<font color=blue>5</font>  insert 2 [] = [2]     ? y

Error located!
Bug found in reduction:   insert 2 [1] = [2,2]
</pre>
<p>

<li><strong>Hat-stack</strong><br>

For aborted computations, that is computations that terminated
with an error message or were interrupted, hat-stack shows in which
function call the computation was aborted.  It does so by showing a
<em>virtual</em> stack of function calls (redexes).  Thus, every function
call shown on the stack caused the function call above it. The evaluation
of the top stack element caused the error (or during its evaluation
the computation was interrupted).  The stack shown is <em>virtual</em>,
because it does not correspond to the actual runtime stack.  The actual
runtime stack enables lazy evaluation whereas the <em>virtual</em>
stack corresponds to a stack that would be used for eager (strict)
evaluation.

<p>
Using the same example program as above, hat-stack shows
<pre>
$ hat-stack Example
Program terminated with error:
    "No match in pattern."
Virtual stack trace:                     source file/line/col
    (last' [])                            Example.hs   6  16
    (last' (5+6:[]))                      Example.hs   6  16
    (last' ((div 5 0):5+6:[]))            Example.hs   6  16
    (last' (8:(div 5 0):5+6:[]))          Example.hs   4  27
    main                                  Example.hs   2   1
$
</pre>
<p>

</ul>


<p>
If you have any problems, please send a message to the
mailing list at <a href="mailto:hat@haskell.org">hat@haskell.org</a>.

<hr>
<p>
The latest updates to these pages are available on the WWW from
<a href="http://www.haskell.org/hat/">
<tt>http://www.haskell.org/hat/</tt></a><br>
<a href="http://www.cs.york.ac.uk/fp/hat/">
<tt>http://www.cs.york.ac.uk/fp/hat/</tt></a>

<p>
This page last modified: 26th March 2003<br>
<a href="http://www.cs.york.ac.uk/fp/">
York Functional Programming Group</a><br>

</body></html>