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 an applicative notation for generators #73

Closed
etorreborre opened this issue Nov 7, 2013 · 2 comments
Closed

Add an applicative notation for generators #73

etorreborre opened this issue Nov 7, 2013 · 2 comments

Comments

@etorreborre
Copy link
Contributor

The for/yield notation can be used with generators because they are monads, but I sometimes wish a more concise notation when just applicatives are needed (because generators are independent):

Contrast:

case class Time(hour: Int, minute: Int)

for {
  hour <- Gen.choose(0, 23)
  minute <- Gen.choose(0, 59)
} yield Time(hour, minute)

with (using the scalaz syntax)

(Gen.choose(0, 23) |@| Gen.choose(0, 59))(Time)
@tonymorris
Copy link
Contributor

On 08/11/13 09:41, Eric Torreborre wrote:

The |for/yield| notation can be used with generators because they are
monads, but I sometimes wish a more concise notation when just
applicatives are needed (because generators are independent):

Contrast:

case class Time(hour: Int, minute: Int)

for {
hour <- Gen.choose(0, 23)
minute <- Gen.choose(0, 59)
} yield Time(hour, minute)

with (using the scalaz syntax)

(Gen.choose(0, 23) |@| Gen.choose(0, 59))(Time)


Reply to this email directly or view it on GitHub
#73.

There is the scalaz-scalacheck module that will give you this.

@etorreborre
Copy link
Contributor Author

You're right @tonymorris I should just do that.

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

2 participants