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

Tests have compilation warnings about partial functions with GHC 9.8 #108

Closed
andreasabel opened this issue Aug 31, 2023 · 4 comments · Fixed by #120
Closed

Tests have compilation warnings about partial functions with GHC 9.8 #108

andreasabel opened this issue Aug 31, 2023 · 4 comments · Fixed by #120

Comments

@andreasabel
Copy link

andreasabel commented Aug 31, 2023

tests/DListProperties.hs:70:31: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘head’
    (imported from Data.List, 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."
   |
70 | prop_head = eqOn (not . null) List.head (head . fromList)
   |                               ^^^^^^^^^

tests/DListProperties.hs:73:31: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘tail’
    (imported from Data.List, 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."
   |
73 | prop_tail = eqOn (not . null) List.tail (tail . fromList)
   |                               ^^^^^^^^^

It seems that the use of head and tail here is intended, so maybe just switch off the warning.

@spl
Copy link
Owner

spl commented Sep 1, 2023

Thanks! I couldn't find any documentation on -Wx-partial. How do I turn it off?

@spl
Copy link
Owner

spl commented Sep 1, 2023

Ah, I think I just found it: -Wno-x-partial

@spl
Copy link
Owner

spl commented Sep 1, 2023

If I understand the proposal correctly, it seems like -Wno-x-partial is not backwards-compatible, so it would need to be done for GHC >= 9.8 in DListProperties.hs. Is that correct?

@andreasabel
Copy link
Author

Indeed, yes.

@spl spl mentioned this issue Feb 17, 2024
@spl spl closed this as completed in #120 Feb 17, 2024
spl added a commit that referenced this issue Feb 17, 2024
- Update 'tested-with' in 'dlist.cabal' to include latest releases of
  GHC: 9.4.8, 9.6.4, 9.8.1
- Update 'haskell-ci' to v0.18
- haskell-ci regenerate
- Use '-Wno-x-partial' to disable the partial function warnings for
  'List.head' and 'List.tail' in 'DListProperties.hs' for GHC >= 9.8
- Fix warning for import of 'liftA2' for GHC >= 9.6
- Fix #108
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

Successfully merging a pull request may close this issue.

2 participants