Skip to content

Conversation

@JSuder-xx
Copy link

Containers meet Result. This includes a few of the userful *M functions renamed for the Elm community. In all of the examples below the m with constraint Monad m is Result.

  • Result.foldl is foldM where the foldable List.
  • Result.foldlArray is foldM where the foldable Array.
  • Result.filterList is filterM where the container is List. Please note that Result.filter was already taken.
  • Result.filterArray is filterM where the container is Array.
  • Result.map2 is zipWithM where the container is List.
  • Result.map2Array is zipWithM where the container is Array.

@miniBill
Copy link
Collaborator

miniBill commented Apr 9, 2025

Tentative +1 to the map2s.

+1 to the foldl (#60).

I'm not sure I like the filters to be honest?

Maybe this is better off split?

@JSuder-xx
Copy link
Author

@miniBill I agree with your assessment completely 😄. I actually opened this to add the foldl (foldM), then thought the map2 would be a nice, simple, and useful addition, and then finally added the filters only for "completeness" with the Monadic generalizations on lists (*M functions), but

  • the name collision with the existing Result.filter is confusing and decreases ease of Api learning and navigation.
  • the filters seem less useful and I don't think they meet the bar for usefulness of inclusion in a core library.

I see you have #60 for the case that motivated this PR.

What would you prefer I do?

@miniBill
Copy link
Collaborator

miniBill commented Apr 9, 2025

My preference would be:

  1. open a PR for foldls
  2. open a PR for map2s
  3. open a PR for filters
  4. close this

So we can discuss them separately

@JSuder-xx JSuder-xx closed this Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants