haskell / filepath

Haskell FilePath core library
BSD 3-Clause "New" or "Revised" License
66 stars 33 forks source link

Improve deprecation warnings wrt #209 #211

Closed hasufell closed 7 months ago

hasufell commented 7 months ago

@tbidne can you test this?

Something else I noticed: building filepath itself throws many deprecation warnings. Can we ignore all those package internal deprecation warnings somehow without causing a lot of work?

tbidne commented 7 months ago

@tbidne can you test this?

It works on my test repo: No errors for using EncodingException here. Given this PR is for only the single module System.OsPath.Encoding.Internal.hs, I presume the other deprecated modules are intended to deprecate everything.

Something else I noticed: building filepath itself throws many deprecation warnings. Can we ignore all those package internal deprecation warnings somehow without causing a lot of work?

Well, you can throw -Wno-deprecations in the affected modules for as long as you have to use the deprecated symbols. Otherwise you can use @Bodigrim's trick with the hidden modules + deprecated re-exports. But this is a decent amount of work, especially with the tricky cpp.

Bodigrim commented 7 months ago

Better than status quo, but I'd go for the trick https://github.com/haskell/filepath/issues/209#issuecomment-1832809252: move the content of System.OsPath.Encoding.Internal to other-module System.OsPath.Encoding.Hidden, without deprecations. Then System.OsPath.Encoding.Internal reexports System.OsPath.Encoding.Hidden and adds a module-wide deprecation atop, and other modules of filepath rely on System.OsPath.Encoding.Hidden directly. This way you don't have to disable -Wno-deprecations everywhere, and it works with all GHC versions.

tbidne commented 7 months ago

Better than status quo, but I'd go for the trick #209 (comment): move the content of System.OsPath.Encoding.Internal to other-module System.OsPath.Encoding.Hidden, without deprecations. Then System.OsPath.Encoding.Internal reexports System.OsPath.Encoding.Hidden and adds a module-wide deprecation atop, and other modules of filepath rely on System.OsPath.Encoding.Hidden directly. This way you don't have to disable -Wno-deprecations everywhere, and it works with all GHC versions.

Here's what that looks like (I split the commits on my branch to make the diff easier):

  1. The first commit simply renames the deprecated modules X.hs -> X.Hidden.hs.

  2. The second commit copies the API from X.Hidden.hs to deprecated X.hs.

hasufell commented 7 months ago

@tbidne can you open a PR?

tbidne commented 7 months ago

https://github.com/haskell/filepath/pull/213

hasufell commented 7 months ago

superseded by https://github.com/haskell/filepath/pull/213