9 Dec 14:30
filepath
From: Ian Lynagh <igloo <at> earth.li>
Subject: filepath
Newsgroups: gmane.comp.lang.haskell.libraries
Date: 2007-12-09 13:34:13 GMT
Subject: filepath
Newsgroups: gmane.comp.lang.haskell.libraries
Date: 2007-12-09 13:34:13 GMT
Hi Neil,
I'm having some problems using filepath in GHC. I think some of these we
might have discussed before, but if so I've forgotten what the
conclusion was, if any, and I can't see the answers in the docs.
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"?
Possibly relatedly, the current directory seems to be "" rather than
".". This turns up in at least a couple of areas:
Prelude System.FilePath> normalise "."
""
Prelude System.FilePath> splitFileName "foo"
("","foo")
I expected "." and "./" respectively, rather than the ""s. This causes
problems when giving arguments to library functions or programs, which
generally want "." or "./" rather than "", and if you are displaying a
directory to the user then you again probably don't want to print "".
As an example, I had a problem where GHC was running "gcc -I foo" rather
than "gcc -I. foo".
This looks like a straightforward bug to me:
(Continue reading)
I tend to use FilePath as just a newtype, i.e. I hardly use any other
functions from the library, but use it in type signatures to make it
clear what this particular string is for.
I won't quite say the current library encourages this, but it clearly
doesn't discourage it either...
-k


RSS Feed