using haskell as a shell language

D. Tweed
Tue, 6 Nov 2001 04:32:05 +0000 (GMT)

[Suggest moving any followup to haskell-cafe to avoid boring people]

On Mon, 5 Nov 2001, Juan Carlos Arevalo-Baeza wrote:

> On Tue, 6 Nov 2001 03:42:51 +0000 (GMT), D. Tweed wrote:
> >The name that
> >gets passed to the interpreter is `the top-level name of the script', so
> >if /home/tweed/bin/myscript.hs is actually a symlink to
> >/home/tweed/src/haskell/myscript.hs and I invoke it from /home/tweed/odd/
> >with ../bin/myscript.hs, what gets passed is "../bin/myscript.hs" (at
> >least under bash on linux). So whilst the interpreter could in principle
> >get to thinking it should look in /home/tweed/bin/ for imports by applying
> >"../bin/myscript.hs" to $cwd, AFAICS there's no way it can get hold of the
> >directory /home/tweed/src/haskell. When I figured this out I just decided
> >that the method that would lead to least banging of my head against wall
> >was just to absolute path any imports of non standard distribution code.
>    Well... I still disagree. From my point of view, it could be argued the order in which directories are searched for modules, but I don't think there's any need to exclude any directories. The interpreter should search not just the current directory, but also the directory of the file where the source was found. At least. I'd even add subdirectories "./modules/" (or "./haskell.modules/" or something like that) of both of them, just for added value :)
>    IMHO, there's no reason not to search a reasonable place for a needed piece of information. It's like Koenig lookups in C++. It just makes sense to look there, just in case.

I entirely agree it would be great if this could be done. However it seems
that runhugs at least _doesn't_ do it, and I suspect that may be because
it technically can't. I never use unix hardlinks myself (only symlinks),
but IIRC if you've got two or more hardlinks to a file there's no way to
find out from the filesystem what the directories of the other links to
the file are, so if you invoke via a hardlink then it's really difficult
to do automatic imports correctly. (I may be wrong about this.)

Incidentally, I do have a setup with
symlinks as described above; it's not just hypothetical.

>    Anyway... This is not my war. Just my opinion. O:-)

Oh, you make very good points, I just suspect that it `can't be done'. I'd
love to be proved wrong :-)

___cheers,_dave________________________________________________________ |tweed's law:  however many computers
email:      |   you have, half your time is spent
work tel: (0117) 954-5250       |   waiting for compilations to finish.