Lysxia / generic-data

Generic data types in Haskell, utilities for GHC.Generics
https://hackage.haskell.org/package/generic-data
MIT License
44 stars 9 forks source link

Use EmptyCase to define absurd1 #29

Closed RyanGlScott closed 4 years ago

RyanGlScott commented 4 years ago

Currently, absurd1 is defined like this:

absurd1 :: V1 x -> a
absurd1 !_ = error "impossible"

The right-hand side of this function (error "impossible") can never be reached. This is harmless now, but on GHC 8.10.1 this will actually give a warning:

[10 of 17] Compiling Generic.Data.Internal.Utils ( src/Generic/Data/Internal/Utils.hs, interpreted )

src/Generic/Data/Internal/Utils.hs:43:1: warning: [-Woverlapping-patterns]
    Pattern match has inaccessible right hand side
    In an equation for ‘absurd1’: absurd1 !_ = ...
   |
43 | absurd1 !_ = error "impossible"
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Thankfully, there is a backwards-compatible way to avoid the warning: just define absurd1 with EmptyCase instead. This patch does just that.

Lysxia commented 4 years ago

Thanks :)