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

Support effect of boolean #25

Open
adrian-salajan opened this issue Sep 28, 2020 · 2 comments
Open

Support effect of boolean #25

adrian-salajan opened this issue Sep 28, 2020 · 2 comments

Comments

@adrian-salajan
Copy link

adrian-salajan commented Sep 28, 2020

Hello, today I tried using this lib, from the provided example:

 val p: PropF[IO] = 
      PropF.forAllF { (x: Int) =>
        IO(x).start.flatMap(_.join).map(res => assert(res == x))
      }

but it was not clear to me why the assert is needed there, actually in my case instead of the assert(res == x) I had a scalatest.Assertion and it kept asking me for an implicit IO[Assertion] => PropF[F] which i found very hard to do.

I solved it by using PropF.boolean but it took a while to discover that this is probably what i should use.

Now if I am not missing anything else, I think this would we much more intuitive:

PropF.forAllF( (a: Int) => IO(a == a))

with the help of

  implicit def effectOfBooleanToPropF[F[_]](
      fu: F[Boolean]
  )(implicit F: MonadError[F, Throwable]): PropF[F] = {
    val fb: F[PropF[F]] = F.map(fu) { a => PropF.boolean[F](a)}
    effectOfPropFToPropF(fb)
  }

then the user can map any F[A] to F[Boolean]
WDYT ?
If ok i can try a PR.

@mpilquist
Copy link
Member

mpilquist commented Nov 17, 2020

@adrian-salajan Apologies on the delay in response. I think supporting IO[Boolean] is a good idea. We currently support IO[Unit] so the original could have been .map(res => res shouldBe 42).void

@TonioGela
Copy link
Member

TonioGela commented Jun 20, 2024

A PR for this got merged, but I forgot to add the Closes #25 :
Also, this is a gentle request for a release, so that I can advocate this lib at work :D

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

3 participants