serokell / universum

:milky_way: Prelude written in @Serokell
MIT License
176 stars 28 forks source link

Investigate and resolve potential space leaks #105

Closed chshersh closed 6 years ago

chshersh commented 6 years ago

I suppose in several places implementation of functions might be stricter than it's actually now. This should increase performance. I'm not aware of all places, but here's my list:

  1. length should use foldl' instead of Foldable.length
  2. mconcat for Sum and Product should use foldl' mappend mempty instead lf foldr (though I dunno how to resolve this because we can't change instances).

Maybe something else... But this should be benchmarked!

chshersh commented 6 years ago

length relies on REWRITE rules and build/foldr fusion system. So it's already works well. We can't change stocked instances. So I propose to solve this problem lazily: when somebody find space leak, we fix it.