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

FlatTraverse can produce type errors #185

Open
mrdziuban opened this issue May 10, 2024 · 0 comments
Open

FlatTraverse can produce type errors #185

mrdziuban opened this issue May 10, 2024 · 0 comments

Comments

@mrdziuban
Copy link

Thank you for these rules, I find them really helpful!

I found that the FlatTraverse rule may rewrite code in a way that produces type errors. For example, this traverses a List[String] and produces an IO[List[Option[Int]]], then maps and flattens it to a List[Int]:

List("", "foo", "bar").traverse(s =>
  IO(Some(s.length).filter(_ > 0))
).map(_.flatten)

When it's rewritten to flatTraverse it triggers a type error since flatTraverse would require the given function to return an IO[List[?]].

I think fixing this would require changing it to a SemanticRule.

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

No branches or pull requests

1 participant