Does it make sense to have a Range data type?

See also GitHub - sgraf812/foldr-build: A foldr/build fusion library. Working out this library would be the principled version of a range data type, I think.

1 Like

I’ve heard stream (co-church) fusion is better than foldr-build (church) fusion since the former can fuse zips (and similar multi-input functions).

That why I suggested looking at the stream-fusion package in my earlier comment.

My stance is that we should first provide a fusion framework based on the encoding used in base, so that users can switch to this push-based framework with minimal breaking performance guarantees. I think there might lurk a few Simplifier-related pitfalls in going straight to pull-based fusion, although all-in-all I think it is the better fusion framework for the reasons you mention.

Ultimately it’s not an either-or. See also this exciting work by Andras Kovacs GitHub - AndrasKovacs/staged-fusion: Staged push/pull fusion with typed Template Haskell

1 Like