System.FilePath propsal (Was: Cabal feedback notes)

Andrew Pimlott andrew at pimlott.net
Fri Oct 29 18:10:27 EDT 2004


On Thu, Oct 28, 2004 at 01:43:19AM +0100, Glynn Clements wrote:
> Andrew Pimlott wrote:
> 
> > > splitFileName "." == (".", ".")
> > 
> > This again runs contrary to my intuition:  I expect to get back the
> > parent, and the name of the file relative to the parent.
> 
> I don't see what other result is possible in this case.

Well, that's what I meant to imply by "consistent with the type".  If
the type were FilePath -> Maybe (String, String) you could return
Nothing.  Or FilePath -> (Maybe String, Maybe String).  To me, that's
better than doing something odd, and makes the user aware of the special
cases.

> > All these
> > weird cases make the library hard to use without reading the code, going
> > by trial and error, or reading the documentation (assuming it is
> > scrupulously complete) _very_ carefully.  (Which, as I complained in the
> > old message I cited, also the case with every other path API I've used.)
> 
> It will probably be the case with every path API which you will ever
> use. There are many difficult problems here.

Well, it's messy, but I don't believe it's that hard.  Of course, you'll
never be correct outside the IO monad, but if you enumerate your
assumptions about what a path means outside of IO, I think you can come
up with a fairly coherent set of operations.

Andrew


More information about the Libraries mailing list