summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Klebinger <klebinger.andreas@gmx.at>2023-01-11 14:27:30 +0100
committerAndreas Klebinger <klebinger.andreas@gmx.at>2023-01-16 14:49:53 +0100
commit4f478762c8e695adbce1b73d5aa5701621b06d29 (patch)
treed153b3a8c789a050479ce8374433c589e27173e8
parenta8cfdfcee9eae344ae0deae438b7994bf3cd4d67 (diff)
downloadhaskell-wip/andreask/spec-pragma.tar.gz
Allow specialization of elem, notElem and lookupwip/andreask/spec-pragma
-rw-r--r--libraries/base/GHC/List.hs3
1 files changed, 3 insertions, 0 deletions
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)