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

Add withFilter to OptionT #981

Closed
travisbrown opened this issue Apr 15, 2016 · 4 comments
Closed

Add withFilter to OptionT #981

travisbrown opened this issue Apr 15, 2016 · 4 comments

Comments

@travisbrown
Copy link
Contributor

-Xfuture on 2.11 doesn't allow filter methods to be used in for-comprehensions, which means e.g. this won't compile with -Xfuture on:

import cats.Eval, cats.data.OptionT

for { x <- OptionT(Eval.now(Option(1))) if x > 0 } yield x

It sounds like there's no reason not to add a withFilter method to OptionT.

@xuwei-k
Copy link
Contributor

xuwei-k commented Apr 16, 2016

@adelbertc
Copy link
Contributor

I like the idea of putting it on MonadFilter, but when defining a MonadFilter instance for OptionT:

 47 [info] - OptionT[List, Int].monadFilter.monadFilter right empty *** FAILED *** (14 milliseconds)
 48 [info]   GeneratorDrivenPropertyCheckFailedException was thrown during property evaluation.
 49 [info]    (Discipline.scala:14)
 50 [info]     Falsified after 0 successful property evaluations.
 51 [info]     Location: (Discipline.scala:14)
 52 [info]     Occurred when passed generated values (
 53 [info]       arg0 = OptionT(List())
 54 [info]     )
 55 [info]     Label of failing property:
 56 [info]       (OptionT(List()) ?== OptionT(List(None))) failed

Related: #698

@ceedubs
Copy link
Contributor

ceedubs commented Apr 18, 2016

I'd vote for adding withFilter to OptionT now and worrying about the MonadFilter component later as a resolution to #694 (which I'm guessing we won't get around to for a while).

@ceedubs
Copy link
Contributor

ceedubs commented May 14, 2016

Added in #1028.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants