Oops.. Probably I get why toList is preferred method for making instances :) My rnfFoldable does not work. <br>But this version must be correct:<br><br>> rnfFoldable :: (NFData a, Foldable f) => f a -> ()<br>> rnfFoldable = Foldable.foldl (\z x -> rnf x `seq` z) ()<br>
<br><br><div class="gmail_quote">On Tue, Jul 12, 2011 at 6:21 PM, Alexey Karakulov <span dir="ltr"><<a href="mailto:ankarakulov@gmail.com">ankarakulov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
My proposal is qiute straightforward. The patch is attached and it's essence is in these lines:<br><br>> instance NFData a => NFData (Data.Sequence.Seq a) where<br>> rnf = rnf . Foldable.toList<br><br>[Discussion part]<br>
<br>I choosed toList method to keep the code style, but I'm not sure it's efficient to create cons'es when we could just fold:<br><br>> rnfFoldable :: (NFData a, Foldable f) => f a -> ()<br>> rnfFoldable = Foldable.foldMap rnf<br>
<br>Or it's better to do this with foldl (while not so nice at is was with using () as monoid):<br><br>> rnfFoldable = Foldable.foldl (const rnf) ()<br><br>There was a proposal to add strict folds to Foldable type class, so we can use foldl' there.<br>
<br>My proposal is to add the instance in either way. <br>
</blockquote></div><br>