Haddock version during build
Claus Reinke
claus.reinke at talk21.com
Wed Jun 18 05:31:46 EDT 2008
>> I was more hoping for a way to ask GHCi for *its libpath*, so that I can
>> stuff that into a GHC API session *running in that GHCi*,
>> and similarly for a GHC-compiled GHC API session.
>
> I don't get it - why not just do 'ghc --print-libdir'? It sounds like GHCi
> is a red herring here. You have to know the libdir regardless of whether
> you're using the GHC API from within GHCi or in a compiled program.
because the 'ghc' first in $PATH might not be the 'ghc' in use. GHCi
is just a good way to illustrate the issue:
$ /cygdrive/c/ghc/ghc-6.9.20080217/bin/ghcii.sh
GHCi, version 6.9.20080217: http://www.haskell.org/ghc/ :? for help
Loading package base ... linking ... done.
Prelude> :!ghc --print-libdir
c:/ghc/ghc-6.6.1
Prelude>
It is yet another incarnation of the "how does ghc find its other parts"
issue (considering multiple OSs, multiple ghcs per platform, mix of
installed/uninstalled ghcs):
1 someone gives you $GHC with the path to a ghc: how do you
find the matching ghc-pkg?
GHC_PKG="${GHC}-pkg" has a chance of working, well,
modulo ".exe", and modulo 'ghc' sometimes being a script
to arrange for local-platform-specific settings..
perhaps "find `dirname $GHC` -name 'ghc-pkg*'" instead?
life would be easier if 'ghc-pkg' was 'ghc --manage-packages',
just as 'ghci' is 'ghc --interactive' - then there'd be a single entry
point to all of ghc/ghci/ghc-pkg.
2 someone dumps you into a GHCi session: how do you find the
matching ghc-pkg?
perhaps 'System.Environment.getProgname' and back to (1)?
no - see haddocks for 'System.Environment.getProgname'.
perhaps ':!ghc-pkg'?
wrong again, if that finds a program, that might be the 'ghc-pkg'
for a different ghc installation..
3 you write code to the GHC API: how do you write calls to
'newSession' without hardcoding the libpath, so that the code
works with whatever ghc compiles it?
perhaps:
ghcDir = "ghc --print-libdir" |> (fmap dropLineEnds . hGetContents)
as I have used, naively, to avoid fixed paths?
wrong again, see above.
4 someone gives you a $GHC: how do you find the matching
html docs and manpage?
'haskell_doc.vim' in my haskellmode plugins for Vim does a
lot of guesswork to try and find the docs, and still has to have
a manual override option for when it fails to guess correctly.
Life for 2/3/4 would be easier if there was a GHC.Paths module
to import, with the paths relevant for the host ghc. Having that
module in a package ghc-paths, with fields describing the paths,
would be a useful bonus for tools/scripting.
Any clearer?-)
Claus
PS. If this isn't clearer, perhaps someone else could jump
in and try to explain it better? Unless, of course, I'm the
only one experiencing these issues?-)
More information about the Cvs-libraries
mailing list