This page is no longer maintained — Please continue to the home page at www.scala-lang.org

use abstract type member as type parameter of inherited trait

3 replies
Raphael Jolly
Joined: 2009-02-27,
User offline. Last seen 1 year 27 weeks ago.

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

Joshua.Suereth
Joined: 2008-09-02,
User offline. Last seen 32 weeks 5 days ago.
Re: use abstract type member as type parameter of inherited tra
If Ordering takes a type parameter, you *have* to use a type parameter:
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:
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


Raphael Jolly
Joined: 2009-02-27,
User offline. Last seen 1 year 27 weeks ago.
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

Joshua.Suereth
Joined: 2008-09-02,
User offline. Last seen 32 weeks 5 days ago.
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:
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


Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland