haskell / deepseq

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

Let the list instance fuse #76

Closed treeowl closed 1 year ago

treeowl commented 2 years ago

We can do something like

liftRnf f = foldr (\x r -> f x `seq` r) ()

This is useful when the list isn't going to be used again. In practice, this mostly occurs


For fun, here it is point free (I wouldn't use this):

liftRnf f = foldr (seq . f) ()
mixphix commented 1 year ago

How do you propose to reconcile this with #17? Are you still interested in the latter, despite the pitfalls of the Foldable class?

treeowl commented 1 year ago

@mixphix Is there some tension between this ticket and that one that I don't see?

mixphix commented 1 year ago

One would imagine the Foldable instance would overlap with the list instance. The implementation mentioned in that ticket would work for this, written explicitly, though.

treeowl commented 1 year ago

@mixphix No one ever suggested a general instance for everything Foldable. Just a tool for writing instances for certain Foldable types (the ones where all the laziness is in the elements folded over).

mixphix commented 1 year ago

That's what I get for reading GitHub issues at 2 in the morning.

treeowl commented 1 year ago

We've all been there. I was up past six this morning. Ugh!