[Haskell] System.FilePath survey

Krasimir Angelov kr.angelov at gmail.com
Mon Feb 6 09:47:51 EST 2006


2006/2/6, David Roundy <droundy at abridgegame.org>:
> Actually couldn't they all be made polymorphic?
>
> getDirectoryContents :: FilePath p => IO p
>
> class FilePath p where
>  fromADT :: ADT -> p
>  toADT :: p -> ADT

Would you mean that we should have two instances:

instance FilePath String where ....
instance FilePath ADT  where ....

It will work but I think that it is unnecessary complication. I prefer
to use type classes only when they are really necessary i.e. when I
have more than 2-3 instances or when I expect to have a lot of generic
code that should work on both types. I think that if we should switch
from plain String to ADT then this should be made for a new i/o
library (the Handle(s) replacement) which will change the thing a lot
in any way. For the current library I think that the plain String is
more reasonable. If the general consensus is that ADT is the way to go
then I think some effort on a new efficient IO library be forced. It
should have:

   - FilePath ADT
   - Packed string
   - Fast I/O with unicode support

I know some pieces already exists but they need integration and polishing.

Cheers,
   Krasimir


More information about the Libraries mailing list