On 1/31/17 9:04 AM, Hugo Ferreira
wrote:

Anyway here is the solution:

Change :

case class ParameterRange[ P[_] <: Parameter[T], T, U ](

to

class
ParameterRange[ P[X] <: Parameter[X], T, U ](

which leads me to another questions. Why don't we have to
declare X?

`P[X] <: Parameter[X]` means

`P: * -> *`, such
that

*for all* *X*: *,

`P[`*X*] <:
Parameter[*X*]. So there is no

*specific* `X`
to talk about; you are making a claim that is quantified over

`X`,
so the variable

`X` is bound by the expression

`P[X]`
itself. So it

*is* declared! :)

Your old variant meant

`P: * -> *` such that

*for all*
*E*: *,

`P[`*E*] <: Parameter[T]
(where

`T` is the later type parameter). (This is a
restatement of the actual bound,

`(P[E] forSome {type E}) <:
Parameter[T]`.) This was a claim about a

*specific* `T`,
bound outside the expression. Note specifically that

`Parameter`'s
type parameter and

`P`'s type parameter are not related at
all.

Given

trait Disconnect[A] extends Parameter[Int]

Under your original declaration,

`ParameterRange[Disconnect, Int,
Int]` is well-kinded, and in the body of

`ParameterRange`,

`P[String] <: Parameter[T]`; I imagine neither of these
behaviors seem correct to you, and both are corrected by your new
form.

The original error was probably that

`Parameter` itself did
not conform to the bounds declared for

`P`, and there was no
way to infer

`T`.

It's not common to declare

`X` when not writing a bound,
because these bounds are relatively rare, and so it's just extra
noise when all you're trying to do is declare a higher-kinded type.
I also imagine 99% of folks saw the

`_` form as their first

*n* examples of HKTs, for some large

*n*, and copied the
style.

--

Stephen Compall

--

You received this message because you are subscribed to the Google Groups "scala-user" 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.