on master help sign in
Drop unnecessary uses of seq
5c8ab4eBryan O'Sullivan
Data/Text.hs+4−4
@@ -55,8 +55,8 @@ import Prelude (Char,Bool,Int,Maybe,String,
55 Eq,(==),(++),error,
55 Eq,(==),(++),error,
56 Show,showsPrec,
56 Show,showsPrec,
57 Read,readsPrec,
57 Read,readsPrec,
58− (&&),(||),(+),(-),($),(<),(>),(<=),(>=),(.),(>>=),
58+ (&&),(||),(+),(-),(<),(>),(<=),(>=),(.),(>>=),
59− return,otherwise,seq,
59+ return,otherwise,
60 IO, FilePath)
60 IO, FilePath)
61
61
62import Data.Char (isSpace)
62import Data.Char (isSpace)
@@ -122,8 +122,8 @@ unpack txt = (unstream_list (stream txt))
122 where
122 where
123 unfold !s = case next s of
123 unfold !s = case next s of
124 S.Done -> []
124 S.Done -> []
125− S.Skip s' -> seq s' $ unfold s'
125+ S.Skip s' -> unfold s'
126− S.Yield x s' -> seq s' $ x : unfold s'
126+ S.Yield x s' -> x : unfold s'
127{-# INLINE [1] unpack #-}
127{-# INLINE [1] unpack #-}
128
128
129-- | Convert a character into a Text.
129-- | Convert a character into a Text.
Data/Text/Fusion.hs+22−22
@@ -469,12 +469,12 @@ last (Stream next s0 _len) = loop0_last s0
469 where
469 where
470 loop0_last !s = case next s of
470 loop0_last !s = case next s of
471 Done -> error "last: Empty list"
471 Done -> error "last: Empty list"
472− Skip s' -> seq s' $ loop0_last s'
472+ Skip s' -> loop0_last s'
473− Yield x s' -> seq s' $ loop_last x s'
473+ Yield x s' -> loop_last x s'
474 loop_last !x !s = case next s of
474 loop_last !x !s = case next s of
475 Done -> x
475 Done -> x
476− Skip s' -> seq s' $ loop_last x s'
476+ Skip s' -> loop_last x s'
477− Yield x' s' -> seq s' $ loop_last x' s'
477+ Yield x' s' -> loop_last x' s'
478{-# INLINE[0] last #-}
478{-# INLINE[0] last #-}
479
479
480-- | /O(1)/ Returns all characters after the head of a Stream Char, which must
480-- | /O(1)/ Returns all characters after the head of a Stream Char, which must
@@ -502,12 +502,12 @@ init (Stream next0 s0 len) = Stream next (Nothing :!: s0) (len-1)
502 {-# INLINE next #-}
502 {-# INLINE next #-}
503 next (Nothing :!: s) = case next0 s of
503 next (Nothing :!: s) = case next0 s of
504 Done -> errorEmptyList "init"
504 Done -> errorEmptyList "init"
505− Skip s' -> seq s' $ Skip (Nothing :!: s')
505+ Skip s' -> Skip (Nothing :!: s')
506− Yield x s' -> seq s' $ Skip (Just x :!: s')
506+ Yield x s' -> Skip (Just x :!: s')
507 next (Just x :!: s) = case next0 s of
507 next (Just x :!: s) = case next0 s of
508 Done -> Done
508 Done -> Done
509− Skip s' -> seq s' $ Skip (Just x :!: s')
509+ Skip s' -> Skip (Just x :!: s')
510− Yield x' s' -> seq s' $ Yield x (Just x' :!: s')
510+ Yield x' s' -> Yield x (Just x' :!: s')
511{-# INLINE [0] init #-}
511{-# INLINE [0] init #-}
512
512
513-- | /O(1)/ Tests whether a Stream Char is empty or not.
513-- | /O(1)/ Tests whether a Stream Char is empty or not.
@@ -673,9 +673,9 @@ any p (Stream next0 s0 _len) = loop_any s0
673 where
673 where
674 loop_any !s = case next0 s of
674 loop_any !s = case next0 s of
675 Done -> False
675 Done -> False
676− Skip s' -> seq s' $ loop_any s'
676+ Skip s' -> loop_any s'
677 Yield x s' | p x -> True
677 Yield x s' | p x -> True
678− | otherwise -> seq s' $ loop_any s'
678+ | otherwise -> loop_any s'
679
679
680-- | /O(n)/ all @p @xs determines if all characters in the 'Text'
680-- | /O(n)/ all @p @xs determines if all characters in the 'Text'
681-- @xs@ satisify the predicate @p@.
681-- @xs@ satisify the predicate @p@.
@@ -684,8 +684,8 @@ all p (Stream next0 s0 _len) = loop_all s0
684 where
684 where
685 loop_all !s = case next0 s of
685 loop_all !s = case next0 s of
686 Done -> True
686 Done -> True
687− Skip s' -> seq s' $ loop_all s'
687+ Skip s' -> loop_all s'
688− Yield x s' | p x -> seq s' $ loop_all s'
688+ Yield x s' | p x -> loop_all s'
689 | otherwise -> False
689 | otherwise -> False
690
690
691-- | /O(n)/ maximum returns the maximum value from a stream, which must be
691-- | /O(n)/ maximum returns the maximum value from a stream, which must be
@@ -695,14 +695,14 @@ maximum (Stream next0 s0 _len) = loop0_maximum s0
695 where
695 where
696 loop0_maximum !s = case next0 s of
696 loop0_maximum !s = case next0 s of
697 Done -> errorEmptyList "maximum"
697 Done -> errorEmptyList "maximum"
698− Skip s' -> seq s' $ loop0_maximum s'
698+ Skip s' -> loop0_maximum s'
699− Yield x s' -> seq s' $ loop_maximum x s'
699+ Yield x s' -> loop_maximum x s'
700 loop_maximum !z !s = case next0 s of
700 loop_maximum !z !s = case next0 s of
701 Done -> z
701 Done -> z
702− Skip s' -> seq s' $ loop_maximum z s'
702+ Skip s' -> loop_maximum z s'
703 Yield x s'
703 Yield x s'
704− | x > z -> seq s' $ loop_maximum x s'
704+ | x > z -> loop_maximum x s'
705− | otherwise -> seq s' $ loop_maximum z s'
705+ | otherwise -> loop_maximum z s'
706
706
707-- | /O(n)/ minimum returns the minimum value from a 'Text', which must be
707-- | /O(n)/ minimum returns the minimum value from a 'Text', which must be
708-- non-empty.
708-- non-empty.
@@ -711,14 +711,14 @@ minimum (Stream next0 s0 _len) = loop0_minimum s0
711 where
711 where
712 loop0_minimum !s = case next0 s of
712 loop0_minimum !s = case next0 s of
713 Done -> errorEmptyList "minimum"
713 Done -> errorEmptyList "minimum"
714− Skip s' -> seq s' $ loop0_minimum s'
714+ Skip s' -> loop0_minimum s'
715− Yield x s' -> seq s' $ loop_minimum x s'
715+ Yield x s' -> loop_minimum x s'
716 loop_minimum !z !s = case next0 s of
716 loop_minimum !z !s = case next0 s of
717 Done -> z
717 Done -> z
718− Skip s' -> seq s' $ loop_minimum z s'
718+ Skip s' -> loop_minimum z s'
719 Yield x s'
719 Yield x s'
720− | x < z -> seq s' $ loop_minimum x s'
720+ | x < z -> loop_minimum x s'
721− | otherwise -> seq s' $ loop_minimum z s'
721+ | otherwise -> loop_minimum z s'
722
722
723
723
724
724