Sophie

Sophie

distrib > Mandriva > 2009.0 > i586 > by-pkgid > 8de1f55ea6a1a64d0f3f3ea116288458 > files > 104

happy-1.17-3mdv2009.0.i586.rpm

<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>8.5. Using Happy with GHCi</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-conflict-tips.html" title="8.4. Conflict Tips"><link rel="next" href="ix01.html" title="Index"></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.5. Using Happy with <span class="application">GHCi</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="sec-conflict-tips.html">Prev</a> </td><th width="60%" align="center">Chapter 8. Tips</th><td width="20%" align="right"> <a accesskey="n" href="ix01.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-happy-ghci"></a>8.5. Using Happy with <span class="application">GHCi</span></h2></div></div></div><a class="indexterm" name="id2551497"></a><p><span class="application">GHCi</span>'s compilation manager
      doesn't understand Happy grammars, but with some creative use of
      macros and makefiles we can give the impression that
      <span class="application">GHCi</span> is invoking Happy
      automatically:</p><div class="itemizedlist"><ul type="disc"><li><p>Create a simple makefile, called
	  <code class="filename">Makefile_happysrcs</code>:</p><pre class="programlisting">HAPPY = happy
HAPPY_OPTS = 

all: MyParser.y

%.hs: %.y
	$(HAPPY) $(HAPPY_OPTS) $&lt; -o $@</pre></li><li><p>Create a macro in GHCi to replace the
          <code class="literal">:reload</code> command, like so (type this all
          on one line):</p><pre class="screen">:def rh (\_ -&gt; System.system "make -f Makefile_happysrcs"
   &gt;&gt;= \rr -&gt; case rr of { System.ExitSuccess -&gt; return ":reload" ; 
                           _ -&gt; return "" })</pre></li><li><p>Use <code class="literal">:myreload</code>
	  (<code class="literal">:my</code> will do) instead of
	  <code class="literal">:reload</code> (<code class="literal">:r</code>).</p></li></ul></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sec-conflict-tips.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="ix01.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">8.4. Conflict Tips </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Index</td></tr></table></div></body></html>