1 %************************************************************************
3 \section[utils]{Other Haskell utility programs}
4 \index{utilities, Haskell}
6 %************************************************************************
8 This section describes other program(s) which we distribute, that help
9 with the Great Haskell Programming Task.
11 %************************************************************************
13 \subsection[mkdependHS]{Makefile dependencies in Haskell: using \tr{mkdependHS}}
15 \index{Makefile dependencies}
16 \index{dependencies in Makefiles}
18 %************************************************************************
20 You run @mkdependHS@ like this:
22 mkdependHS [mkdependHS options] [-- GHC options --] srcfile1 [srcfile2 ...]
26 ghc -M [mkdependHS options(prefix with -optdep)] [ GHC options ] srcfile1 [srcfile2 ...]
28 To see \tr{mkdependHS}'s command-line flags, give it a duff flag,
29 e.g., \tr{mkdependHS -help}.
31 In general, if module @A@ contains the line
35 then @mkdependHS@ will generate a dependency line of the form:
39 If module @A@ contains the line
41 import {-# SOURCE #-} B ...blah...
43 then @mkdependHS@ will generate a dependency line of the form:
47 (See \Sectionref{hi-files} for details of interface files.)
48 If @A@ imports multiple modules, then there will be multiple lines with @A.o@ as the
51 By default, @mkdependHS@ generates all the dependencies, and then
52 concatenates them onto the end of
53 @makefile@ (or @Makefile@ if @makefile@ doesn't exist) bracketed by
54 the lines "@# DO NOT DELETE: Beginning of Haskell dependencies@" and
55 "@# DO NOT DELETE: End of Haskell dependencies@". If these lines
56 already exist in the @makefile@, @mkdependHS@ deletes the old
59 @mkdependHS@ takes GHC options between @--@ brackets.
60 It understands the following ones. Any options between @--@ brackets
61 that it doesn't understand are simply ignored; this way you can feed your
62 Makefile's standard GHC options to @mkdependHS@ un-filtered.
65 \item[@-D<blah>@] A cpp @#define@; usual meaning.
67 \item[@-i<dirs>@] Add @<dirs>@ (colon-separated) to list of directories
68 to search for "import"ed modules.
70 \item[@-I<dir>@] Add @<dir>@ to list of directories to search for
71 .h files (i.e., usual meaning).
73 \item[@-syslib <blah>@] This program uses this GHC system library; take
74 appropriate action (e.g., recognise when they are
75 "import"ing a module from that library).
77 \item[@-ignore <mod>@]
80 Here are the @mkdependHS@-specific options (not between @--@'s):
82 \item[@-v@] Be verbose.
83 \item[@-v -v@] Be very verbose.
84 \item[@-w@] Turn off warnings about interface file shadowing.
86 Use @blah@ as the makefile, rather than @makefile@
87 or @Makefile@. If @blah@ doesn't exist, @mkdependHS@ creates it.
88 We often use @-f .depend@ to put the dependencies in @.depend@ and
89 then @include@ the file @.depend@ into @Makefilpe@.
92 Use @.<osuf>@ as the "target file" suffix ( default: @o@).
93 Multiple @-o@ flags are permitted (GHC2.05 onwards). Thus "@-o hc -o o@"
94 will generate dependencies for @.hc@ and @.o@ files.
97 Make extra dependencies that declare that files with
98 suffix @.<suf>_<osuf>@ depend on interface files with suffix @.<suf>_hi@, or
99 (for @{-# SOURCE #-}@ imports) on @.hi-boot@.
100 Multiple @-s@ flags are permitted.
101 For example, "@-o hc -s a -s b@" will
102 make dependencies for @.hc@ on @.hi@, @.a_hc@ on @.a_hi@, and @.b_hc@ on @.b_hi@.
103 (Useful in conjunction with NoFib "ways".)
105 \item[@--exclude-module=<file>@]
106 Regard @<file>@ as "stable"; i.e., exclude it from having
109 \item[@-x@] same as @--exclude-module@
111 \item[@--exclude-directory=<dirs>@]
112 Regard the colon-separated list of directories @<dirs>@ as containing stable,
113 don't generate any dependencies on modules therein.
115 \item[@-Xdirs@] same as @--exclude-directory@.
117 \item[@--include-module=<file>@]
118 Regard @<file>@ as not "stable"; i.e., generate dependencies
119 on it (if any). This option is normally used in conjunction
120 with the @--exclude-directory@ option.
121 \item[@--include-prelude@]
122 Regard prelude libraries as unstable, i.e., generate dependencies
123 on the prelude modules used (including \tr{Prelude}).
124 This option is normally only used by the various system libraries. If
125 a \tr{-syslib} option is used, dependencies will also be
126 generated on the library's interfaces.
130 %************************************************************************
132 \subsection[hstags]{Emacs `TAGS' for Haskell: \tr{hstags}}
134 \index{TAGS for Haskell}
136 %************************************************************************
138 `Tags' is a facility for indexing the definitions of
139 programming-language things in a multi-file program, and then using
140 that index to jump around among these definitions.
142 Rather than scratch your head, saying ``Now where did we define
143 `foo'?'', you just do (in Emacs) \tr{M-. foo RET}, and You're There!
144 Some people go wild over this stuff...
146 GHC comes with a program \tr{hstags}, which build Emacs-able TAGS
147 files. The invocation syntax is:
149 hstags [GHC-options] file [files...]
152 The best thing is just to feed it your GHC command-line flags.
153 A good Makefile entry might be:
157 hstags $(GHC_FLAGS) *.lhs
160 The only flags of its own are: \tr{-v} to be verbose; \tr{-a} to
161 **APPEND** to the TAGS file, rather than write to it.
163 Shortcomings: (1)~Instance declarations don't get into the TAGS file
164 (but the definitions inside them do); as instances aren't named, this
165 is probably just as well. (2)~Data-constructor definitions don't get
166 in. Go for the corresponding type constructor instead.
168 (Actually, GHC also comes with \tr{etags} [for C], and \tr{perltags}
169 [for You Know What]. And---I cannot tell a lie---there is Denis
170 Howe's \tr{fptags} [for Haskell, etc.] in the \tr{ghc/CONTRIB}
173 %************************************************************************
175 \subsection[happy]{``Yacc for Haskell'': \tr{happy}}
177 \index{Yacc for Haskell}
178 \index{parser generator for Haskell}
180 %************************************************************************
182 Andy Gill and Simon Marlow have written a parser-generator for
183 Haskell, called \tr{happy}.\index{happy parser generator} \tr{Happy}
184 is to Haskell what \tr{Yacc} is to C.
186 You can get \tr{happy} by FTP from \tr{ftp.dcs.gla.ac.uk} in
187 \tr{pub/haskell/happy}, the file \tr{happy-0.8.tar.gz}.
189 \tr{Happy} is at its shining best when compiled by GHC.
191 %************************************************************************
193 \subsection[pphs]{Pretty-printing Haskell: \tr{pphs}}
195 \index{pretty-printing Haskell code}
197 %************************************************************************
199 Andrew Preece has written
200 \tr{pphs},\index{pphs}\index{pretty-printing Haskell}
201 a utility to pretty-print Haskell code in LaTeX documents.
202 Keywords in bolds, variables in italics---that sort of thing. It is
203 good at lining up program clauses and equals signs, things that are
204 very tiresome to do by hand.
206 The code is distributed with GHC in \tr{ghc/CONTRIB/pphs}.