Abstract FilePath Proposal
m at tweag.io
Sun Jun 28 10:03:59 UTC 2015
why does the proposal *not* include normalization?
There are four advantages that I see to making FilePath a datatype:
1. it makes it possible to implement the correct semantics for some
systems (including POSIX),
2. it allows for information hiding, which in turn helps modularity,
3. the type is distinct from any other type, hence static checks are stronger,
4. it becomes possible to quotient values over some arbitrary set of
identities that makes sense. i.e. in the case of FilePath, arguably
"foo/bar//baz" *is* "foo/bar/baz" *is* "foo//bar/baz" for all intents
and purposes, so it is not useful to distinguish these three ways of
writing down the same path (and in fact in practice distinguishing
them leads to subtle bugs). That is, the Eq instance compares
FilePath's modulo a few laws.
Do you propose to forego (4)? If so why so?
If we're going through a deprecation process, could we do so once, by
getting the notion of path equality we want right the first time?
Contrary to type indexing FilePath, it seems to me that the design
space for path identities is much smaller. Essentially, exactly the
ones here: https://hackage.haskell.org/package/filepath-18.104.22.168/docs/System-FilePath-Posix.html#v:normalise.
On 27 June 2015 at 12:12, Neil Mitchell <ndmitchell at gmail.com> wrote:
> Hi Niklas,
> The function writeFile takes a FilePath. We could fork base or tell everyone
> to use writeFile2, but in practice everyone will keep using writeFile, and
> this String for FilePath. This approach is the only thing we could figure
> that made sense.
> Henning: we do not propose normalisation on initialisation. For ASCII
> strings fromFilePath . toFilePath will be id. It might also be for unicode
> on some/all platforms. Of course, you can write your own FilePath creator
> that does normalisation on construction.
> Thanks, Neil
> On Saturday, 27 June 2015, Niklas Larsson <metaniklas at gmail.com> wrote:
>> Instead of trying to minimally patch the existing API and still breaking
>> loads of code, why not make a new API that doesn't have to compromise and
>> depreciate the old one?
>> Från: Herbert Valerio Riedel
>> Skickat: 2015-06-26 18:09
>> Till: libraries at haskell.org; ghc-devs at haskell.org
>> Ämne: Abstract FilePath Proposal
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>> Hello *,
>> We (see From: & CC: headers) propose, plain and simple, to turn the
>> currently defined type-synonym
>> type FilePath = String
>> into an abstract/opaque data type instead.
>> For details (including motivation and a suggested transition scheme)
>> please consult
>> Suggested discussion period: 4 weeks
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1
>> -----END PGP SIGNATURE-----
>> ghc-devs mailing list
>> ghc-devs at haskell.org
> ghc-devs mailing list
> ghc-devs at haskell.org
More information about the ghc-devs