How about a "case trait"?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How about a "case trait"?

Owen-2
Where
 
case trait A

would desugar to

trait A extends Product with Serializable

This would mitigate the problem of Scala inferring a superfluous "Product with Serializable" for the result of methods that return case classes, for example Left and Right.

--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How about a "case trait"?

ARKBAN

+1 if it gives you .copy() for the common fields... although that might require a definition something like this:

case trait A( field: String, ... )

ARKBAN

On 10/11/16 1:01 PM, Owen wrote:
Where
 
case trait A

would desugar to

trait A extends Product with Serializable

This would mitigate the problem of Scala inferring a superfluous "Product with Serializable" for the result of methods that return case classes, for example Left and Right.
--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How about a "case trait"?

Daniel Armak
You would need a cooperation protocol for equals/hashCode and copy() when several such case traits, and maybe a case class, are mixed together.

Daniel Armak

On Tue, Oct 11, 2016 at 8:05 PM, ARKBAN <[hidden email]> wrote:

+1 if it gives you .copy() for the common fields... although that might require a definition something like this:

case trait A( field: String, ... )

ARKBAN


On 10/11/16 1:01 PM, Owen wrote:
Where
 
case trait A

would desugar to

trait A extends Product with Serializable

This would mitigate the problem of Scala inferring a superfluous "Product with Serializable" for the result of methods that return case classes, for example Left and Right.
--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.