Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x-partial warnings with GHC 9.8 #81

Open
andreasabel opened this issue Sep 30, 2023 · 2 comments
Open

x-partial warnings with GHC 9.8 #81

andreasabel opened this issue Sep 30, 2023 · 2 comments

Comments

@andreasabel
Copy link
Member

The blessings of the new x-partial warning will be bestowed unto you by GHC 9.8:

Network/URI.hs:1131:12: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘head’
    (imported from Prelude, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
     |
1131 |         if head (uriPath ref) == '/' then
     |            ^^^^

Network/URI.hs:1437:16: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘tail’
    (imported from Prelude, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
     |
1437 | query = orNull tail . uriQuery
     |                ^^^^

Network/URI.hs:1441:19: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘tail’
    (imported from Prelude, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
     |
1441 | fragment = orNull tail . uriFragment
     |                   ^^^^

These are all false alarms:

network-uri/Network/URI.hs

Lines 1148 to 1149 in 4012e57

| isDefined ( uriPath ref ) =
if head (uriPath ref) == '/' then

network-uri/Network/URI.hs

Lines 1453 to 1463 in 4012e57

{-# DEPRECATED query "use uriQuery, and note changed functionality" #-}
query :: URI -> String
query = orNull tail . uriQuery
{-# DEPRECATED fragment "use uriFragment, and note changed functionality" #-}
fragment :: URI -> String
fragment = orNull tail . uriFragment
orNull :: ([a]->[a]) -> [a] -> [a]
orNull _ [] = []
orNull f as = f as

@ezrakilty
Copy link
Contributor

Thanks for the heads up. Looks like it's not released yet, so I guess I can't add it to the CI test automation. I'll try to get ahead of it nonetheless.

@andreasabel
Copy link
Member Author

https://github.com/haskell-CI/haskell-ci supports GHC 9.8 prereleases under the version 9.8.1.
My fork at https://github.com/andreasabel/haskell-ci does so under the version 9.8.0, so you could add GHC == 9.8.0 to the tested-with of the cabal file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants