getProgName behaviour...

Sigbjorn Finne
Sat, 13 Oct 2001 09:07:20 -0700

"Peter Strand" <> writes:
> Why does getProgName in the System module in ghc return only the program
> and not the invoked path?
> The library report states
> "Computation getProgName returns the name of the program _as it was
> and both nhc and hbc behaves as one(?) would expect...
> This seems like a deliberate choise so I am a bit curious of the reasoning
> behind it...

One design 'principle' behind the standard Haskell libraries that deal with
IO and OS interaction was to hide OS details as much as possible
(not that surprising given that one of the main people behind it was
(and still is?) an avid Apple user..), letting the programmer write
programs that could work on multiple platforms.

So, in that light it makes sense for 'getProgName' not to give away any
details of where on a file system an executable resides (or how it was
invoked) - just the _name_ (as in 'basename' in UNIX parlance). Not
that the GHC implementation always gets this right, try it on a Win32 box...

If I remember correctly, the relevant code in GHC's implementation of System
was snaffled directly from code written by the Haskell 1.3 IO committee.

Anyway, that's the underlying reasoning behind this (as known to me).