<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>8.3. Finding Type Errors</title><link rel="stylesheet" href="fptools.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><link rel="start" href="index.html" title="Happy User Guide"><link rel="up" href="sec-tips.html" title="Chapter 8. Tips"><link rel="prev" href="sec-compilation-time.html" title="8.2. Compilation-Time Tips"><link rel="next" href="sec-conflict-tips.html" title="8.4. Conflict Tips"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">8.3. Finding Type Errors</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="sec-compilation-time.html">Prev</a> </td><th width="60%" align="center">Chapter 8. Tips</th><td width="20%" align="right"> <a accesskey="n" href="sec-conflict-tips.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec-finding-errors"></a>8.3. Finding Type Errors</h2></div></div></div><a class="indexterm" name="id2551207"></a><p>Finding type errors in grammar files is inherently difficult because the code for reductions is moved around before being placed in the parser. We currently have no way of passing the original filename and line numbers to the Haskell compiler, so there is no alternative but to look at the parser and match the code to the grammar file. An info file (generated by the <code class="literal">-i</code> option) can be helpful here.</p><a class="indexterm" name="id2551234"></a><p>Type signature sometimes help by pinning down the particular error to the place where the mistake is made, not half way down the file. For each production in the grammar, there's a bit of code in the generated file that looks like this:</p><pre class="programlisting"> HappyAbsSyn<n> ( E ) </pre><a class="indexterm" name="id2551259"></a><p>where <code class="literal">E</code> is the Haskell expression from the grammar file (with <code class="literal">$n</code> replaced by <code class="literal">happy_var_n</code>). If there is a type signature for this production, then <span class="application">Happy</span> will have taken it into account when declaring the HappyAbsSyn datatype, and errors in <code class="literal">E</code> will be caught right here. Of course, the error may be really caused by incorrect use of one of the <code class="literal">happy_var_n</code> variables.</p><p>(this section will contain more info as we gain experience with creating grammar files. Please send us any helpful tips you find.)</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sec-compilation-time.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="sec-tips.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sec-conflict-tips.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">8.2. Compilation-Time Tips </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 8.4. Conflict Tips</td></tr></table></div></body></html>