# Does it make sense to have a Range data type?

**URL:** <https://discourse.haskell.org/t/does-it-make-sense-to-have-a-range-data-type/8826>\
**Category:** Learn\
**Created:** [February 18, 2024, 7:20pm UTC](https://discourse.haskell.org/t/does-it-make-sense-to-have-a-range-data-type/8826 "2024-02-18T19:20:16Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![sgraf](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/sgraf/32/392_2.png) [@sgraf](https://discourse.haskell.org/u/sgraf)\
**Post date:** [February 19, 2024, 9:22pm UTC](https://discourse.haskell.org/t/does-it-make-sense-to-have-a-range-data-type/8826/22 "2024-02-19T21:22:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jaror](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/jaror/32/3271_2.png) [@jaror](https://discourse.haskell.org/u/jaror)\
**Post date:** [February 19, 2024, 10:16pm UTC](https://discourse.haskell.org/t/does-it-make-sense-to-have-a-range-data-type/8826/23 "2024-02-19T22:16:27Z")

</div>

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](http://discourse.haskell.org/t/does-it-make-sense-to-have-a-range-data-type/8826/2).

---

<div class="post-metadata">

**Author:** ![sgraf](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/sgraf/32/392_2.png) [@sgraf](https://discourse.haskell.org/u/sgraf)\
**Post date:** [February 20, 2024, 9:48am UTC](https://discourse.haskell.org/t/does-it-make-sense-to-have-a-range-data-type/8826/24 "2024-02-20T09:48:50Z")

</div>

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](https://github.com/AndrasKovacs/staged-fusion)

[Previous page](https://discourse.haskell.org/t/does-it-make-sense-to-have-a-range-data-type/8826.md?page=1)
