on master help sign in
Allow older versions of deepseq
b846fd6Harendra Kumar
benchmark/Linear.hs+8
@@ -1,4 +1,8 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2+#if __GLASGOW_HASKELL__ >= 800
3+{-# OPTIONS_GHC -Wno-orphans #-}
4+#endif
5+
2-- |
6-- |
3-- Module : Main
7-- Module : Main
4-- Copyright : (c) 2018 Harendra Kumar
8-- Copyright : (c) 2018 Harendra Kumar
@@ -26,6 +30,10 @@ import Gauge
26--
30--
27-------------------------------------------------------------------------------
31-------------------------------------------------------------------------------
28
32
33+#if !MIN_VERSION_deepseq(1,4,3)
34+instance NFData Ordering where rnf = (`seq` ())
35+#endif
36+
29-- We need a monadic bind here to make sure that the function f does not get
37-- We need a monadic bind here to make sure that the function f does not get
30-- completely optimized out by the compiler in some cases.
38-- completely optimized out by the compiler in some cases.
31
39
src/Streamly/List.hs+12−3
@@ -73,7 +73,10 @@ module Streamly.List
73where
73where
74
74
75import Control.Arrow (second)
75import Control.Arrow (second)
76−import Control.DeepSeq (NFData(..), NFData1(..))
76+import Control.DeepSeq (NFData(..))
77+#if MIN_VERSION_deepseq(1,4,3)
78+import Control.DeepSeq (NFData1(..))
79+#endif
77import Data.Functor.Identity (Identity, runIdentity)
80import Data.Functor.Identity (Identity, runIdentity)
78import Data.Semigroup (Semigroup(..))
81import Data.Semigroup (Semigroup(..))
79import GHC.Exts (IsList(..), IsString(..))
82import GHC.Exts (IsList(..), IsString(..))
@@ -100,7 +103,10 @@ import qualified Streamly.Streams.StreamK as K
100--
103--
101-- @since 0.6.0
104-- @since 0.6.0
102newtype List a = List { toSerial :: SerialT Identity a }
105newtype List a = List { toSerial :: SerialT Identity a }
103− deriving (Show, Read, Eq, Ord, NFData, NFData1
106+ deriving (Show, Read, Eq, Ord, NFData
107+#if MIN_VERSION_deepseq(1,4,3)
108+ , NFData1
109+#endif
104 , Semigroup, Monoid, Functor, Foldable
110 , Semigroup, Monoid, Functor, Foldable
105 , Applicative, Traversable, Monad)
111 , Applicative, Traversable, Monad)
106
112
@@ -159,7 +165,10 @@ pattern Cons x xs <-
159--
165--
160-- @since 0.6.0
166-- @since 0.6.0
161newtype ZipList a = ZipList { toZipSerial :: ZipSerialM Identity a }
167newtype ZipList a = ZipList { toZipSerial :: ZipSerialM Identity a }
162− deriving (Show, Read, Eq, Ord, NFData, NFData1
168+ deriving (Show, Read, Eq, Ord, NFData
169+#if MIN_VERSION_deepseq(1,4,3)
170+ , NFData1
171+#endif
163 , Semigroup, Monoid, Functor, Foldable
172 , Semigroup, Monoid, Functor, Foldable
164 , Applicative, Traversable)
173 , Applicative, Traversable)
165
174
src/Streamly/Streams/Instances.hs+11−4
@@ -56,6 +56,15 @@ instance (MonadState s m CONSTRAINT) => MonadState s (STREAM m) where { \
56-- well, because they do not get inlined. Need to add INLINE in Ord class in
56-- well, because they do not get inlined. Need to add INLINE in Ord class in
57-- base?
57-- base?
58
58
59+#if MIN_VERSION_deepseq(1,4,3)
60+#define NFDATA1_INSTANCE(STREAM) \
61+instance NFData1 (STREAM Identity) where { \
62+ {-# INLINE liftRnf #-}; \
63+ liftRnf r = runIdentity . P.foldl' (\_ x -> r x) () }
64+#else
65+#define NFDATA1_INSTANCE(STREAM)
66+#endif
67+
59#define LIST_INSTANCES(STREAM) \
68#define LIST_INSTANCES(STREAM) \
60instance IsList (STREAM Identity a) where { \
69instance IsList (STREAM Identity a) where { \
61 type (Item (STREAM Identity a)) = a; \
70 type (Item (STREAM Identity a)) = a; \
@@ -98,10 +107,8 @@ instance (a ~ Char) => IsString (STREAM Identity a) where { \
98 {-# INLINE fromString #-}; \
107 {-# INLINE fromString #-}; \
99 fromString = P.fromList }; \
108 fromString = P.fromList }; \
100 \
109 \
101−instance NFData a => NFData (STREAM Identity a) where { rnf = rnf1 }; \
110+instance NFData a => NFData (STREAM Identity a) where { \
102−instance NFData1 (STREAM Identity) where { \
103− {-# INLINE liftRnf #-}; \
104− liftRnf r = runIdentity . P.foldl' (\_ x -> r x) () }
111+ rnf = runIdentity . P.foldl' (\_ x -> rnf x) () }; \
105
112
106-------------------------------------------------------------------------------
113-------------------------------------------------------------------------------
107-- Foldable
114-- Foldable
src/Streamly/Streams/Serial.hs+6−1
@@ -45,7 +45,10 @@ module Streamly.Streams.Serial
45where
45where
46
46
47import Control.Applicative (liftA2)
47import Control.Applicative (liftA2)
48−import Control.DeepSeq (NFData(..), NFData1(..), rnf1)
48+import Control.DeepSeq (NFData(..))
49+#if MIN_VERSION_deepseq(1,4,3)
50+import Control.DeepSeq (NFData1(..))
51+#endif
49import Control.Monad (ap)
52import Control.Monad (ap)
50import Control.Monad.Base (MonadBase(..), liftBaseDefault)
53import Control.Monad.Base (MonadBase(..), liftBaseDefault)
51import Control.Monad.Catch (MonadThrow, throwM)
54import Control.Monad.Catch (MonadThrow, throwM)
@@ -203,6 +206,7 @@ map f = mapM (return . f)
203MONAD_APPLICATIVE_INSTANCE(SerialT,)
206MONAD_APPLICATIVE_INSTANCE(SerialT,)
204MONAD_COMMON_INSTANCES(SerialT,)
207MONAD_COMMON_INSTANCES(SerialT,)
205LIST_INSTANCES(SerialT)
208LIST_INSTANCES(SerialT)
209+NFDATA1_INSTANCE(SerialT)
206FOLDABLE_INSTANCE(SerialT)
210FOLDABLE_INSTANCE(SerialT)
207TRAVERSABLE_INSTANCE(SerialT)
211TRAVERSABLE_INSTANCE(SerialT)
208
212
@@ -375,5 +379,6 @@ instance Monad m => Monad (WSerialT m) where
375MONAD_APPLICATIVE_INSTANCE(WSerialT,)
379MONAD_APPLICATIVE_INSTANCE(WSerialT,)
376MONAD_COMMON_INSTANCES(WSerialT,)
380MONAD_COMMON_INSTANCES(WSerialT,)
377LIST_INSTANCES(WSerialT)
381LIST_INSTANCES(WSerialT)
382+NFDATA1_INSTANCE(WSerialT)
378FOLDABLE_INSTANCE(WSerialT)
383FOLDABLE_INSTANCE(WSerialT)
379TRAVERSABLE_INSTANCE(WSerialT)
384TRAVERSABLE_INSTANCE(WSerialT)
src/Streamly/Streams/Zip.hs+5−1
@@ -39,7 +39,10 @@ module Streamly.Streams.Zip
39where
39where
40
40
41import Control.Applicative (liftA2)
41import Control.Applicative (liftA2)
42−import Control.DeepSeq (NFData(..), NFData1(..), rnf1)
42+import Control.DeepSeq (NFData(..))
43+#if MIN_VERSION_deepseq(1,4,3)
44+import Control.DeepSeq (NFData1(..))
45+#endif
43import Data.Functor.Identity (Identity, runIdentity)
46import Data.Functor.Identity (Identity, runIdentity)
44import Data.Foldable (fold)
47import Data.Foldable (fold)
45import Data.Semigroup (Semigroup(..))
48import Data.Semigroup (Semigroup(..))
@@ -124,6 +127,7 @@ instance IsStream ZipSerialM where
124 (|:) = consMZip
127 (|:) = consMZip
125
128
126LIST_INSTANCES(ZipSerialM)
129LIST_INSTANCES(ZipSerialM)
130+NFDATA1_INSTANCE(ZipSerialM)
127
131
128instance Monad m => Functor (ZipSerialM m) where
132instance Monad m => Functor (ZipSerialM m) where
129 fmap = map
133 fmap = map