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

Pull up laws #69

Merged
merged 4 commits into from Jul 7, 2017
Merged

Pull up laws #69

merged 4 commits into from Jul 7, 2017

Conversation

djspiewak
Copy link
Member

Fixes #52

Moves stack-safety laws up into SyncLaws, as well as some of the error propagation laws. Also adds a law which stipulates that errors in the runAsync handler effect must be discarded (previously this was unspecified).

I had to remove the Async[Kleisli[F, R, ?]] instance with the laws moving up, because Kleisli is stack-unsafe on left-associated binds (see: typelevel/cats#1733). This is a shame, but not entirely unexpected.

@codecov-io
Copy link

codecov-io commented Jun 18, 2017

Codecov Report

Merging #69 into master will increase coverage by 0.32%.
The diff coverage is 93.1%.

@@            Coverage Diff             @@
##           master      #69      +/-   ##
==========================================
+ Coverage   84.59%   84.91%   +0.32%     
==========================================
  Files          18       18              
  Lines         370      358      -12     
  Branches       22       20       -2     
==========================================
- Hits          313      304       -9     
+ Misses         57       54       -3

@djspiewak
Copy link
Member Author

Can one of the maintainers review this? @alexandru @mpilquist @pchlupacek @rossabaker @tpolecat

Copy link
Member

@alexandru alexandru left a comment

Choose a reason for hiding this comment

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

Looks good.

"repeated sync evaluation not memoized" -> forAll(laws.repeatedSyncEvaluationNotMemoized[A] _),
"propagate errors through bind (suspend)" -> forAll(laws.propagateErrorsThroughBindSuspend[A] _))

val jvmProps = Seq(
Copy link
Member

Choose a reason for hiding this comment

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

Running stack safety tests on top of Javascript is still valuable and what I'd do here is to use a different count, e.g. 1000 instead of 10000 binds.

This is because we might end up with projects implementing Sync that don't care about the JVM at all.

Copy link
Member Author

Choose a reason for hiding this comment

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

What would be the best way to empirically determine the appropriate count?

Copy link
Member

Choose a reason for hiding this comment

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

I have no idea; basically you pick a value, then see if the tests run in a reasonable amount of time for cats.effect.IO.

Copy link
Member

Choose a reason for hiding this comment

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

I would set it to 1000. It's better than nothing and should be manageable on top of Node.js

Copy link
Member Author

Choose a reason for hiding this comment

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

In the interest of not stalling this on the petard of my lack of time, I'm going to merge this PR and open a new issue for reenabling the stack safety tests on JS with lower limits.

Choose a reason for hiding this comment

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

The threshold for stack-safety is in my experience closer to 70000 function compositions than 10000, let alone 1000. That's what every cats stack-safety test uses. Does this test fail as is with a stack-unsafe monad?

Copy link
Member

Choose a reason for hiding this comment

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

I've seen tests fail for a stack depth of 1000, because it's usually multiplied by whatever else you're doing for each of those frames.

But indeed the number is chosen arbitrarily.

We should do a quick / simple Thunk-based implementation and measure with that.

Copy link
Member Author

Choose a reason for hiding this comment

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

@edmundnoble It does fail as it is with a stack-unsafe monad. I think it's just because there are more stack frames floating around. Or maybe it's just because my machine is allocating less stack space. Either way, it did seem to be pretty consistent when I was playing with it.

Choose a reason for hiding this comment

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

Alright nice, thanks :) I bet we could cut it down for cats too.

@djspiewak djspiewak merged commit 09e64a7 into typelevel:master Jul 7, 2017
@djspiewak djspiewak deleted the feature/pull-up-laws branch July 7, 2017 09:15
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

Successfully merging this pull request may close these issues.

None yet

4 participants