Cats-effect: Add withFilter to IO

Created on 29 Mar 2018  路  3Comments  路  Source: typelevel/cats-effect

I was converting some code from Futures, and found that I couldn't directly translate for { (foo, bar) <- IO(blah) } due to the lack of withFilter

Most helpful comment

I did use that fix for the record; my desire to have this is purely because it makes the transition to using IO more smooth for people with less experience. On the surface, using (foo, bar) <- IO(blah) getting a compile error about IO not having withFilter is one I expect to be confusing to newcomers.

Worst case I could always add an implicit to my codebase

All 3 comments

withFilter is reportedly unsafe. You might find this discussion interesting: https://github.com/scalaz/scalaz/pull/728

I'm on the fence about adding it and I'm leaning towards NO 馃憥 , because the need for it is an artifact of how the current Scala compiler works and might not survive long term, plus you can live just fine without it:

for {
  r <- IO(blah)
  (foo, bar) = r
} yield ???

I did use that fix for the record; my desire to have this is purely because it makes the transition to using IO more smooth for people with less experience. On the surface, using (foo, bar) <- IO(blah) getting a compile error about IO not having withFilter is one I expect to be confusing to newcomers.

Worst case I could always add an implicit to my codebase

Reading the Maybe discussion was fairly enlightening, thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

djspiewak picture djspiewak  路  4Comments

hilios picture hilios  路  5Comments

kubukoz picture kubukoz  路  7Comments

jchapuis picture jchapuis  路  6Comments

ronanM picture ronanM  路  5Comments