dlist
dlist copied to clipboard
Tests have compilation warnings about partial functions with GHC 9.8
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.
Thanks! I couldn't find any documentation on -Wx-partial. How do I turn it off?
Ah, I think I just found it: -Wno-x-partial
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?
Indeed, yes.