« Return to Thread: [scala] is this a bug?

Re: [scala] Re: is this a bug?

by nuttycom :: Rate this Message:

Reply to Author | View in Thread

On Thu, Jun 25, 2009 at 3:17 PM, Jesper Nordenberg<megagurka@...> wrote:

> Meredith Gregory wrote:
>>
>> All,
>>
>> Here is a little codesnippet <http://paste.pocoo.org/show/125132/>.
>> Everything is fine up to the last decl. That generates the following
>> compiler error.
>
> Can't say I fully understand higher kinded types. A little example
> influenced by your code:
>
> trait T[A[_] <: T[A, B], B]
> trait T2[B] extends T[T2, B]
>
> This is valid Scala code, but what does it mean? I can see two
> possibilities:
>
> - There exists a C for which "T2[C] <: T[T2, B]" holds, which obviously is
> true if C = B. But how is this even useful?

That's essentially my take too - that having the parameterized type of
A be unconstrained is essentially useless except in the case where C =
B.

So why not define it as:

trait T[B, A[B] <: T[B, A]]

In this case, the dependency between the container type and the
contained type is strictly constrained. I'm not sure if this
restriction is overly narrow for his purposes, but at least within an
instance of the trait you can safely refer to the type of the
implementing class A[B]. An example of how this might play out in his
code is http://paste.pocoo.org/show/125150/

What am I missing here?

Kris

> - For all C "T2[C] <: T[T2, B]" must hold, which clearly is not true and
> would indicate a compiler bug.
>
> /Jesper Nordenberg
>
>

 « Return to Thread: [scala] is this a bug?