Proposal for deepseq: Data.Sequence.Seq instance for NFData
Alexey Karakulov
ankarakulov at gmail.com
Tue Jul 12 17:21:15 CEST 2011
My proposal is qiute straightforward. The patch is attached and it's essence
is in these lines:
> instance NFData a => NFData (Data.Sequence.Seq a) where
> rnf = rnf . Foldable.toList
[Discussion part]
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:
> rnfFoldable :: (NFData a, Foldable f) => f a -> ()
> rnfFoldable = Foldable.foldMap rnf
Or it's better to do this with foldl (while not so nice at is was with using
() as monoid):
> rnfFoldable = Foldable.foldl (const rnf) ()
There was a proposal to add strict folds to Foldable type class, so we can
use foldl' there.
My proposal is to add the instance in either way.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20110712/4bb2ffba/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: deepseq.patch
Type: text/x-patch
Size: 1029 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/libraries/attachments/20110712/4bb2ffba/attachment.bin>
More information about the Libraries
mailing list