On 1/17/08, Albert Y. C. Lai <trebla@vex.net> wrote:
Magnus Therning wrote:
> This might seem like a silly question, but what's the reasoning behind
> the following behaviour?
>
> % ghc-pkg list dataenc
> /usr/lib/ghc-6.8.2/package.conf:
> % ghc --make -hide-package dataenc -isrc UT.hs
> ghc-6.8.2 : unknown package: dataenc
>
> Hiding an uninstalled package doesn't seem to warrant failing compilation!

"I cannot find it, therefore I cannot hide it"? XD

The following is fairly widely accepted behaviour:

$ rm phd-thsies
rm: cannot remove `phd-thsies': No such file or directory

If a file is absent and you want it absent, is that an error?

(Now you might get into a long thread debating whether deletion is
analogous to hiding...)

If I want to hide or delete something, and the computer can't find that
something, it may be because I have a typo. If the computer remains
silent about it, I fail to hide or delete the true thing. I want to
delete phd-thesis, but I typed phd-thsies, and I appreciate the error
report. If I fail to delete phd-thesis, at worst more people read it and
be enlightened :) but if I fail to hide a package and I don't know about
it, the ensuing problems will be much more mysterious.

Fair enough.  I stumbled on this behaviour because I was writing a makefile for my unit/quickcheck tests.  I need to make sure that the correct module is used, hence I need to hide it if it's installed.  I ended up with the following in order to work around the issue:

ifeq (,$(shell ghc-pkg list dataenc | grep dataenc))
GHCOPTS = -fhpc -isrc
else
GHCOPTS = -fhpc -hide-package dataenc -isrc
endif

% : %.hs
        ghc --make $(GHCOPTS) $<

Is there a better way to do it?

/M