Skip to content

Commit f615f24

Browse files
committed
Fixed warnings in Data/Vector/Fusion/Bundle/Monadic.hs
- Removed unused imports - Data.Vector.Fusion.Stream.Monadic (SPEC(..)) - Renamed variables to avoid shadowing - Added a type to the intermediate value in enumFromTo_double - TODO: the type was defaulting to Integer; that seems questionable
1 parent ffc1268 commit f615f24

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

Data/Vector/Fusion/Bundle/Monadic.hs

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ import Data.Vector.Generic.Base
8080
import qualified Data.Vector.Generic.Mutable.Base as M
8181
import Data.Vector.Fusion.Bundle.Size
8282
import Data.Vector.Fusion.Util ( Box(..), delay_inline )
83-
import Data.Vector.Fusion.Stream.Monadic ( Stream(..), Step(..), SPEC(..) )
83+
import Data.Vector.Fusion.Stream.Monadic ( Stream(..), Step(..) )
8484
import qualified Data.Vector.Fusion.Stream.Monadic as S
8585
import Control.Monad.Primitive
8686

@@ -118,7 +118,7 @@ data Bundle m v a = Bundle { sElems :: Stream m a
118118

119119
fromStream :: Monad m => Stream m a -> Size -> Bundle m v a
120120
{-# INLINE fromStream #-}
121-
fromStream (Stream step s) sz = Bundle (Stream step s) (Stream step' s) Nothing sz
121+
fromStream (Stream step t) sz = Bundle (Stream step t) (Stream step' t) Nothing sz
122122
where
123123
step' s = do r <- step s
124124
return $ fmap (\x -> Chunk 1 (\v -> M.basicUnsafeWrite v 0 x)) r
@@ -291,7 +291,7 @@ mapM_ :: Monad m => (a -> m b) -> Bundle m v a -> m ()
291291
mapM_ m = S.mapM_ m . sElems
292292

293293
-- | Transform a 'Bundle' to use a different monad
294-
trans :: (Monad m, Monad m') => (forall a. m a -> m' a)
294+
trans :: (Monad m, Monad m') => (forall z. m z -> m' z)
295295
-> Bundle m v a -> Bundle m' v a
296296
{-# INLINE_FUSED trans #-}
297297
trans f Bundle{sElems = s, sChunks = cs, sVector = v, sSize = n}
@@ -754,7 +754,7 @@ enumFromTo_small x y = x `seq` y `seq` fromStream (Stream step x) (Exact n)
754754
n = delay_inline max (fromIntegral y - fromIntegral x + 1) 0
755755

756756
{-# INLINE_INNER step #-}
757-
step x | x <= y = return $ Yield x (x+1)
757+
step z | z <= y = return $ Yield z (z+1)
758758
| otherwise = return $ Done
759759

760760
{-# RULES
@@ -803,31 +803,31 @@ enumFromTo_int x y = x `seq` y `seq` fromStream (Stream step x) (Exact (len x y)
803803
where
804804
{-# INLINE [0] len #-}
805805
len :: Int -> Int -> Int
806-
len x y | x > y = 0
806+
len u v | u > v = 0
807807
| otherwise = BOUNDS_CHECK(check) "enumFromTo" "vector too large"
808808
(n > 0)
809809
$ n
810810
where
811-
n = y-x+1
811+
n = v-u+1
812812

813813
{-# INLINE_INNER step #-}
814-
step x | x <= y = return $ Yield x (x+1)
814+
step z | z <= y = return $ Yield z (z+1)
815815
| otherwise = return $ Done
816816

817817
enumFromTo_intlike :: (Integral a, Monad m) => a -> a -> Bundle m v a
818818
{-# INLINE_FUSED enumFromTo_intlike #-}
819819
enumFromTo_intlike x y = x `seq` y `seq` fromStream (Stream step x) (Exact (len x y))
820820
where
821821
{-# INLINE [0] len #-}
822-
len x y | x > y = 0
822+
len u v | u > v = 0
823823
| otherwise = BOUNDS_CHECK(check) "enumFromTo" "vector too large"
824824
(n > 0)
825825
$ fromIntegral n
826826
where
827-
n = y-x+1
827+
n = v-u+1
828828

829829
{-# INLINE_INNER step #-}
830-
step x | x <= y = return $ Yield x (x+1)
830+
step z | z <= y = return $ Yield z (z+1)
831831
| otherwise = return $ Done
832832

833833
{-# RULES
@@ -854,15 +854,15 @@ enumFromTo_big_word :: (Integral a, Monad m) => a -> a -> Bundle m v a
854854
enumFromTo_big_word x y = x `seq` y `seq` fromStream (Stream step x) (Exact (len x y))
855855
where
856856
{-# INLINE [0] len #-}
857-
len x y | x > y = 0
857+
len u v | u > v = 0
858858
| otherwise = BOUNDS_CHECK(check) "enumFromTo" "vector too large"
859859
(n < fromIntegral (maxBound :: Int))
860860
$ fromIntegral (n+1)
861861
where
862-
n = y-x
862+
n = v-u
863863

864864
{-# INLINE_INNER step #-}
865-
step x | x <= y = return $ Yield x (x+1)
865+
step z | z <= y = return $ Yield z (z+1)
866866
| otherwise = return $ Done
867867

868868
{-# RULES
@@ -894,15 +894,15 @@ enumFromTo_big_int :: (Integral a, Monad m) => a -> a -> Bundle m v a
894894
enumFromTo_big_int x y = x `seq` y `seq` fromStream (Stream step x) (Exact (len x y))
895895
where
896896
{-# INLINE [0] len #-}
897-
len x y | x > y = 0
897+
len u v | u > v = 0
898898
| otherwise = BOUNDS_CHECK(check) "enumFromTo" "vector too large"
899899
(n > 0 && n <= fromIntegral (maxBound :: Int))
900900
$ fromIntegral n
901901
where
902-
n = y-x+1
902+
n = v-u+1
903903

904904
{-# INLINE_INNER step #-}
905-
step x | x <= y = return $ Yield x (x+1)
905+
step z | z <= y = return $ Yield z (z+1)
906906
| otherwise = return $ Done
907907

908908
#if WORD_SIZE_IN_BITS > 32
@@ -926,7 +926,7 @@ enumFromTo_char x y = x `seq` y `seq` fromStream (Stream step xn) (Exact n)
926926
n = delay_inline max 0 (yn - xn + 1)
927927

928928
{-# INLINE_INNER step #-}
929-
step xn | xn <= yn = return $ Yield (unsafeChr xn) (xn+1)
929+
step zn | zn <= yn = return $ Yield (unsafeChr zn) (zn+1)
930930
| otherwise = return $ Done
931931

932932
{-# RULES
@@ -950,10 +950,11 @@ enumFromTo_double n m = n `seq` m `seq` fromStream (Stream step n) (Max (len n m
950950
{-# INLINE [0] len #-}
951951
len x y | x > y = 0
952952
| otherwise = BOUNDS_CHECK(check) "enumFromTo" "vector too large"
953-
(n > 0)
954-
$ fromIntegral n
953+
(l > 0)
954+
$ fromIntegral l
955955
where
956-
n = truncate (y-x)+2
956+
l :: Integer
957+
l = truncate (y-x)+2
957958

958959
{-# INLINE_INNER step #-}
959960
step x | x <= lim = return $ Yield x (x+1)
@@ -1025,12 +1026,12 @@ fromVector v = v `seq` n `seq` Bundle (Stream step 0)
10251026

10261027
fromVectors :: forall m v a. (Monad m, Vector v a) => [v a] -> Bundle m v a
10271028
{-# INLINE_FUSED fromVectors #-}
1028-
fromVectors vs = Bundle (Stream pstep (Left vs))
1029-
(Stream vstep vs)
1029+
fromVectors us = Bundle (Stream pstep (Left us))
1030+
(Stream vstep us)
10301031
Nothing
10311032
(Exact n)
10321033
where
1033-
n = List.foldl' (\k v -> k + basicLength v) 0 vs
1034+
n = List.foldl' (\k v -> k + basicLength v) 0 us
10341035

10351036
pstep (Left []) = return Done
10361037
pstep (Left (v:vs)) = basicLength v `seq` return (Skip (Right (v,0,vs)))
@@ -1051,9 +1052,9 @@ fromVectors vs = Bundle (Stream pstep (Left vs))
10511052

10521053
concatVectors :: (Monad m, Vector v a) => Bundle m u (v a) -> Bundle m v a
10531054
{-# INLINE_FUSED concatVectors #-}
1054-
concatVectors Bundle{sElems = Stream step s}
1055-
= Bundle (Stream pstep (Left s))
1056-
(Stream vstep s)
1055+
concatVectors Bundle{sElems = Stream step t}
1056+
= Bundle (Stream pstep (Left t))
1057+
(Stream vstep t)
10571058
Nothing
10581059
Unknown
10591060
where

0 commit comments

Comments
 (0)