filepath

Simon Marlow simonmarhaskell at gmail.com
Tue Jan 22 09:38:59 EST 2008


Neil Mitchell wrote:
> Hi Simon
> 
>> I've just come across this again.  It's quite inconvenient that
>>
>>    takeDirectory "foo" == ""
>>
>> because it means that you can't say
>>
>>    doesDirectoryExist (takeDirectory f)
> 
> Yes, I came across this the other day. And am leaning towards agreeing with you.
> 
> I think its reasonable if splitFileName keeps the same behaviour, and
> dropFileName as well, but takeDirectory follows the new behaviour. So:
> 
> takeDirectory "foo" = "."
> takeDirectory "foo/bar" = "foo"
> 
> dropFileName "foo" = ""
> dropFilename "foo/bar" = "foo/"
> 
> Does that sound like a plan that suits everyone?

That seems strange, actually.  I would expect, perhaps naively, that

   takeDirectory == fst . splitFileName
   dropFileName  == takeDirectory

is there a good reason for these not to be true?

Cheers,
	Simon



More information about the Libraries mailing list