typelevel / cats-effect

The pure asynchronous runtime for Scala
https://typelevel.org/cats-effect/
Apache License 2.0
2.02k stars 518 forks source link

Add FAQ entry about IO missing `withFilter` #1350

Open Daenyth opened 3 years ago

Daenyth commented 3 years ago

Errors like error: value withFilter is not a member of cats.effect.IO are very confusing for newcomers

Add a FAQ entry which:

djspiewak commented 3 years ago

Linking this idea so we don't lose it: https://gitter.im/typelevel/cats-effect?at=5f91ac4bc990bb1c3924d794 I absolutely love this concept. Very creative use of implicits.

kubukoz commented 3 years ago

Is bm4 going to be available / necessary in dotty? If so, maybe we should go the ZIO way and define withFilter as an IO that fails with some Throwable if the predicate doesn't hold.

djspiewak commented 3 years ago

Failing with a MatchError actually isn't the end of the world. It basically recreates pattern matching semantics (like val). It does oddly allow if statement as well though.

If we were to do that, I would want to make it available as syntax on all MonadThrow types as well, just for uniformity. And I'm still not convinced it's a good idea. 😃

But with that said, maybe it's better than nothing. Bm4 isn't available on Dotty and probably never will be.