Organization of strict functions

In Strict maps by treeowl · Pull Request #102 · lspitzner/pqueue · GitHub 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?

2 Likes

New module without the tick is nice!

2 Likes

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.

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

1 Like

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.

1 Like

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.

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

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.