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 NonEmptySet #2143

Merged
merged 12 commits into from
Mar 14, 2018
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions core/src/main/scala/cats/data/Newtype.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package cats
package data

trait Newtype { self =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add some documentation that motivates this trait?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, good idea :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense for this to be a public trait if Base and Tag are both private[data]?

Copy link
Member Author

Choose a reason for hiding this comment

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

Debatable IMO, but to me those two are implementation details, you're never actually going to want to access these, no?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh right I guess that in order to create your own type that uses Newtype you don't actually have to set Base and Tag, right?

I guess I'm partially hesitant to expose Newtype publicly because there are a lot of approaches to newtypes in the scala world and I'm not sure whether we want to take on the burden of keeping this one around and stable in cats. Especially since it's an internal implementation detail that isn't really used as an abstraction and is trivial enough that people could easily copy/paste it if they wanted it. I'd be inclined to make it private for now and if it works out well and people want it to be exposed publicly it's easier to open it up later than to make it private later. Admittedly I'm sometimes overly paranoid about this sort of thing...

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd be okay with making them private :)

private[data] type Base
private[data] trait Tag extends Any
type Type[A] <: Base with Tag
}
Loading