Proposal: Add getFullProgName

Johan Tibell johan.tibell at gmail.com
Thu Jun 21 21:35:53 CEST 2012


On Thu, Jun 21, 2012 at 1:51 AM, Simon Meier <iridcode at gmail.com> wrote:
> I know this a special case and slightly off-topic. However, I'm not
> sure, if this use-case provides a good justification for
> 'getExecutablePath'. Couldn't you just pass an explicit argument with
> the path to the file to copy when executing this binary?

It's possible, but I think we can do better. First, it's kinda silly
to require the user to type:

    /some/dir/my-binary /some/dir/my-binary

Second, in the presence of symlinks it can be tricky for the user to
figure out what the right path is and, since the OS has already
resolved that issue when launching the executable, it makes sense to
use the info the OS has (to avoid having the OS and the user disagree
over where the executable lives if nothing else.)

Third, the fact that I copy the executable somewhere is something I
like to keep behind the scenes and not include in the UI.

> Your shortcut via 'getExecutablePath' somehow reminds me of an
> arbitrary IO action deep-down in some module trying to call 'main'
> again. This requires quite some impurity to achieve and entails a slew
> of composability issues. The pure construction of explicitly passing
> all arguments was always much simpler in my code.

I'm not using any unsafe I/O anywhere. I want to replace (the non-working):

    main = do
        file <- getProgName
        ...

with

    main = do
        file <- getExecutablePath
        ...

All my actions on file (i.e. copying it, executing it) lives in IO.

-- Johan



More information about the Libraries mailing list