# Organization of strict functions

**URL:** <https://discourse.haskell.org/t/organization-of-strict-functions/6354>\
**Category:** Uncategorized\
**Created:** [May 31, 2023, 10:36pm UTC](https://discourse.haskell.org/t/organization-of-strict-functions/6354 "2023-05-31T22:36:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![konsumlamm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/konsumlamm/32/3193_2.png) [@konsumlamm](https://discourse.haskell.org/u/konsumlamm)\
**Post date:** [May 31, 2023, 10:36pm UTC](https://discourse.haskell.org/t/organization-of-strict-functions/6354/1 "2023-05-31T22:36:22Z")

</div>

In [Strict maps by treeowl · Pull Request #102 · lspitzner/pqueue · GitHub](https://github.com/lspitzner/pqueue/pull/102) we were talking about how to organize functions like strict `map` or `traverse`. There are several options:

- have the strict versions in the same module with a `'` suffix
- have a new module for strict functions (with or without `'` suffix)

Which options would you prefer and why? Or perhaps you have another option we haven’t considered yet?

---

<div class="post-metadata">

**Author:** ![Kleidukos](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/kleidukos/32/1213_2.png) [@Kleidukos](https://discourse.haskell.org/u/Kleidukos)\
**Post date:** [June 1, 2023, 5:47am UTC](https://discourse.haskell.org/t/organization-of-strict-functions/6354/2 "2023-06-01T05:47:22Z")

</div>

New module without the tick is nice!

---

<div class="post-metadata">

**Author:** ![tomjaguarpaw](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/tomjaguarpaw/32/1230_2.png) [@tomjaguarpaw](https://discourse.haskell.org/u/tomjaguarpaw)\
**Post date:** [June 1, 2023, 9:00am UTC](https://discourse.haskell.org/t/organization-of-strict-functions/6354/3 "2023-06-01T09:00:43Z")

</div>

Yes, a whole strict module like `containers` please! Personally I never want to use the lazy interface to container types and I’d rather import one module that gets me the functions I want and none of the functions I don’t want.

---

<div class="post-metadata">

**Author:** ![konsumlamm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/konsumlamm/32/3193_2.png) [@konsumlamm](https://discourse.haskell.org/u/konsumlamm)\
**Post date:** [June 1, 2023, 11:14am UTC](https://discourse.haskell.org/t/organization-of-strict-functions/6354/4 "2023-06-01T11:14:30Z")

</div>

> [@tomjaguarpaw](#):
>
> Yes, a whole strict module like `containers` please! Personally I never want to use the lazy interface to container types and I’d rather import one module that gets me the functions I want and none of the functions I don’t want.

So you’d want a module that exports the strict functions _and_ the other functions (that have no lazy/strict variants)? I was thinking about a module that only contains the strict functions and nothing else.

---

<div class="post-metadata">

**Author:** ![tomjaguarpaw](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/tomjaguarpaw/32/1230_2.png) [@tomjaguarpaw](https://discourse.haskell.org/u/tomjaguarpaw)\
**Post date:** [June 1, 2023, 11:39am UTC](https://discourse.haskell.org/t/organization-of-strict-functions/6354/5 "2023-06-01T11:39:13Z")

</div>

Oh right, yes, strict functions plus strictness-independent ones, just like `Data.Map.Strict`.

---

<div class="post-metadata">

**Author:** ![tomjaguarpaw](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/tomjaguarpaw/32/1230_2.png) [@tomjaguarpaw](https://discourse.haskell.org/u/tomjaguarpaw)\
**Post date:** [June 1, 2023, 11:44am UTC](https://discourse.haskell.org/t/organization-of-strict-functions/6354/6 "2023-06-01T11:44:41Z")

</div>

Although I should emphasize that regardless of the exact module layout, the thing that is most important to me is that it be easy to avoid importing any lazy functions.

---

<div class="post-metadata">

**Author:** ![konsumlamm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/konsumlamm/32/3193_2.png) [@konsumlamm](https://discourse.haskell.org/u/konsumlamm)\
**Post date:** [June 1, 2023, 1:58pm UTC](https://discourse.haskell.org/t/organization-of-strict-functions/6354/7 "2023-06-01T13:58:48Z")

</div>

I’m afraid that’s not entirely possible (same for `Data.Map.Strict`), unless we make a new type for strict priority queues. The instances (e.g. `Functor` and `Traversable`) would still have the lazy variant.

---

<div class="post-metadata">

**Author:** ![tomjaguarpaw](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/tomjaguarpaw/32/1230_2.png) [@tomjaguarpaw](https://discourse.haskell.org/u/tomjaguarpaw)\
**Post date:** [June 1, 2023, 2:00pm UTC](https://discourse.haskell.org/t/organization-of-strict-functions/6354/8 "2023-06-01T14:00:27Z")

</div>

Agreed, not quite possible, but `Data.Map.Strict` gets close enough.

---

<div class="post-metadata">

**Author:** ![treeowl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/treeowl/32/1813_2.png) [@treeowl](https://discourse.haskell.org/u/treeowl)\
**Post date:** [June 1, 2023, 8:09pm UTC](https://discourse.haskell.org/t/organization-of-strict-functions/6354/9 "2023-06-01T20:09:52Z")

</div>

I think it might actually make sense to make a new type for strict priority queues. In particular, if we copied over the current `MinPQueue` implementation and added a bangs to the second fields of both `BinomTree` and `Succ`, then we’d get a `StrictMinPQueue k a` with the property that the current `MinQueue k` is _precisely_ `StrictMinPQueue k ()`. Kind of interesting… Now as has been discussed previously, we might want to change the representation of `MinQueue` to make it more compact, but that adds complexity. This `StrictMinPQueue` wouldn’t be a `Functor` (IMO), but could have a full suite of mapping and traversal functions. Something to think about.
