[Haskell-cafe] How to determine if a FilePath is a directory name
or regular file?
Ketil Malde
ketil at malde.org
Mon Jun 22 08:59:34 EDT 2009
Deniz Dogan <deniz.a.m.dogan at gmail.com> writes:
>> One explanation is that isBlah asks "is this thing a blah", but we're
>> not asking that because there is an indirection via the filepath. We're
>> asking "does this filepath refer to a directory" not "is this filename a
>> directory".
> I think see what you mean, but I find the argument more of an excuse
> to the poor naming than a solid argument for it. Following the
> convention and intuition that most users have should be more important
> than making the (sometimes unnecessary) distinction between a
> directory and the path to it.
It is more important to be consistent and logical than to follow
conventions and intuitions.
And at any rate, convention is that 'isFoo' is a pure function with the
type 'FooType -> Bool', clearly different from 'doesDirectoryExist', which
returns an IO action.
So IMO 'isDirectory "/foo/bar/"' should always return false, since it is
a string, not a directory.
-k
--
If I haven't seen further, it is by standing in the footprints of giants
More information about the Haskell-Cafe
mailing list