Box helper to wrap types where WHNF = NF
I'd like a type that can be used to wrap values for which I want WHNF = NF. This is useful for satisfying NFData constraints with criterion for example.
newtype WHNF a = WHNF a
instance NFData (WHNF a) where rnf (WHNF a) = seq a ()
Of course, this data type should be given a better name. Maybe data instead of newtype would also be useful for even more laziness?
@bennofs btw, wasn't there already some mailing-list discussion about this?
I have uploaded a package which does this https://hackage.haskell.org/package/nf though the type is called NF. Eventually we might move it into deepseq but this package will be useful for people who want to use it in older versions of GHC. (We'd like to stabilize it first though.)
This would be amazing to use with DerivingVia:
data Foo = ...
deriving NFData via WHNF Foo