ref: 7a9a4c585a271b81983b14fc3ea9d6a8d7712252
parent: 04486af65a233d40b69cb2d6215a4a1448f4246b
author: Lennart Augustsson <lennart@augustsson.net>
date: Thu Sep 26 13:59:12 EDT 2024
Move DeepSeq stuff around
--- a/lib/Control/DeepSeq.hs
+++ b/lib/Control/DeepSeq.hs
@@ -14,13 +14,16 @@
import Control.Monad
import Data.Bool
import Data.Char
+import Data.Complex
import Data.Double
import Data.Either
+import Data.Fixed
import Data.Float
import Data.Function
import Data.Int
import Data.Integer
import Data.List
+import Data.List.NonEmpty
import Data.Maybe
import Data.Ord
import Data.Proxy
@@ -77,7 +80,11 @@
instance NFData Word32
instance NFData Word64
+instance NFData a => NFData (NonEmpty a) where
+ rnf = rnf . toList
+
instance NFData (Proxy a) where rnf Proxy = ()
+
instance NFData a => NFData (Ratio a) where
rnf x = rnf (numerator x, denominator x)
@@ -84,6 +91,7 @@
instance NFData a => NFData (Maybe a) where
rnf Nothing = ()
rnf (Just a) = rnf a
+
instance NFData a => NFData [a] where
rnf = foldr (\ x r -> rnf x `seq` r) ()
@@ -90,6 +98,9 @@
instance (NFData a, NFData b) => NFData (Either a b) where
rnf (Left a) = rnf a
rnf (Right b) = rnf b
+
+instance (NFData a) => NFData (Complex a) where
+ rnf (x :+ y) = rnf x `seq` rnf y
{-
-- | @since 1.4.3.0
--- a/lib/Data/Complex.hs
+++ b/lib/Data/Complex.hs
@@ -1,5 +1,4 @@
module Data.Complex(module Data.Complex) where
-import Control.DeepSeq
import Data.Typeable
infix 6 :+
@@ -137,6 +136,3 @@
, v <- sin (b/2)
, w <- -2*v*v = (u*w + u + w) :+ (u+1)*sin b
| otherwise = exp x - 1
-
-instance (NFData a) => NFData (Complex a) where
- rnf (x :+ y) = rnf x `seq` rnf y `seq` ()
--- a/lib/Data/Fixed.hs
+++ b/lib/Data/Fixed.hs
@@ -38,6 +38,12 @@
import Text.Read.Internal
import Text.ParserCombinators.ReadPrec
import Text.Read.Lex
+import Data.Double
+import Data.Floating
+import Data.Fractional
+import Data.Integer
+import Data.Real
+import Data.RealFrac
import Data.Typeable
default () -- avoid any defaulting shenanigans
--- a/lib/Data/List/NonEmpty.hs
+++ b/lib/Data/List/NonEmpty.hs
@@ -101,7 +101,6 @@
import Prelude()
import Control.Applicative
-import Control.DeepSeq
import Control.Error
import Control.Monad
import Data.Bool
@@ -164,8 +163,6 @@
foldr f z = foldr f z . toList
--instance Traversable NonEmpty where
-- traverse f = fromList . traverse f . toList
-instance NFData a => NFData (NonEmpty a) where
- rnf = rnf . toList
----- End MHS replacement
--- a/lib/Text/ParserCombinators/ReadP.hs
+++ b/lib/Text/ParserCombinators/ReadP.hs
@@ -241,7 +241,7 @@
-- ^ Symmetric choice.
R f1 +++ R f2 = R (\k -> f1 k <|> f2 k)
-(<++) :: ReadP a -> ReadP a -> ReadP a
+(<++) :: forall a . ReadP a -> ReadP a -> ReadP a
-- ^ Local, exclusive, left-biased choice: If left parser
-- locally produces any result at all, then right parser is
-- not used.
@@ -249,6 +249,7 @@
do s <- look
probe (f0 return) s 0
where
+ probe :: P a -> [Char] -> Int -> ReadP a
probe (Get f) (c:s) n = probe (f c) s (n + 1)
probe (Look f) s n = probe (f s) s n
probe p@(Result _ _) _ n = discard n >> R (p >>=)