- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
use abstract type member as type parameter of inherited trait
Thu, 2011-12-01, 16:34
Hello,
I am trying to use an abstract type member as type parameter of an
inherited trait. Any hint on how to do this appreciated.
trait A extends Ordering[B] { type B } // error: not found: type B
As I understand, it may have to do with early type members, which are
not implemented. Can we do without ?
Thanks !
Raphael
Sat, 2011-12-03, 13:57
#2
Re: use abstract type member as type parameter of inherited trai
Raphael Jolly wrote:
> Hello,
>
> I am trying to use an abstract type member as type parameter of an
> inherited trait. Any hint on how to do this appreciated.
>
> trait A extends Ordering[B] { type B } // error: not found: type B
>
> As I understand, it may have to do with early type members, which are
> not implemented.
I was referring to:
From: Adriaan Moors
Subject: Re: type parameter vs type members
Newsgroups: gmane.comp.lang.scala.user
Date: 2010-08-18
http://article.gmane.org/gmane.comp.lang.scala.user/30125
"as type members are implemented now, yes (at one point early type
members were considered, but they were never implemented -- they would
close the gap between parameters and members completely)"
Any info on these early type members ? Thanks !
Raphael
Sat, 2011-12-03, 15:47
#3
Re: Re: use abstract type member as type parameter of inherited
Adriaan could speak better for this, but I think this might be referring to the dependent object types research he was working on.
On Sat, Dec 3, 2011 at 7:50 AM, Raphael Jolly <raphael.jolly@free.fr> wrote:
On Sat, Dec 3, 2011 at 7:50 AM, Raphael Jolly <raphael.jolly@free.fr> wrote:
Raphael Jolly wrote:
Hello,
I am trying to use an abstract type member as type parameter of an inherited trait. Any hint on how to do this appreciated.
trait A extends Ordering[B] { type B } // error: not found: type B
As I understand, it may have to do with early type members, which are not implemented.
I was referring to:
From: Adriaan Moors
Subject: Re: type parameter vs type members
Newsgroups: gmane.comp.lang.scala.user
Date: 2010-08-18
http://article.gmane.org/gmane.comp.lang.scala.user/30125
"as type members are implemented now, yes (at one point early type members were considered, but they were never implemented -- they would close the gap between parameters and members completely)"
Any info on these early type members ? Thanks !
Raphael
trait A[B] extends Ordering[B]
You have the option of delegation:
trait A { type B def ordering: Ordering[B]}
*or* you alter the parent class (not applicable for Ordering)
trait A { type Abstract }
trait B extends A { type Abstract = Abstract2 // Not really needed, you can just drop Abstract2 and have an abstract type. type Abstract2}
On Thu, Dec 1, 2011 at 10:30 AM, Raphael Jolly <raphael.jolly@free.fr> wrote: