typelevel / typelevel/scalacheck-effect
Support effect of boolean
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 83
- Forks
- 26
- Avg merge
- 4h 49m
- Merged PRs (30d)
- 4
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the examples in this issue and the existing PropF.boolean and effectOfPropFToPropF APIs. Check how an F[Boolean] is currently converted into a property and whether an implicit conversion fits the library's design. Done means the proposed forAllF usage typechecks and is covered by tests, with the conversion behavior documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100