From cc87bda6739b2f10ef097759ee5de45a97afbe66 Mon Sep 17 00:00:00 2001 From: Asad Saeeduddin Date: Sat, 26 Dec 2020 20:03:05 -0500 Subject: Use EmptyCase instead of undefined in Generics example Fixes #19124 --- libraries/base/GHC/Generics.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/base/GHC/Generics.hs b/libraries/base/GHC/Generics.hs index d4c8f73995..09d8fe1bfe 100644 --- a/libraries/base/GHC/Generics.hs +++ b/libraries/base/GHC/Generics.hs @@ -317,17 +317,17 @@ module GHC.Generics ( -- -- | -- --- The instance for 'V1' is slightly awkward (but also rarely used): +-- To deal with the 'V1' case, we use the following code (which requires the pragma @EmptyCase@): -- -- @ -- instance Encode' 'V1' where --- encode' x = undefined +-- encode' x = case x of { } -- @ -- --- There are no values of type @V1 p@ to pass (except undefined), so this is --- actually impossible. One can ask why it is useful to define an instance for --- 'V1' at all in this case? Well, an empty type can be used as an argument to --- a non-empty type, and you might still want to encode the resulting type. +-- There are no values of type @V1 p@ to pass, so it is impossible for this +-- function to be invoked. One can ask why it is useful to define an instance +-- for 'V1' at all in this case? Well, an empty type can be used as an argument +-- to a non-empty type, and you might still want to encode the resulting type. -- As a somewhat contrived example, consider @[Empty]@, which is not an empty -- type, but contains just the empty list. The 'V1' instance ensures that we -- can call the generic function on such types. -- cgit v1.2.1