From 4f478762c8e695adbce1b73d5aa5701621b06d29 Mon Sep 17 00:00:00 2001 From: Andreas Klebinger Date: Wed, 11 Jan 2023 14:27:30 +0100 Subject: Allow specialization of elem, notElem and lookup --- libraries/base/GHC/List.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/base/GHC/List.hs b/libraries/base/GHC/List.hs index 4427d1af1b..55caa95669 100644 --- a/libraries/base/GHC/List.hs +++ b/libraries/base/GHC/List.hs @@ -1270,6 +1270,7 @@ elem x = any (== x) elem _ [] = False elem x (y:ys) = x==y || elem x ys {-# NOINLINE [1] elem #-} +{-# INLINABLE elem #-} {-# RULES "elem/build" forall x (g :: forall b . (a -> b -> b) -> b -> b) . elem x (build g) = g (\ y r -> (x == y) || r) False @@ -1295,6 +1296,7 @@ notElem x = all (/= x) notElem _ [] = True notElem x (y:ys)= x /= y && notElem x ys {-# NOINLINE [1] notElem #-} +{-# INLINABLE notElem #-} {-# RULES "notElem/build" forall x (g :: forall b . (a -> b -> b) -> b -> b) . notElem x (build g) = g (\ y r -> (x /= y) && r) True @@ -1312,6 +1314,7 @@ notElem x (y:ys)= x /= y && notElem x ys -- >>> lookup 2 [(1, "first"), (2, "second"), (3, "third")] -- Just "second" -- +{-# INLINABLE lookup #-} lookup :: (Eq a) => a -> [(a,b)] -> Maybe b lookup _key [] = Nothing lookup key ((x,y):xys) -- cgit v1.2.1