deepseq
deepseq copied to clipboard
Add 'Whnf{,1,2}' (or some better name) newtype
newtype Whnf a = Whnf a
newtype Whnf1 f a = Whnf1 (f a)
newtype Whnf2 bi a b = Whnf2 (bi a b)
instance NFData (Whnf a) where rnf (Whnf a) = a `seq` ()
instance NFData1 (Whnf1 f) where liftRnf _ (Whnf1 as) = as `seq` ()
instance NFData2 (Whnf2 bi) where liftRnf2 _ _ (Whnf2 as) = as `seq` ()
As well as
newtype Rnf1 f a = Rnf1 (f a)
instance (NFData1 f, NFData a) => NFData (Rnf1 f a) where
rnf (Rnf1 as) = rnf1 as
You want a newtype instance that will prevent NFData from fully evaluating it?
I think the nf package may have some stuff like that.