[Haskell-cafe] ANN: generic-deepseq 1.0.0.0
José Pedro Magalhães
jpm at cs.uu.nl
Fri Feb 24 14:08:53 CET 2012
Hi Andres,
2012/2/24 Andres Löh <andres.loeh at googlemail.com>
> I don't understand what's going on here. Instances for V1 should of
> course be defined if they can be! And in this case, a V1 instance
> makes sense and should be defined. The definition itself doesn't
> matter, as it'll never be executed.
>
The definition certainly matters:
data Ze deriving Generic
>
> class DeepSeq a where
> rnf :: a -> ()
> default rnf :: (Generic a, GDeepSeq (Rep a)) => a -> ()
> rnf = grnf . from
>
> instance DeepSeq Ze
>
> class GDeepSeq f where
> grnf :: f a -> ()
>
> instance GDeepSeq V1 where
> grnf _ = ()
>
> instance GDeepSeq a => GDeepSeq (M1 i c a) where
> grnf = grnf . unM1
>
> -- other instances are not relevant now
>
> t :: Ze
> t = undefined
>
seq t () == undefined. rnf t == (), because the V1 instance dictates so.
Cheers,
Pedro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120224/e08cf2fd/attachment.htm>
More information about the Haskell-Cafe
mailing list