filepath
Ian Lynagh
igloo at earth.li
Sun Dec 9 17:23:59 EST 2007
On Sun, Dec 09, 2007 at 09:17:56PM +0000, Neil Mitchell wrote:
>
> > The first is this:
> > Prelude System.FilePath> "." </> "foo"
> > "./foo"
> > which means we get things like
> > [2 of 2] Compiling GHC.Foo ( ./GHC/Foo.hs, ./GHC/Foo.o )
> > rather than
> > [2 of 2] Compiling GHC.Foo ( GHC/Foo.hs, GHC/Foo.o )
> > Is there a reason the result shouldn't be "foo"?
>
> My best guess is that "." </> "foo" should equal "./foo". However, I'm
> not overly wedded to this behaviour, so if the general consensus is
> the other way, I'll happily implement that.
>
> > Possibly relatedly, the current directory seems to be "" rather than
> > ".". This turns up in at least a couple of areas:
> > Prelude System.FilePath> normalise "."
> > ""
>
> I would say this is a bug, and that normalise "." should be ".".
The two answers above together mean that the property
\x y -> let x' = normalise x
y' = normalise y
z = x' </> y'
in z == normalise z'
doesn't hold (for x = ".", y = "foo"), but it is one I would expect to
hold.
> > Prelude System.FilePath> splitFileName "foo"
> > ("","foo")
>
> I'd say this was expected. In a similar way, takeDirectory "foo" gives
> "", not "./".
I'd expect takeDirectory "foo" to be "." and dropFileName "foo" to be
"./" too.
> > Finally, could splitSearchPath please take an extra argument, a list of
> > FilePaths, to be appended to the result if it ends with a : or ; (as
> > appropriate)?
>
> Perhaps call it splitSearchPathIncluding?
Another name would be fine with me. I don't think "Including" is quite
right, as it implies it always includes it. I can't think of a good name
right now, though.
Thanks
Ian
More information about the Libraries
mailing list