haskell / deepseq

Deep evaluation of data structures
http://hackage.haskell.org/package/deepseq
Other
41 stars 28 forks source link

Add rnfFoldableLTR and rnfFoldableRTL #18

Closed treeowl closed 2 months ago

treeowl commented 8 years ago

If a type has a Foldable instance, then we can force it from left to right or from right to left.

Fixes #17

RyanGlScott commented 8 years ago

For context: Haskell libraries mailing list discussion: https://mail.haskell.org/pipermail/libraries/2016-July/027164.html

rwbarton commented 8 years ago

This should carry a huge warning that it is normally not a sensible definition for Foldable instances where f a contains fields of types other than a, such as a pair.

treeowl commented 8 years ago

It has such a warning, specifically mentioning Either a and (,) a. Is the warning insufficient?

On Jul 27, 2016 5:03 PM, "Reid Barton" notifications@github.com wrote:

This should carry a huge warning that it is normally not a sensible definition for Foldable instances where f a contains fields of types other than a, such as a pair.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/haskell/deepseq/pull/18#issuecomment-235720235, or mute the thread https://github.com/notifications/unsubscribe-auth/ABzi_djQZ4CsXZJuz8q7fJP_0C8XJgpyks5qZ8esgaJpZM4JOIet .

rwbarton commented 8 years ago

Oh, so it does. There is such a lot of noise in the diff that I missed it.

chessai commented 5 years ago

This seems useful, can this be worked in to the modern deepseq?

cartazio commented 5 years ago

Perhaps I’m overlooking something obvious : but can’t we tease out assoxiativity of a structure from its foldmap?

On Fri, May 3, 2019 at 6:56 PM chessai notifications@github.com wrote:

This seems useful, can this be worked in to the modern deepseq?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/haskell/deepseq/pull/18#issuecomment-489264650, or mute the thread https://github.com/notifications/unsubscribe-auth/AAABBQXQJ6QXWWMAR4BP2TDPTS7JJANCNFSM4CJYQ6WQ .

chessai commented 4 years ago

Are we worried at all about the loss of Safe?

mixphix commented 2 months ago

foldMap can be more efficient than either foldl or foldr, so Unit was added by #106 (same as UnitLTR).