
4 Sep
2009
4 Sep
'09
7:57 p.m.
When ones makes an ADT with data constructors that has strict (and maybe unpacked) fields, e.g. data Vec2 a = Vec2 {-# UNPACK #-} !a {-# UNPACK #-} !a how does one define an NFData instance? Like this? instance NFData a => NFData (Vec2 a) where rnf (Vec2 x y) = rnf x `seq` rnf y Or is it enough to just do instance NFData a => NFData (Vec2 a) since Vec2 is fully strict anyway, so that default rnf implementation will do? Thanks, Peter