haskell / haskell/containers

Foldable Conversions

Open
#351 5 comments 0 reactions 0 assignees View on GitHub
feature-request
Dominant language
Haskell
Stars
355
Forks
194
Avg merge
3d 4h
Merged PRs (30d)
4

Description

This is related to some of what I brought up in https://github.com/haskell/containers/issues/338. I was just working with Data.Set and wanted to call unions on some foldable collection of Sets. I can just write:

```
unions . toList
```

And that works fine. And for some data structures, the intermediate list may even get fused away. Maybe. But any time I have to call toList on a Foldable, I'm unsatisfied because whatever cosumes the list could have been written to just fold over the collection instead. It seems like generalizing unions should be possible (although it does use a special variant of foldl).

Additionally, having a fromFoldable would be nice. It would be misleading to generalize fromList since the name would then be misleading.

But for the most part, I would like the see the functions whose names don't explicitly mention the word "list" be generalized, with rewrite rules to use the tunes list variants when possible.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.