cookie icon indicating copy to clipboard operation
cookie copied to clipboard

`x-partial` warnings with GHC 9.8

Open andreasabel opened this issue 2 years ago • 0 comments

The blessings of the new x-partial warning are now bestowed unto you:

Web/Cookie.hs:260:21: 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."
    |
260 |     (name, value) = head pairs
    |                     ^^^^

Web/Cookie.hs:261:44: 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."
    |
261 |     flags = map (first (S8.map toLower)) $ tail pairs
    |                                            ^^^^

This is a false alarm: https://github.com/snoyberg/cookie/blob/d95ea0b5cb593f324da2730c03033ffbdabba0c7/Web/Cookie.hs#L259-L261 It can be silenced by using a non-empty list type for pairs.

andreasabel avatar Sep 30 '23 10:09 andreasabel