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

Drop invalid lists:filtermap/2 known problem #506

Merged
merged 1 commit into from
Jan 24, 2023

Conversation

erszcz
Copy link
Collaborator

@erszcz erszcz commented Jan 24, 2023

The original case this test was based on is not really a problem with the spec or the constraint solver - it was an actual bug in how we use the function. It was originally merged in #504.

The original case this test was based on is not really a problem with the spec
or the constraint solver - it was an actual bug in how we use the function.
@erszcz
Copy link
Collaborator Author

erszcz commented Jan 24, 2023

I've also cross checked with the Haskell standard library and see there isn't a combined filtermap there. I think that without union types it would be pretty hard to express the return value in the Haskell type system. However, this also hints that the union type is correct there and that the actual use case of filtermap was buggy, not it's type checking.

Copy link
Collaborator

@zuiderkwast zuiderkwast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with deleting this. The use case is not valid. It needs some type assertion or guard. The spec in OTP is correct, i.e.

  -spec filtermap(Fun, List1) -> List2
                     when
                         Fun :: fun((Elem) -> boolean() | {true, Value}),
                         List1 :: [Elem],
                         List2 :: [Elem | Value],
                         Elem :: term(),
                         Value :: term().

@erszcz erszcz merged commit 57dda0f into josefs:master Jan 24, 2023
@erszcz erszcz deleted the drop-invalid-known-problem branch January 24, 2023 13:41
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