%************************************************************************ %* * \section[utils]{Other Haskell utility programs} \index{utilities, Haskell} %* * %************************************************************************ This section describes other program(s) which we distribute, that help with the Great Haskell Programming Task. %************************************************************************ %* * \subsection[mkdependHS]{Makefile dependencies in Haskell: using \tr{mkdependHS}} \index{mkdependHS} \index{Makefile dependencies} \index{dependencies in Makefiles} %* * %************************************************************************ You run @mkdependHS@ like this: \begin{verbatim} mkdependHS [mkdependHS options] [-- GHC options --] srcfile1 [srcfile2 ...] \end{verbatim} or \begin{verbatim} ghc -M [mkdependHS options(prefix with -optdep)] [ GHC options ] srcfile1 [srcfile2 ...] \end{verbatim} To see \tr{mkdependHS}'s command-line flags, give it a duff flag, e.g., \tr{mkdependHS -help}. In general, if module @A@ contains the line \begin{verbatim} import B ...blah... \end{verbatim} then @mkdependHS@ will generate a dependency line of the form: \begin{verbatim} A.o : B.hi \end{verbatim} If module @A@ contains the line \begin{verbatim} import {-# SOURCE #-} B ...blah... \end{verbatim} then @mkdependHS@ will generate a dependency line of the form: \begin{verbatim} A.o : B.hi-boot \end{verbatim} (See \Sectionref{hi-boot} for details of @.hi-boot@ files.) If @A@ imports multiple modules, then there will be multiple lines with @A.o@ as the target. By default, @mkdependHS@ generates all the dependencies, and then concatenates them onto the end of @makefile@ (or @Makefile@ if @makefile@ doesn't exist) bracketed by the lines "@# DO NOT DELETE: Beginning of Haskell dependencies@" and "@# DO NOT DELETE: End of Haskell dependencies@". If these lines already exist in the @makefile@, @mkdependHS@ deletes the old dependencies first. @mkdependHS@ takes GHC options between @--@ brackets. It understands the following ones. Any options between @--@ brackets that it doesn't understand are simply ignored; this way you can feed your Makefile's standard GHC options to @mkdependHS@ un-filtered. \begin{description} \item[@-D@] A cpp @#define@; usual meaning. \item[@-i@] Add @@ (colon-separated) to list of directories to search for "import"ed modules. \item[@-I@] Add @@ to list of directories to search for .h files (i.e., usual meaning). \item[@-syslib @] This program uses this GHC system library; take appropriate action (e.g., recognise when they are "import"ing a module from that library). \item[@-ignore @] \end{description} Here are the @mkdependHS@-specific options (not between @--@'s): \begin{description} \item[@-v@] Be verbose. \item[@-v -v@] Be very verbose. \item[@-f blah@] Use @blah@ as the makefile, rather than @makefile@ or @Makefile@. If @blah@ doesn't exist, @mkdependHS@ creates it. We often use @-f .depend@ to put the dependencies in @.depend@ and then @include@ the file @.depend@ into @Makefilpe@. \item[@-o @] Use @.@ as the "target file" suffix ( default: @o@). Multiple @-o@ flags are permitted (GHC2.05 onwards). Thus "@-o hc -o o@" will generate dependencies for @.hc@ and @.o@ files. \item[@-s @] Make extra dependencies that declare that files with suffix @._@ depend on interface files with suffix @._hi@, or (for @{-# SOURCE #-}@ imports) on @.hi-boot@. Multiple @-s@ flags are permitted. For example, "@-o hc -s a -s b@" will make dependencies for @.hc@ on @.hi@, @.a_hc@ on @.a_hi@, and @.b_hc@ on @.b_hi@. (Useful in conjunction with NoFib "ways".) \item[@--exclude-module=@] Regard @@ as "stable"; i.e., exclude it from having dependencies on it. \item[@-x@] same as @--exclude-module@ \item[@--exclude-directory=@] Regard the colon-separated list of directories @@ as containing stable, don't generate any dependencies on modules therein. \item[@-Xdirs@] same as @--exclude-directory@. \item[@--include-module=@] Regard @@ as not "stable"; i.e., generate dependencies on it (if any). This option is normally used in conjunction with the @--exclude-directory@ option. \end{description} %************************************************************************ %* * \subsection[hstags]{Emacs `TAGS' for Haskell: \tr{hstags}} \index{hstags} \index{TAGS for Haskell} %* * %************************************************************************ `Tags' is a facility for indexing the definitions of programming-language things in a multi-file program, and then using that index to jump around among these definitions. Rather than scratch your head, saying ``Now where did we define `foo'?'', you just do (in Emacs) \tr{M-. foo RET}, and You're There! Some people go wild over this stuff... GHC comes with a program \tr{hstags}, which build Emacs-able TAGS files. The invocation syntax is: \begin{verbatim} hstags [GHC-options] file [files...] \end{verbatim} The best thing is just to feed it your GHC command-line flags. A good Makefile entry might be: \begin{verbatim} tags: $(RM) TAGS hstags $(GHC_FLAGS) *.lhs \end{verbatim} The only flags of its own are: \tr{-v} to be verbose; \tr{-a} to **APPEND** to the TAGS file, rather than write to it. Shortcomings: (1)~Instance declarations don't get into the TAGS file (but the definitions inside them do); as instances aren't named, this is probably just as well. (2)~Data-constructor definitions don't get in. Go for the corresponding type constructor instead. (Actually, GHC also comes with \tr{etags} [for C], and \tr{perltags} [for You Know What]. And---I cannot tell a lie---there is Denis Howe's \tr{fptags} [for Haskell, etc.] in the \tr{ghc/CONTRIB} section...) %************************************************************************ %* * \subsection[happy]{``Yacc for Haskell'': \tr{happy}} \index{happy} \index{Yacc for Haskell} \index{parser generator for Haskell} %* * %************************************************************************ Andy Gill and Simon Marlow have written a parser-generator for Haskell, called \tr{happy}.\index{happy parser generator} \tr{Happy} is to Haskell what \tr{Yacc} is to C. You can get \tr{happy} by FTP from \tr{ftp.dcs.gla.ac.uk} in \tr{pub/haskell/happy}, the file \tr{happy-0.8.tar.gz}. \tr{Happy} is at its shining best when compiled by GHC. %************************************************************************ %* * \subsection[pphs]{Pretty-printing Haskell: \tr{pphs}} \index{pphs} \index{pretty-printing Haskell code} %* * %************************************************************************ Andrew Preece has written \tr{pphs},\index{pphs}\index{pretty-printing Haskell} a utility to pretty-print Haskell code in LaTeX documents. Keywords in bolds, variables in italics---that sort of thing. It is good at lining up program clauses and equals signs, things that are very tiresome to do by hand. The code is distributed with GHC in \tr{ghc/CONTRIB/pphs}.