kowainik / slist

♾️ Sized list
https://kowainik.github.io/projects/slist
Mozilla Public License 2.0
46 stars 6 forks source link

[RFC] Strict append #36

Closed chshersh closed 3 years ago

chshersh commented 4 years ago

Sometimes, I want to do <> on lists but add sizes strictly to avoid space leaks. The size field of the Slist data structure is intentionally lazy to make some functions work and not hang on some corner cases (or maybe to have a better lazy semantics). So having a separate function like append' probably won't hurt :slightly_smiling_face:

I also often use concatMap to combine a lot of lists, so having concatMap' will be nice as well :+1:

Both strict append' and concatMap' can be faster my skipping empty lists. This is especially relevant when you want to append a lot of lists of size 0 or 1.

Alternatively, we can change the definition of <> itself, but dealing with laziness is difficult, so probably we can introduce a few separate functions.

chshersh commented 3 years ago

Having strict cons' would be nice as well