[web-devel] FilePath in WAI

Greg Weber greg at gregweber.info
Mon Jun 25 15:53:50 CEST 2012


> FYI, in case it wasn't clear, the system-filepath package provides such an
> abstract FilePath type, which I imagine is why some people prefer to use it
> even though it means adding some extra conversions when using the System.IO
> API (conversions which are fragile because we keep changing the meaning of
> the String version of FilePath, sigh).

Users of system-filepath should use system-fileio and have fewer needs
for System.IO, although system-fileio uses System.IO APIs.
Internally, system-filepath has conversion rules that can vary from
one ghc version to the next:
http://hackage.haskell.org/packages/archive/system-filepath/0.4.6/doc/html/src/Filesystem-Path-Rules.html

>
> system-filepath looks slightly odd to be because I would have expected the
> representation internally to be platform-specific (e.g. either ByteString or
> Text for Unix or Windows respectively), but it just uses String.

I am kind of suprised to see an internal representation using strings
also. I imagine that is because paths are usually used with
system-fileio which needs strings for the existing Haskell APIs.
system-fileio calls encodeString, which is OS specific, and that the
internal code base is easier to maintain with 1 type. The
encode/decode functions do return a platform specific type.

Greg Weber



More information about the web-devel mailing list