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

Streaming.take(n).toList shouldn't blow up when n+1 is an error #530

Merged
merged 4 commits into from
Sep 15, 2015

Conversation

ceedubs
Copy link
Contributor

@ceedubs ceedubs commented Sep 12, 2015

The Cons(a, lt.map(_.take(n - 1))) seems reasonable enough, but since toList calls lt.value, this blows up when lt is a deferred error.

@codecov-io
Copy link

Current coverage is 65.03%

Merging #530 into master will decrease coverage by -0.05% as of 710749b

@@            master    #530   diff @@
======================================
  Files          156     156       
  Stmts         2417    2417       
  Branches        67      68     +1
  Methods          0       0       
======================================
- Hit           1573    1572     -1
  Partial          0       0       
- Missed         844     845     +1

Review entire Coverage Diff as of 710749b

Powered by Codecov. Updated on successful CI builds.

case Cons(a, lt) => Cons(a, lt.map(_.take(n - 1)))
case Cons(a, lt) =>
if (n == 1) Cons(a, Now(Empty()))
else Cons(a, lt.map(_.take(n - 1)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe I'm too fussy, but could we rewrite that line?

Cons(a, if (n == 1) Now(Empty()) else lt.map(_.take(n - 1))

@non
Copy link
Contributor

non commented Sep 12, 2015

👍 (with-or-without my fussy suggestion honestly)

@non
Copy link
Contributor

non commented Sep 13, 2015

👍

@adelbertc
Copy link
Contributor

Merge conflicts. Also one nitpicky comment :-)

@@ -473,7 +473,8 @@ sealed abstract class Streaming[A] { lhs =>
if (n <= 0) Empty() else this match {
case Empty() => Empty()
case Wait(lt) => Wait(lt.map(_.take(n)))
case Cons(a, lt) => Cons(a, lt.map(_.take(n - 1)))
case Cons(a, lt) =>
Cons(a, if (n ==1) Now(Empty()) else lt.map(_.take(n - 1)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Eeeek, space between == and 1 :-)

@ceedubs
Copy link
Contributor Author

ceedubs commented Sep 15, 2015

@adelbertc thanks. Hopefully this should pass inspection now :)

@non
Copy link
Contributor

non commented Sep 15, 2015

👍

1 similar comment
@adelbertc
Copy link
Contributor

👍

adelbertc added a commit that referenced this pull request Sep 15, 2015
Streaming.take(n).toList shouldn't blow up when n+1 is an error
@adelbertc adelbertc merged commit 9848003 into typelevel:master Sep 15, 2015
@ceedubs ceedubs deleted the take-bomb branch November 15, 2015 23:39
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.

5 participants