getProgName behaviour...

Sigbjorn Finne sof@galconn.com
Sat, 13 Oct 2001 09:07:20 -0700


"Peter Strand" <d98peter@dtek.chalmers.se> writes:
>
> Why does getProgName in the System module in ghc return only the program
name
> and not the invoked path?
>
> The library report states
> "Computation getProgName returns the name of the program _as it was
invoked_"
>
> 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
'system'y
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).

--sigbjorn