ghc6.8: hiding uninstalled package?

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! /M

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.

On 1/17/08, Albert Y. C. Lai
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

Magnus Therning wrote:
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?
The 'ghc-pkg list dataenc | grep dataenc' cannot be avoided AFAIK. Using some make-fu you can avoid the conditional, though, thus making it a bit more generic: PACKAGES_TO_HIDE := bla mtl blub base EXISTING_PACKAGES_TO_HIDE :=\ $(foreach p,$(PACKAGES_TO_HIDE), $(shell ghc-pkg list $p | grep $p)) GHC_HIDE_PACKAGE_OPTS = $(EXISTING_PACKAGES_TO_HIDE:%=-hide-package %) GHCOPTS = -fhpc -isrc $(GHC_HIDE_PACKAGE_OPTS) Cheers Ben

On Jan 22, 2008, at 14:57 , Ben Franksen wrote:
The 'ghc-pkg list dataenc | grep dataenc' cannot be avoided AFAIK. Using some make-fu you can avoid the conditional, though, thus making it a bit more generic:
You can also use $(findstring) instead of piping to grep. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH
participants (4)
-
Albert Y. C. Lai
-
Ben Franksen
-
Brandon S. Allbery KF8NH
-
Magnus Therning