Skip to content

Add ::: to NonEmptyList - #1949

Merged
kailuowang merged 5 commits into
typelevel:masterfrom
jcranky:master
Nov 2, 2017
Merged

Add ::: to NonEmptyList#1949
kailuowang merged 5 commits into
typelevel:masterfrom
jcranky:master

Conversation

@jcranky

@jcranky jcranky commented Oct 4, 2017

Copy link
Copy Markdown
Contributor

No description provided.

@codecov-io

codecov-io commented Oct 4, 2017

Copy link
Copy Markdown

Codecov Report

Merging #1949 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1949      +/-   ##
==========================================
+ Coverage   96.21%   96.21%   +<.01%     
==========================================
  Files         272      272              
  Lines        4627     4629       +2     
  Branches      124      119       -5     
==========================================
+ Hits         4452     4454       +2     
  Misses        175      175
Impacted Files Coverage Δ
core/src/main/scala/cats/data/NonEmptyVector.scala 100% <100%> (ø) ⬆️
core/src/main/scala/cats/data/NonEmptyList.scala 100% <100%> (ø) ⬆️
core/src/main/scala/cats/instances/map.scala 94.28% <0%> (-0.16%) ⬇️
core/src/main/scala/cats/Foldable.scala 100% <0%> (ø) ⬆️
core/src/main/scala/cats/data/Kleisli.scala 100% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8d7b394...d8b501d. Read the comment docs.

@kailuowang

Copy link
Copy Markdown
Contributor

if you want, you can add a doctest to make the test coverage happy.

def ::[AA >: A](a: AA): NonEmptyList[AA] =
NonEmptyList(a, head :: tail)

def :::[AA >: A](other: NonEmptyList[AA]): NonEmptyList[AA] =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually to maintain symmetry, can we add ++: to NonEmptyVector as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure :)

@jcranky

jcranky commented Oct 5, 2017

Copy link
Copy Markdown
Contributor Author

Regarding doctest, where should I look at? I new to the cats codebase.

@LukaJCB

LukaJCB commented Oct 5, 2017

Copy link
Copy Markdown
Member

Doc test is a test in the Scaladoc right above the method itself :) our build pipeline we automatically check if the result is the same.

An example can be found in NonEmptyVector#filter :)


/**
* Append this NEV to another NEV, producing a new `NonEmptyVector`.
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't these be the other way around? ++ for two NEVs and ++: for an NEV and a Vector?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure, I went with this #1838 (comment) - perhaps we should have both for both, since overloading is happening already anyway?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is to mimic the API in Vector and List. Let's address #1838 first

@jcranky

jcranky commented Oct 5, 2017

Copy link
Copy Markdown
Contributor Author

@LukaJCB thanks for the explanation on doc test, I'll have a look

@jcranky

jcranky commented Oct 5, 2017

Copy link
Copy Markdown
Contributor Author

Tests added. This doctest thing is really cool, can you point me to somewhere where I can understand better how it works? Thanks!

@LukaJCB

LukaJCB commented Oct 5, 2017

Copy link
Copy Markdown
Member

Check out sbt-doctest :)

@jcranky

jcranky commented Oct 5, 2017

Copy link
Copy Markdown
Contributor Author

@LukaJCB thanks!

@jcranky

jcranky commented Oct 6, 2017

Copy link
Copy Markdown
Contributor Author

In the meanwhile, please let me know if I should do something else here :)

@jcranky

jcranky commented Oct 18, 2017

Copy link
Copy Markdown
Contributor Author

I guess we can now merge this as well? :)

* res0: cats.data.NonEmptyList[Int] = NonEmptyList(1, 2, 3, 4, 5)
* }}}
*/
def :::[AA >: A](other: NonEmptyList[AA]): NonEmptyList[AA] =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shall we use concatNel here instead? concat is deprecated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sure

@jcranky

jcranky commented Oct 18, 2017

Copy link
Copy Markdown
Contributor Author

@kailuowang done

@jcranky

jcranky commented Oct 24, 2017

Copy link
Copy Markdown
Contributor Author

@kailuowang anything else I should do here ? :)

@kailuowang

kailuowang commented Oct 24, 2017

Copy link
Copy Markdown
Contributor

The build is broken in scala doc generation

/home/travis/build/typelevel/cats/core/src/main/scala/cats/data/NonEmptyList.scala:102: The link target "concat" is ambiguous. Several members fit the target

Instead of linking it using [[]], just use concat should be fine.

@jcranky

jcranky commented Oct 24, 2017

Copy link
Copy Markdown
Contributor Author

@kailuowang ok, my bad, I was blind and didn't see the build was broken. Fixed :)

@kailuowang

Copy link
Copy Markdown
Contributor

@jcranky no worries at all. i probably should've pointed it out earlier.

@jcranky

jcranky commented Oct 25, 2017

Copy link
Copy Markdown
Contributor Author

@kailuowang now the build is ok 👍 🗡️

@LukaJCB LukaJCB added this to the 1.0.0 milestone Nov 1, 2017
@kailuowang
kailuowang requested a review from tpolecat November 1, 2017 19:28
@tpolecat

tpolecat commented Nov 1, 2017

Copy link
Copy Markdown
Member

It's not obvious to me what the use case is here. a ::: b/a ++: b are always equivalent to a ++ b right?

@jcranky

jcranky commented Nov 2, 2017

Copy link
Copy Markdown
Contributor Author

@tpolecat my main reasoning for this was to keep symmetry with List. Plus, ++ / ++: are not there, or are they?

@jcranky

jcranky commented Nov 2, 2017

Copy link
Copy Markdown
Contributor Author

(I found myself using .toList a few times just to use :::)

@kailuowang

Copy link
Copy Markdown
Contributor

@tpolecat ++ was added to concat with List rather than NEL, for maintaining compatibility we didn't want to change that.

@tpolecat tpolecat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok, seems fine. 👍

@kailuowang
kailuowang merged commit 9912a8e into typelevel:master Nov 2, 2017
@jcranky

jcranky commented Nov 3, 2017

Copy link
Copy Markdown
Contributor Author

thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants