2 <Title>Other Haskell utility programs
5 <IndexTerm><Primary>utilities, Haskell</Primary></IndexTerm>
8 This section describes other program(s) which we distribute, that help
9 with the Great Haskell Programming Task.
12 <Sect1 id="mkdependHS">
13 <Title>Makefile dependencies in Haskell: using <Command>mkdependHS</Command>
17 <IndexTerm><Primary>mkdependHS</Primary></IndexTerm>
18 <IndexTerm><Primary>Makefile dependencies</Primary></IndexTerm>
19 <IndexTerm><Primary>dependencies in Makefiles</Primary></IndexTerm>
23 You run <Command>mkdependHS</Command> like this:
26 mkdependHS [mkdependHS options] [-- GHC options --] srcfile1 [srcfile2 ...]
32 ghc -M [mkdependHS options(prefix with -optdep)] [ GHC options ] srcfile1 [srcfile2 ...]
35 To see <Command>mkdependHS</Command>'s command-line flags, give it a duff flag,
36 e.g., <Command>mkdependHS -help</Command>.
40 In general, if module <Literal>A</Literal> contains the line
46 then <Command>mkdependHS</Command> will generate a dependency line of the form:
52 If module <Literal>A</Literal> contains the line
55 import {-# SOURCE #-} B ...blah...
58 then <Command>mkdependHS</Command> will generate a dependency line of the form:
64 (See <XRef LinkEnd="hi-files"> for details of interface files.)
65 If <Literal>A</Literal> imports multiple modules, then there will be multiple lines with <Filename>A.o</Filename> as the
70 By default, <Command>mkdependHS</Command> generates all the dependencies, and then
71 concatenates them onto the end of
72 <Filename>makefile</Filename> (or <Filename>Makefile</Filename> if <Filename>makefile</Filename> doesn't exist) bracketed by
73 the lines "<Literal># DO NOT DELETE: Beginning of Haskell dependencies</Literal>" and
74 "<Literal># DO NOT DELETE: End of Haskell dependencies</Literal>". If these lines
75 already exist in the <Filename>makefile</Filename>, <Command>mkdependHS</Command> deletes the old
80 <Command>mkdependHS</Command> takes GHC options between <Literal>--</Literal> brackets.
81 It understands the following ones. Any options between <Literal>--</Literal> brackets
82 that it doesn't understand are simply ignored; this way you can feed your
83 Makefile's standard GHC options to <Command>mkdependHS</Command> un-filtered.
87 <Term><Option>-cpp</Option></Term>
90 Run the C pre-processor over the input files. The
96 <Term><Option>-D<blah></Option></Term>
99 A cpp <Option>#define</Option>; usual meaning.
104 <Term><Option>-i<dirs></Option></Term>
107 Add <Filename><dirs></Filename> (colon-separated) to list of directories
108 to search for "import"ed modules.
113 <Term><Option>-I<dir></Option></Term>
116 Add <Filename><dir></Filename> to list of directories to search for
117 .h files (i.e., usual meaning).
122 <Term><Option>-syslib <blah></Option></Term>
125 This program uses this GHC system library; take
126 appropriate action (e.g., recognise when they are
127 "import"ing a module from that library).
135 Here are the <Command>mkdependHS</Command>-specific options (not between <Literal>--</Literal>'s):
139 <Term><Option>-v</Option></Term>
147 <Term><Option>-v -v</Option></Term>
155 <Term><Option>-w</Option></Term>
158 Turn off warnings about interface file shadowing.
163 <Term><Option>-f blah</Option></Term>
166 Use <Filename>blah</Filename> as the makefile, rather than <Filename>makefile</Filename>
167 or <Filename>Makefile</Filename>. If <Filename>blah</Filename> doesn't exist, <Command>mkdependHS</Command> creates it.
168 We often use <Option>-f .depend</Option> to put the dependencies in <Filename>.depend</Filename> and
169 then <Command>include</Command> the file <Filename>.depend</Filename> into <Filename>Makefile</Filename>.
174 <Term><Option>-o <osuf></Option></Term>
177 Use <Filename>.<osuf></Filename> as the "target file" suffix ( default: <Literal>o</Literal>).
178 Multiple <Option>-o</Option> flags are permitted (GHC2.05 onwards). Thus "<Option>-o hc -o o</Option>"
179 will generate dependencies for <Filename>.hc</Filename> and <Filename>.o</Filename> files.
184 <Term><Option>-s <suf></Option></Term>
187 Make extra dependencies that declare that files with
188 suffix <Filename>.<suf>_<osuf></Filename> depend on interface files with suffix <Filename>.<suf>_hi</Filename>, or
189 (for <Literal>{-# SOURCE #-}</Literal> imports) on <Filename>.hi-boot</Filename>.
190 Multiple <Option>-s</Option> flags are permitted.
191 For example, <Option>-o hc -s a -s b</Option> will
192 make dependencies for <Filename>.hc</Filename> on <Filename>.hi</Filename>, <Filename>.a_hc</Filename> on <Filename>.a_hi</Filename>, and <Filename>.b_hc</Filename> on <Filename>.b_hi</Filename>.
193 (Useful in conjunction with NoFib "ways".)
198 <Term><Option>--exclude-module=<file></Option></Term>
201 Regard <Filename><file></Filename> as "stable"; i.e., exclude it from having
207 <Term><Option>-x</Option></Term>
210 same as <Option>--exclude-module</Option>
215 <Term><Option>--exclude-directory=<dirs></Option></Term>
218 Regard the colon-separated list of directories <Filename><dirs></Filename> as containing stable,
219 don't generate any dependencies on modules therein.
224 <Term><Option>-Xdirs</Option></Term>
227 same as <Option>--exclude-directory</Option>.
232 <Term><Option>--include-module=<file></Option></Term>
235 Regard <Filename><file></Filename> as not "stable"; i.e., generate dependencies
236 on it (if any). This option is normally used in conjunction
237 with the <Option>--exclude-directory</Option> option.
242 <Term><Option>--include-prelude</Option></Term>
245 Regard prelude libraries as unstable, i.e., generate dependencies
246 on the prelude modules used (including <Literal>Prelude</Literal>).
247 This option is normally only used by the various system libraries. If
248 a <Option>-syslib</Option> option is used, dependencies will also be
249 generated on the library's interfaces.
259 <Title>Emacs `TAGS' for Haskell: <Command>hstags</Command>
263 <IndexTerm><Primary>hstags</Primary></IndexTerm>
264 <IndexTerm><Primary>TAGS for Haskell</Primary></IndexTerm>
268 `Tags' is a facility for indexing the definitions of
269 programming-language things in a multi-file program, and then using
270 that index to jump around among these definitions.
274 Rather than scratch your head, saying ``Now where did we define
275 `foo'?'', you just do (in Emacs) <Literal>M-. foo RET</Literal>, and You're There!
276 Some people go wild over this stuff…
280 GHC comes with a program <Command>hstags</Command>, which build Emacs-able TAGS files. The invocation syntax is:
283 hstags [GHC-options] file [files...]
289 The best thing is just to feed it your GHC command-line flags.
290 A good Makefile entry might be:
295 hstags $(GHC_FLAGS) *.lhs
301 The only flags of its own are: <Option>-v</Option> to be verbose; <Option>-a</Option> to
302 <Emphasis>APPEND</Emphasis> to the TAGS file, rather than write to it.
306 Shortcomings: (1) Instance declarations don't get into the TAGS file
307 (but the definitions inside them do); as instances aren't named, this
308 is probably just as well. (2) Data-constructor definitions don't get
309 in. Go for the corresponding type constructor instead.
313 (Actually, GHC also comes with <Command>etags</Command> [for C], and <Command>perltags</Command>
314 [for You Know What]. And—I cannot tell a lie—there is Denis
315 Howe's <Command>fptags</Command> [for Haskell, etc.] in the <Filename>ghc/CONTRIB</Filename>
322 <Title>``Yacc for Haskell'': <Command>happy</Command>
326 <IndexTerm><Primary>happy</Primary></IndexTerm>
327 <IndexTerm><Primary>Yacc for Haskell</Primary></IndexTerm>
328 <IndexTerm><Primary>parser generator for Haskell</Primary></IndexTerm>
329 Andy Gill and Simon Marlow have written a parser-generator for
330 Haskell, called <Command>happy</Command>.<IndexTerm><Primary>happy parser generator</Primary></IndexTerm> <Command>Happy</Command>
331 is to Haskell what <Command>Yacc</Command> is to C.
335 You can get <Command>happy</Command> by FTP from <Literal>ftp.dcs.gla.ac.uk</Literal> in
336 <Filename>pub/haskell/happy</Filename>, the file <Filename>happy-1.5-src.tar.gz</Filename>.
340 <Command>Happy</Command> is at its shining best when compiled by GHC.
346 <Title>Pretty-printing Haskell: <Command>pphs</Command>
350 <IndexTerm><Primary>pphs</Primary></IndexTerm>
351 <IndexTerm><Primary>pretty-printing Haskell code</Primary></IndexTerm>
355 Andrew Preece has written
356 <Command>pphs</Command>,<IndexTerm><Primary>pphs</Primary></IndexTerm><IndexTerm><Primary>pretty-printing Haskell</Primary></IndexTerm>
357 a utility to pretty-print Haskell code in LaTeX documents.
358 Keywords in bolds, variables in italics—that sort of thing. It is
359 good at lining up program clauses and equals signs, things that are
360 very tiresome to do by hand.
364 The code is distributed with GHC in <Filename>ghc/CONTRIB/pphs</Filename>.