Commit de7d4e9d authored by pcapriotti's avatar pcapriotti

Fix inline rule shadowing warnings

parent ac50935b
......@@ -532,6 +532,7 @@ insertBy cmp x ys@(y:ys')
-- It is a special case of 'Data.List.maximumBy', which allows the
-- programmer to supply their own comparison function.
maximum :: (Ord a) => [a] -> a
{-# NOINLINE [1] maximum #-}
maximum [] = errorEmptyList "maximum"
maximum xs = foldl1 max xs
......@@ -552,6 +553,7 @@ strictMaximum xs = foldl1' max xs
-- It is a special case of 'Data.List.minimumBy', which allows the
-- programmer to supply their own comparison function.
minimum :: (Ord a) => [a] -> a
{-# NOINLINE [1] minimum #-}
minimum [] = errorEmptyList "minimum"
minimum xs = foldl1 min xs
......@@ -592,6 +594,7 @@ minimumBy cmp xs = foldl1 minBy xs
-- particular, instead of returning an 'Int', it returns any type which is
-- an instance of 'Num'. It is, however, less efficient than 'length'.
genericLength :: (Num i) => [b] -> i
{-# NOINLINE [1] genericLength #-}
genericLength [] = 0
genericLength (_:l) = 1 + genericLength l
......
......@@ -697,7 +697,7 @@ eqArray arr1@(Array l1 u1 n1 _) arr2@(Array l2 u2 n2 _) =
l1 == l2 && u1 == u2 &&
and [unsafeAt arr1 i == unsafeAt arr2 i | i <- [0 .. n1 - 1]]
{-# INLINE cmpArray #-}
{-# INLINE [1] cmpArray #-}
cmpArray :: (Ix i, Ord e) => Array i e -> Array i e -> Ordering
cmpArray arr1 arr2 = compare (assocs arr1) (assocs arr2)
......
......@@ -363,6 +363,7 @@ augment g xs = g (:) xs
-- > map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn]
-- > map f [x1, x2, ...] == [f x1, f x2, ...]
{-# NOINLINE [1] map #-}
map :: (a -> b) -> [a] -> [b]
map _ [] = []
map f (x:xs) = f x : map f xs
......@@ -409,6 +410,7 @@ mapFB c f = \x ys -> c (f x) ys
--
-- If the first list is not finite, the result is the first list.
{-# NOINLINE [1] (++) #-}
(++) :: [a] -> [a] -> [a]
(++) [] ys = ys
(++) (x:xs) ys = x : xs ++ ys
......
......@@ -394,6 +394,7 @@ eftCharFB c n x0 y = go x0
go x | x ># y = n
| otherwise = C# (chr# x) `c` go (x +# 1#)
{-# NOINLINE [1] eftChar #-}
eftChar :: Int# -> Int# -> String
eftChar x y | x ># y = []
| otherwise = C# (chr# x) : eftChar (x +# 1#) y
......@@ -408,6 +409,7 @@ efdCharFB c n x1 x2
where
!delta = x2 -# x1
{-# NOINLINE [1] efdChar #-}
efdChar :: Int# -> Int# -> String
efdChar x1 x2
| delta >=# 0# = go_up_char_list x1 delta 0x10FFFF#
......@@ -423,6 +425,7 @@ efdtCharFB c n x1 x2 lim
where
!delta = x2 -# x1
{-# NOINLINE [1] efdtChar #-}
efdtChar :: Int# -> Int# -> Int# -> String
efdtChar x1 x2 lim
| delta >=# 0# = go_up_char_list x1 delta lim
......@@ -512,6 +515,7 @@ instance Enum Int where
"eftIntList" [1] eftIntFB (:) [] = eftInt
#-}
{-# NOINLINE [1] eftInt #-}
eftInt :: Int# -> Int# -> [Int]
-- [x1..x2]
eftInt x0 y | x0 ># y = []
......@@ -547,6 +551,7 @@ efdInt x1 x2
| x2 >=# x1 = case maxInt of I# y -> efdtIntUp x1 x2 y
| otherwise = case minInt of I# y -> efdtIntDn x1 x2 y
{-# NOINLINE [1] efdtInt #-}
efdtInt :: Int# -> Int# -> Int# -> [Int]
-- [x1,x2..y]
efdtInt x1 x2 y
......@@ -670,9 +675,11 @@ instance Enum Integer where
"enumDeltaToInteger" [1] enumDeltaToIntegerFB (:) [] = enumDeltaToInteger
#-}
{-# NOINLINE [0] enumDeltaIntegerFB #-}
enumDeltaIntegerFB :: (Integer -> b -> b) -> Integer -> Integer -> b
enumDeltaIntegerFB c x d = x `seq` (x `c` enumDeltaIntegerFB c (x+d) d)
{-# NOINLINE [1] enumDeltaInteger #-}
enumDeltaInteger :: Integer -> Integer -> [Integer]
enumDeltaInteger x d = x `seq` (x : enumDeltaInteger (x+d) d)
-- strict accumulator, so
......@@ -687,6 +694,7 @@ enumDeltaToIntegerFB c n x delta lim
| delta >= 0 = up_fb c n x delta lim
| otherwise = dn_fb c n x delta lim
{-# NOINLINE [1] enumDeltaToInteger #-}
enumDeltaToInteger :: Integer -> Integer -> Integer -> [Integer]
enumDeltaToInteger x delta lim
| delta >= 0 = up_list x delta lim
......
......@@ -825,6 +825,8 @@ Now, here's Lennart's code (which works)
"fromRat/Float" fromRat = (fromRational :: Rational -> Float)
"fromRat/Double" fromRat = (fromRational :: Rational -> Double)
#-}
{-# NOINLINE [1] fromRat #-}
fromRat :: (RealFloat a) => Rational -> a
-- Deal with special cases first, delegating the real work to fromRat'
......
......@@ -58,6 +58,7 @@ infix 4 `elem`, `notElem`
head :: [a] -> a
head (x:_) = x
head [] = badHead
{-# NOINLINE [1] head #-}
badHead :: a
badHead = errorEmptyList "head"
......@@ -125,6 +126,7 @@ length l = len l 0#
--
-- > filter p xs = [ x | x <- xs, p x]
{-# NOINLINE [1] filter #-}
filter :: (a -> Bool) -> [a] -> [a]
filter _pred [] = []
filter pred (x:xs)
......@@ -226,13 +228,14 @@ scanr1 f (x:xs) = f x q : qs
--
-- > iterate f x == [x, f x, f (f x), ...]
{-# NOINLINE [1] iterate #-}
iterate :: (a -> a) -> a -> [a]
iterate f x = x : iterate f (f x)
{-# NOINLINE [0] iterateFB #-}
iterateFB :: (a -> b -> b) -> (a -> a) -> a -> b
iterateFB c f x = x `c` iterateFB c f (f x)
{-# RULES
"iterate" [~1] forall f x. iterate f x = build (\c _n -> iterateFB c f x)
"iterateFB" [1] iterateFB (:) = iterate
......@@ -497,6 +500,9 @@ and (x:xs) = x && and xs
or [] = False
or (x:xs) = x || or xs
{-# NOINLINE [1] and #-}
{-# NOINLINE [1] or #-}
{-# RULES
"and/build" forall (g::forall b.(Bool->b->b)->b->b) .
and (build g) = g (&&) True
......@@ -525,6 +531,10 @@ any p (x:xs) = p x || any p xs
all _ [] = True
all p (x:xs) = p x && all p xs
{-# NOINLINE [1] any #-}
{-# NOINLINE [1] all #-}
{-# RULES
"any/build" forall p (g::forall b.(a->b->b)->b->b) .
any p (build g) = g ((||) . p) False
......@@ -566,6 +576,8 @@ concatMap f = foldr ((++) . f) []
concat :: [[a]] -> [a]
concat = foldr (++) []
{-# NOINLINE [1] concat #-}
{-# RULES
"concat" forall xs. concat xs = build (\c n -> foldr (\x y -> foldr c y x) n xs)
-- We don't bother to turn non-fusible applications of concat back into concat
......@@ -613,6 +625,8 @@ foldr2 _k z [] _ys = z
foldr2 _k z _xs [] = z
foldr2 k z (x:xs) (y:ys) = k x y (foldr2 k z xs ys)
{-# NOINLINE [1] foldr2 #-}
foldr2_left :: (a -> b -> c -> d) -> d -> a -> ([b] -> c) -> [b] -> d
foldr2_left _k z _x _r [] = z
foldr2_left k _z x r (y:ys) = k x y (r ys)
......@@ -649,6 +663,7 @@ Zips for larger tuples are in the List module.
-- | 'zip' takes two lists and returns a list of corresponding pairs.
-- If one input list is short, excess elements of the longer list are
-- discarded.
{-# NOINLINE [1] zip #-}
zip :: [a] -> [b] -> [(a,b)]
zip (a:as) (b:bs) = (a,b) : zip as bs
zip _ _ = []
......@@ -684,6 +699,7 @@ zip3 _ _ _ = []
-- as the first argument, instead of a tupling function.
-- For example, @'zipWith' (+)@ is applied to two lists to produce the
-- list of corresponding sums.
{-# NOINLINE [1] zipWith #-}
zipWith :: (a->b->c) -> [a]->[b]->[c]
zipWith f (a:as) (b:bs) = f a b : zipWith f as bs
zipWith _ _ _ = []
......
......@@ -461,6 +461,7 @@ instance (Integral a) => Enum (Ratio a) where
\begin{code}
-- | general coercion from integral types
{-# NOINLINE [1] fromIntegral #-}
fromIntegral :: (Integral a, Num b) => a -> b
fromIntegral = fromInteger . toInteger
......@@ -476,6 +477,7 @@ fromIntegral = fromInteger . toInteger
-- | general coercion to fractional types
realToFrac :: (Real a, Fractional b) => a -> b
{-# NOINLINE [1] realToFrac #-}
realToFrac = fromRational . toRational
\end{code}
......@@ -506,7 +508,7 @@ odd = not . even
Integer -> Integer -> Integer,
Integer -> Int -> Integer,
Int -> Int -> Int #-}
{-# INLINABLE (^) #-} -- See Note [Inlining (^)]
{-# INLINABLE [1] (^) #-} -- See Note [Inlining (^)]
(^) :: (Num a, Integral b) => a -> b -> a
x0 ^ y0 | y0 < 0 = error "Negative exponent"
| y0 == 0 = 1
......@@ -522,7 +524,7 @@ x0 ^ y0 | y0 < 0 = error "Negative exponent"
-- | raise a number to an integral power
(^^) :: (Fractional a, Integral b) => a -> b -> a
{-# INLINABLE (^^) #-} -- See Note [Inlining (^)
{-# INLINABLE [1] (^^) #-} -- See Note [Inlining (^)
x ^^ n = if n >= 0 then x^n else recip (x^(negate n))
{- Note [Inlining (^)
......@@ -644,6 +646,7 @@ x ^^ n = if n >= 0 then x^n else recip (x^(negate n))
-- the result may be negative if one of the arguments is @'minBound'@ (and
-- necessarily is if the other is @0@ or @'minBound'@) for such types.
gcd :: (Integral a) => a -> a -> a
{-# NOINLINE [1] gcd #-}
gcd x y = gcd' (abs x) (abs y)
where gcd' a 0 = a
gcd' a b = gcd' b (a `rem` b)
......@@ -651,6 +654,7 @@ gcd x y = gcd' (abs x) (abs y)
-- | @'lcm' x y@ is the smallest positive integer that both @x@ and @y@ divide.
lcm :: (Integral a) => a -> a -> a
{-# SPECIALISE lcm :: Int -> Int -> Int #-}
{-# NOINLINE [1] lcm #-}
lcm _ 0 = 0
lcm 0 _ = 0
lcm x y = abs ((x `quot` (gcd x y)) * y)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment