-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Consider adding some form of newtypes to cats #1800
Comments
|
Maybe we should wait out this: http://docs.scala-lang.org/sips/opaque-types.html |
Options that I see so far.
|
I am okay with either 3 or 4. |
I prefer 3. I'm not really okay with 4 myself. I think we're going to get stuck with a lot of things we don't want to be stuck with if we wait that long. |
I prefer 4 since we are in the midst of this currently unfolding. Also, can we have some concrete proposals of where we want newtype in cats? For things like I don't want to complicate things, nor consider dropping 2.10, if we don't have a concrete win to look at. I added this in gitter:
|
For context, the use cases for newtype in in cats that I noticed recently.
|
To add to those, we also have |
I think I can try for a stab at the use-cases we have in addition to the ones presented so far. Type class disambiguation
Zero-overhead data types
|
@LukaJCB I am curious if you still plan to do the benchmark? |
I haven't made a lot of progress yet. Tried for about an hour last weekend, but ran into some errors with JMH in combination with @alexknvl newtypes library, will have to do more research on that |
Given the scope mentioned above, and the fact that the new type mechanism in Scala doesn't seem to be stable yet, also once the opaque type is out, we probably have to change it again. Now I incline to not include it in Cats 1.0 and lock it down. Users can choose their own new type lib for now. Cats internal usage of new type might be easier to manage (IRT to backward compat) if we keep the new type mechanism also internal. |
I agree this is premature for cats 1.0. |
I would like to reopen this discussion :) I'll also try to get those benchmarks I promised a long time ago, to see what we can gain here :) |
It might be me, a macro based solution can probably support cross build. It could be internal to cats or since cross building new type would be very commonly used, cats can depend on https://github.com/estatico/scala-newtype and help support it. |
I like the idea! I'm not super sure how stable that project is, but I've used it a lot and had only good experiences so far 👍 |
I did those benchmarks for a very simple
Full code here: I can imagine results being even more dramatic when using nested Monad transformers. |
This will be a good reason to go cats 3.0 (assuming 2.x maintains BC on Scala 2.12). Do we know the timeline of adding opaque type to 2.13? |
IIRC, the timeline is Q3 for 2.13.0 and Q4 for 2.13.1 and I think Opaque types will be in the 2.13.1 version (it turned out to be harder to implement than originally thought) On another note, do we think we'll release cats 2.0 and 3.0 at the same time? |
@carymrobbins What do you think of the idea of having cats depend on |
@LukaJCB I like it! Do you think cats will look to use mostly the annotation macros (
Let me know what you think. Also, feel free to adjust the above points if either I'm over/underthinking things. |
I think we'll primarily use |
If we go with the option 1 in this roadmap, this will be Cats 3.0 right? |
Right, yeah it depends on how we handle our next release. :) |
@LukaJCB Good evening. I have been sweeping a bit through old issues of |
I think we should consider Cats 3.0 for Scala 3 using opaque types |
Yep, I think we can close this one. Anyone who needs something for Scala 2 can look at https://github.com/monix/newtypes. |
We have https://github.com/alexknvl/newtypes, but we could also look at other options :)
The text was updated successfully, but these errors were encountered: