on master help sign in
Allow older versions of deepseq

Otherwise cabal cannot find a build plan for older versions of GHC

commitb846fd6a21441e463ad1d697c7f14b25dd548916 authorHarendra Kumar <harendra.kumar@gmail.com> dateSun 16 Jun 2019, 15:24 (7 years ago) parenta40050f
5 files changed+42−9
benchmark/Linear.hs+8 src/Streamly/List.hs+12−3 src/Streamly/Streams/Instances.hs+11−4 src/Streamly/Streams/Serial.hs+6−1 src/Streamly/Streams/Zip.hs+5−1
benchmark/Linear.hs+8
@@ -1,4 +1,8 @@
11{-# LANGUAGE CPP #-}
2+#if __GLASGOW_HASKELL__ >= 800
3+{-# OPTIONS_GHC -Wno-orphans #-}
4+#endif
5+
26-- |
37-- Module : Main
48-- Copyright : (c) 2018 Harendra Kumar
@@ -26,6 +30,10 @@ import Gauge
2630--
2731-------------------------------------------------------------------------------
2832
33+#if !MIN_VERSION_deepseq(1,4,3)
34+instance NFData Ordering where rnf = (`seq` ())
35+#endif
36+
2937-- We need a monadic bind here to make sure that the function f does not get
3038-- completely optimized out by the compiler in some cases.
3139
src/Streamly/List.hs+12−3
@@ -73,7 +73,10 @@ module Streamly.List
7373where
7474
7575import 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
7780import Data.Functor.Identity (Identity, runIdentity)
7881import Data.Semigroup (Semigroup(..))
7982import GHC.Exts (IsList(..), IsString(..))
@@ -100,7 +103,10 @@ import qualified Streamly.Streams.StreamK as K
100103--
101104-- @since 0.6.0
102105newtype 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
104110 , Semigroup, Monoid, Functor, Foldable
105111 , Applicative, Traversable, Monad)
106112
@@ -159,7 +165,10 @@ pattern Cons x xs <-
159165--
160166-- @since 0.6.0
161167newtype 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
163172 , Semigroup, Monoid, Functor, Foldable
164173 , Applicative, Traversable)
165174
src/Streamly/Streams/Instances.hs+11−4
@@ -56,6 +56,15 @@ instance (MonadState s m CONSTRAINT) => MonadState s (STREAM m) where { \
5656-- well, because they do not get inlined. Need to add INLINE in Ord class in
5757-- base?
5858
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+
5968#define LIST_INSTANCES(STREAM) \
6069instance IsList (STREAM Identity a) where { \
6170 type (Item (STREAM Identity a)) = a; \
@@ -98,10 +107,8 @@ instance (a ~ Char) => IsString (STREAM Identity a) where { \
98107 {-# INLINE fromString #-}; \
99108 fromString = P.fromList }; \
100109 \
101−instance NFData a => NFData (STREAM Identity a) where { rnf = rnf1 }; \
102−instance NFData1 (STREAM Identity) where { \
103− {-# INLINE liftRnf #-}; \
104− liftRnf r = runIdentity . P.foldl' (\_ x -> r x) () }
110+instance NFData a => NFData (STREAM Identity a) where { \
111+ rnf = runIdentity . P.foldl' (\_ x -> rnf x) () }; \
105112
106113-------------------------------------------------------------------------------
107114-- Foldable
src/Streamly/Streams/Serial.hs+6−1
@@ -45,7 +45,10 @@ module Streamly.Streams.Serial
4545where
4646
4747import 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
4952import Control.Monad (ap)
5053import Control.Monad.Base (MonadBase(..), liftBaseDefault)
5154import Control.Monad.Catch (MonadThrow, throwM)
@@ -203,6 +206,7 @@ map f = mapM (return . f)
203206MONAD_APPLICATIVE_INSTANCE(SerialT,)
204207MONAD_COMMON_INSTANCES(SerialT,)
205208LIST_INSTANCES(SerialT)
209+NFDATA1_INSTANCE(SerialT)
206210FOLDABLE_INSTANCE(SerialT)
207211TRAVERSABLE_INSTANCE(SerialT)
208212
@@ -375,5 +379,6 @@ instance Monad m => Monad (WSerialT m) where
375379MONAD_APPLICATIVE_INSTANCE(WSerialT,)
376380MONAD_COMMON_INSTANCES(WSerialT,)
377381LIST_INSTANCES(WSerialT)
382+NFDATA1_INSTANCE(WSerialT)
378383FOLDABLE_INSTANCE(WSerialT)
379384TRAVERSABLE_INSTANCE(WSerialT)
src/Streamly/Streams/Zip.hs+5−1
@@ -39,7 +39,10 @@ module Streamly.Streams.Zip
3939where
4040
4141import 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
4346import Data.Functor.Identity (Identity, runIdentity)
4447import Data.Foldable (fold)
4548import Data.Semigroup (Semigroup(..))
@@ -124,6 +127,7 @@ instance IsStream ZipSerialM where
124127 (|:) = consMZip
125128
126129LIST_INSTANCES(ZipSerialM)
130+NFDATA1_INSTANCE(ZipSerialM)
127131
128132instance Monad m => Functor (ZipSerialM m) where
129133 fmap = map