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 Lazy data and Delay type class #1993

Open
wants to merge 3 commits into
base: series/8.0.x
Choose a base branch
from

Conversation

edmundnoble
Copy link
Contributor

Tests incoming.

I believe this is the beginning of a way to solve the lazy type classes problem in Scala.

@emilypi
Copy link
Contributor

emilypi commented Sep 22, 2018

Could you give a little background as to why this is needed?

@edmundnoble
Copy link
Contributor Author

Sure, will do tomorrow.

@jbgi
Copy link
Member

jbgi commented Sep 22, 2018

I worked on a similar Thunkable type class last year but did not have time to submit a PR. This where I left off: jbgi@7c116ec
The idea was, whenever possible, scalaz data types would come with a lazy constructor of type (=>A) => A.

@Milyardo
Copy link
Contributor

Should there be a law that says delay(() => a) == a?

@edmundnoble
Copy link
Contributor Author

@Milyardo We could have that, though what makes for == would have to not include the semantics of evaluating "whatever's inside" a.

Copy link
Member

@hrhino hrhino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to not include the semantics of evaluating "whatever's inside" a.

why not?


import tc._

class Lazy[A](val run: () => A) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final?

/**
* Given `Delay[A]`, one can suspend execution of an `A` inside of the `A` itself.
*/
trait DelayClass[A] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so what's a good use case for Delay?

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

Successfully merging this pull request may close these issues.

None yet

6 participants