hat, ghc

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Thu Sep 1 11:46:38 EDT 2005

Frederik Eaton <frederik at a5.repetae.net> writes:

> Is there a way to use Hat with GHC, without 'hmake'?

You could transform each module in your project individually with
hat-trans, before running ghc --make over the traced version.
Unfortunately, this means you will need to find some other way to
do the dependency analysis to ensure that modules are transformed
in the right order.  It is a known deficiency of the ghc --make
implementation that it cannot handle pre-processors nicely - this
applies equally to Happy, Alex, generic Haskell, etc.

One way would be to write a Makefile, with rules something like

    $(patsubst %.hs, Hat/%.hs, ${SRCS}) : Hat/%.hs : %.hs
		hat-trans $<
    $(patsubst %.hs, Hat/%.o, ${SRCS}) : Hat/$.o : Hat/%.hs
		ghc -c -package hat $<

and then use ghc -M to generate the dependencies somehow.

>  $ which ghc
>  /home/frederik/.toast-i386/armed/bin/ghc
>  $ hmake -hat pointtracker.hs
>  Fail: Can't find module Graphics.X11.Xlib in user directories
>          .
>    Or in installed libraries/packages at
>          /usr/lib/ghc-6.2.2/imports
>    Asked for by: pointtracker.hs
>    Fix using the -I, -P, or -package flags.

Well, since ghc-6.2.2 doesn't ship with the X11 library package
enabled, this is hardly surprising.  However, even it it were supplied,
you /might/ also need to ask for it explicitly with
    -package X11
on the command-line.

> i.e., I'm not sure how 'hmake' found /usr/lib/ghc-6.2.2, but this
> directory is not mentioned in my environment, and it was not my
> intention to use this version of ghc.

You can select which version of ghc is used by hmake, either on the
command-line, or by setting a default with hmake-config.  e.g.
    hmake -hc=/home/frederik/.toast-i386/armed/bin/ghc ...
    hmake-config list
    hmake-config add /home/frederik/.toast-i386/armed/bin/ghc
    hmake-config default /home/frederik/.toast-i386/armed/bin/ghc


More information about the Glasgow-haskell-users mailing list