Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List.filterMapM is backwards #4676

Closed
3 tasks done
ChiCubed opened this issue Jul 7, 2024 · 0 comments · Fixed by #4820
Closed
3 tasks done

List.filterMapM is backwards #4676

ChiCubed opened this issue Jul 7, 2024 · 0 comments · Fixed by #4820
Assignees
Labels
bug Something isn't working

Comments

@ChiCubed
Copy link

ChiCubed commented Jul 7, 2024

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

List.filterMapM works from right to left, not left to right as the documentation claims.

-- for reference. output: 123
#eval discard $ [1, 2, 3].mapM fun x => IO.print x

-- expected: 123, actual: 321
#eval discard $ [1, 2, 3].filterMapM fun x => some <$> IO.print x

Versions

"4.11.0-nightly-2024-07-07" on live.lean-lang.org

Additional information

I tested these other monadic map-like functions and they all seem to behave as advertised:

  • List: mapM, forM, filterM, filterRevM, foldlM, foldrM
  • Array: the above (except Array.filterRevM which doesn't exist) and, notably, filterMapM

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

@ChiCubed ChiCubed added the bug Something isn't working label Jul 7, 2024
@semorrison semorrison self-assigned this Jul 24, 2024
github-merge-queue bot pushed a commit that referenced this issue Jul 24, 2024
Closes #4676. Previously `List.filterMapM` was returning results
left-to-right, but evaluating right-to-left.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants