Skip to content

Support effect of boolean #25

@adrian-2414745

Description

@adrian-2414745

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions