summaryrefslogtreecommitdiff
path: root/libraries/base/GHC/List.lhs
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/base/GHC/List.lhs')
-rw-r--r--libraries/base/GHC/List.lhs7
1 files changed, 2 insertions, 5 deletions
diff --git a/libraries/base/GHC/List.lhs b/libraries/base/GHC/List.lhs
index e004ded1e8..9b6cc2eb19 100644
--- a/libraries/base/GHC/List.lhs
+++ b/libraries/base/GHC/List.lhs
@@ -83,11 +83,8 @@ last [x] = x
last (_:xs) = last xs
last [] = errorEmptyList "last"
#else
--- eliminate repeated cases
-last [] = errorEmptyList "last"
-last (x:xs) = last' x xs
- where last' y [] = y
- last' _ (y:ys) = last' y ys
+-- use foldl to allow fusion
+last = foldl (\_ x -> x) (errorEmptyList "last")
#endif
-- | Return all the elements of a list except the last one.