11{-# LANGUAGE FlexibleContexts #-}
22{-# LANGUAGE RankNTypes #-}
33{-# LANGUAGE Trustworthy #-}
4- {-# LANGUAGE TypeOperators #-}
54
65-- | This module does two things:
76--
@@ -25,7 +24,6 @@ module Distribution.Compat.Prelude
2524 , Data
2625 , Generic
2726 , NFData (.. )
28- , genericRnf
2927 , Binary (.. )
3028 , Structured
3129 , Alternative (.. )
@@ -235,7 +233,7 @@ import Data.Void (Void, absurd, vacuous)
235233import Data.Word (Word , Word16 , Word32 , Word64 , Word8 )
236234import Distribution.Compat.Binary (Binary (.. ))
237235import Distribution.Compat.Semigroup (gmappend , gmempty )
238- import GHC.Generics (Generic ( .. ), K1 ( unK1 ), M1 ( unM1 ), U1 ( U1 ), V1 , (:*:) ( (:*:) ), (:+:) ( L1 , R1 ) )
236+ import GHC.Generics (Generic )
239237import System.Exit (ExitCode (.. ), exitFailure , exitSuccess , exitWith )
240238import Text.Read (readMaybe )
241239
@@ -251,47 +249,6 @@ import qualified Debug.Trace
251249(<<>>) :: Disp. Doc -> Disp. Doc -> Disp. Doc
252250(<<>>) = (Disp. <>)
253251
254- -- | "GHC.Generics"-based 'rnf' implementation
255- --
256- -- This is needed in order to support @deepseq < 1.4@ which didn't
257- -- have a 'Generic'-based default 'rnf' implementation yet.
258- --
259- -- In order to define instances, use e.g.
260- --
261- -- > instance NFData MyType where rnf = genericRnf
262- --
263- -- The implementation has been taken from @deepseq-1.4.2@'s default
264- -- 'rnf' implementation.
265- genericRnf :: (Generic a , GNFData (Rep a )) => a -> ()
266- genericRnf = grnf . from
267-
268- -- | Hidden internal type-class
269- class GNFData f where
270- grnf :: f a -> ()
271-
272- instance GNFData V1 where
273- grnf = error " Control.DeepSeq.rnf: uninhabited type"
274-
275- instance GNFData U1 where
276- grnf U1 = ()
277-
278- instance NFData a => GNFData (K1 i a ) where
279- grnf = rnf . unK1
280- {-# INLINEABLE grnf #-}
281-
282- instance GNFData a => GNFData (M1 i c a ) where
283- grnf = grnf . unM1
284- {-# INLINEABLE grnf #-}
285-
286- instance (GNFData a , GNFData b ) => GNFData (a :*: b ) where
287- grnf (x :*: y) = grnf x `seq` grnf y
288- {-# INLINEABLE grnf #-}
289-
290- instance (GNFData a , GNFData b ) => GNFData (a :+: b ) where
291- grnf (L1 x) = grnf x
292- grnf (R1 x) = grnf x
293- {-# INLINEABLE grnf #-}
294-
295252-- TODO: if we want foldr1/foldl1 to work on more than NonEmpty, we
296253-- can define a local typeclass 'Foldable1', e.g.
297254--
0 commit comments