haskell / network-uri

URI manipulation facilities
Other
24 stars 33 forks source link

Fix compilation warnings #77

Closed andreasabel closed 1 year ago

andreasabel commented 1 year ago

Dunno, somehow cabal builds network-uri very often on my system, and I always see the same warnings (see below). Could these warnings be fixed?

Building library for network-uri-2.6.4.1..
[1 of 3] Compiling Network.URI      ( Network/URI.hs, dist/build/Network/URI.o, dist/build/Network/URI.dyn_o )

Network/URI.hs:10:14: warning: [-Wtrustworthy-safe]
    ‘Network.URI’ is marked as Trustworthy but has been inferred as safe!
   |
10 | {-# LANGUAGE Trustworthy #-}
   |              ^^^^^^^^^^^

Network/URI.hs:1418:23: warning: [-Woperator-whitespace-ext-conflict]
    The prefix use of a ‘$’ would denote an untyped splice
      were the TemplateHaskell extension enabled.
    Suggested fix: Add whitespace after the ‘$’.
     |
1418 | authority = dropss . ($"") . uriAuthToString id . uriAuthority
     |                       ^
ezrakilty commented 1 year ago

At one time, there was a difficulty eliminating the warnings across all the ghc versions. I bet that's changed and this bears another look. I'll see what I can do!

andreasabel commented 1 year ago

authority = dropss . ($"") . uriAuthToString id . uriAuthority

This is easily fixed by adding a whitespace after $.

Network/URI.hs:10:14: warning: [-Wtrustworthy-safe] ‘Network.URI’ is marked as Trustworthy but has been inferred as safe!

Maybe just disable this warning, but it is unclear when it was introduced. The "since" info is missing here: https://downloads.haskell.org/ghc/9.2.4/docs/html/users_guide/exts/safe_haskell.html#ghc-flag--Wtrustworthy-safe

(Upstream issue: https://gitlab.haskell.org/ghc/ghc/-/issues/18087#note_466151)

Or, maybe it is possible to declare this module as Safe. However, there are caveats around SafeHaskell, see e.g.:

ezrakilty commented 1 year ago

I fixed the warning for the $.

@andreasabel I'm not actually seeing the trustworthy-safe warning in my CI build: https://github.com/haskell/network-uri/actions/runs/3646303898/jobs/6157239686

The module is actually marked as Safe under these conditions: #if MIN_VERSION_template_haskell(2,12,0) && MIN_VERSION_parsec(3,1,13) Are you building in a way that fails one of those conditions?

andreasabel commented 1 year ago

This is the full reproducer, using the latest (non-deprecated) release on Hackage:

$ cabal get network-uri
Unpacking to network-uri-2.6.4.1/

$ cd network-uri-2.6.4.1/

$ cabal build -w ghc-9.4.3

Resolving dependencies...
Build profile: -w ghc-9.4.3 -O1
In order, the following will be built (use -v for more details):
 - network-uri-2.6.4.1 (lib) (first run)
Configuring library for network-uri-2.6.4.1..
Preprocessing library for network-uri-2.6.4.1..
Building library for network-uri-2.6.4.1..
[1 of 3] Compiling Network.URI      ( ... )

Network/URI.hs:10:14: warning: [-Wtrustworthy-safe]
    ‘Network.URI’ is marked as Trustworthy but has been inferred as safe!
   |
10 | {-# LANGUAGE Trustworthy #-}
   |              ^^^^^^^^^^^

Network/URI.hs:1418:23: warning: [-Woperator-whitespace-ext-conflict]
    The prefix use of a ‘$’ would denote an untyped splice
      were the TemplateHaskell extension enabled.
    Suggested fix: Add whitespace after the ‘$’.
     |
1418 | authority = dropss . ($"") . uriAuthToString id . uriAuthority
     |                       ^
[2 of 3] Compiling Network.URI.Lens ( ... )
[3 of 3] Compiling Network.URI.Static ( ... )

So, just vanilla build conditions.

Bodigrim commented 1 year ago

The module is actually marked as Safe under these conditions: #if MIN_VERSION_template_haskell(2,12,0) && MIN_VERSION_parsec(3,1,13) Are you building in a way that fails one of those conditions?

The released network-uri-2.6.4.1 says MIN_VERSION_parsec(3,13,0) instead of MIN_VERSION_parsec(3,1,13).

ezrakilty commented 1 year ago

The released network-uri-2.6.4.1 says MIN_VERSION_parsec(3,13,0) instead of MIN_VERSION_parsec(3,1,13).

I see, thank you! Well, that's good motivation for a release, then. I'll get to it today or this week.

ezrakilty commented 1 year ago

Here I have a candidate for 2.6.4.2: https://hackage.haskell.org/package/network-uri-2.6.4.2/candidate

I will publish later today if I don't see any reason not to.

andreasabel commented 1 year ago

https://github.com/haskell/network-uri/blob/4a95974352f70e849e7e618c2562b03da6feb4b3/CHANGELOG.md?plain=1#L2 Maybe

* Fix warnings `-Wtrustworthy-safe` and `-Woperator-whitespace-ext-conflict` on GHC 9.4. 
ezrakilty commented 1 year ago

OK, I've published network-uri 2.6.4.2, fixing these warnings. https://hackage.haskell.org/package/network-uri-2.6.4.2