{-# LANGUAGE BangPatterns, TypeOperators, FlexibleContexts #-}
module Control.DeepSeq.Generics
( genericRnf
, genericRnfV1
) where
import Control.DeepSeq
import GHC.Generics
genericRnf :: (Generic a, GNFData (Rep a)) => a -> ()
genericRnf :: forall a. (Generic a, GNFData (Rep a)) => a -> ()
genericRnf = forall (f :: * -> *) a. GNFData f => f a -> ()
grnf_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a x. Generic a => a -> Rep a x
from
{-# INLINE genericRnf #-}
class GNFData f where
grnf_ :: f a -> ()
instance GNFData U1 where
grnf_ :: forall a. U1 a -> ()
grnf_ U1 a
U1 = ()
instance NFData a => GNFData (K1 i a) where
grnf_ :: forall a. K1 i a a -> ()
grnf_ = forall a. NFData a => a -> ()
rnf forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k i c (p :: k). K1 i c p -> c
unK1
{-# INLINEABLE grnf_ #-}
instance GNFData a => GNFData (M1 i c a) where
grnf_ :: forall a. M1 i c a a -> ()
grnf_ = forall (f :: * -> *) a. GNFData f => f a -> ()
grnf_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k i (c :: Meta) (f :: k -> *) (p :: k). M1 i c f p -> f p
unM1
{-# INLINEABLE grnf_ #-}
instance (GNFData a, GNFData b) => GNFData (a :*: b) where
grnf_ :: forall a. (:*:) a b a -> ()
grnf_ (a a
x :*: b a
y) = forall (f :: * -> *) a. GNFData f => f a -> ()
grnf_ a a
x seq :: forall a b. a -> b -> b
`seq` forall (f :: * -> *) a. GNFData f => f a -> ()
grnf_ b a
y
{-# INLINEABLE grnf_ #-}
instance (GNFData a, GNFData b) => GNFData (a :+: b) where
grnf_ :: forall a. (:+:) a b a -> ()
grnf_ (L1 a a
x) = forall (f :: * -> *) a. GNFData f => f a -> ()
grnf_ a a
x
grnf_ (R1 b a
x) = forall (f :: * -> *) a. GNFData f => f a -> ()
grnf_ b a
x
{-# INLINEABLE grnf_ #-}
genericRnfV1 :: (Generic a, GNFDataV1 (Rep a)) => a -> ()
genericRnfV1 :: forall a. (Generic a, GNFDataV1 (Rep a)) => a -> ()
genericRnfV1 = forall (f :: * -> *) a. GNFDataV1 f => f a -> ()
grnfV1_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a x. Generic a => a -> Rep a x
from
{-# INLINE genericRnfV1 #-}
class GNFDataV1 f where
grnfV1_ :: f a -> ()
instance GNFDataV1 V1 where
grnfV1_ :: forall a. V1 a -> ()
grnfV1_ = forall a. HasCallStack => [Char] -> a
error [Char]
"Control.DeepSeq.Generics.genericRnfV1: uninhabited type"
instance GNFDataV1 U1 where
grnfV1_ :: forall a. U1 a -> ()
grnfV1_ U1 a
U1 = ()
instance NFData a => GNFDataV1 (K1 i a) where
grnfV1_ :: forall a. K1 i a a -> ()
grnfV1_ = forall a. NFData a => a -> ()
rnf forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k i c (p :: k). K1 i c p -> c
unK1
{-# INLINEABLE grnfV1_ #-}
instance GNFDataV1 a => GNFDataV1 (M1 i c a) where
grnfV1_ :: forall a. M1 i c a a -> ()
grnfV1_ = forall (f :: * -> *) a. GNFDataV1 f => f a -> ()
grnfV1_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k i (c :: Meta) (f :: k -> *) (p :: k). M1 i c f p -> f p
unM1
{-# INLINEABLE grnfV1_ #-}
instance (GNFDataV1 a, GNFDataV1 b) => GNFDataV1 (a :*: b) where
grnfV1_ :: forall a. (:*:) a b a -> ()
grnfV1_ (a a
x :*: b a
y) = forall (f :: * -> *) a. GNFDataV1 f => f a -> ()
grnfV1_ a a
x seq :: forall a b. a -> b -> b
`seq` forall (f :: * -> *) a. GNFDataV1 f => f a -> ()
grnfV1_ b a
y
{-# INLINEABLE grnfV1_ #-}
instance (GNFDataV1 a, GNFDataV1 b) => GNFDataV1 (a :+: b) where
grnfV1_ :: forall a. (:+:) a b a -> ()
grnfV1_ (L1 a a
x) = forall (f :: * -> *) a. GNFDataV1 f => f a -> ()
grnfV1_ a a
x
grnfV1_ (R1 b a
x) = forall (f :: * -> *) a. GNFDataV1 f => f a -> ()
grnfV1_ b a
x
{-# INLINEABLE grnfV1_ #-}