Skip to content

Poor test for empty list

If you say

g:: Eq a => [a] -> Bool
g xs = xs /= []

you get bad code:

g = \ (@a_aIv) ($dEq_aIw :: Eq a_aIv) (x_aI3 :: [a_aIv]) ->
      case GHC.Classes.$fEqList_$c==
             @a_aIv $dEq_aIw x_aI3 (GHC.Types.[] @a_aIv)
      of {
        False -> GHC.Types.True;
        True -> GHC.Types.False
      }

This is a bit silly -- Data.List.null will do the job. Perhaps that is a silly example, but xs == "" is not so unusual.

We should do better.

Edited by sheaf
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information