haskell / deepseq

Deep evaluation of data structures
http://hackage.haskell.org/package/deepseq
Other
40 stars 29 forks source link

NFData(1) instances of Generically(1). #79

Open Icelandjack opened 2 years ago

Icelandjack commented 2 years ago

Generic instances of NFData and NFData1, and documentation.

instance (Generic a, GNFData Zero (Rep a)) => NFData (Generically a) where
  rnf :: Generically a -> ()
  rnf (Generically a) = grnf RnfArgs0 (from a)

instance (Generic1 f, GNFData One (Rep1 f)) => NFData1 (Generically1 f) where
  liftRnf :: (a -> ()) -> (Generically1 f a -> ())
  liftRnf r (Generically1 as) = grnf (RnfArgs1 r) (from1 as)