milessabin/shapeless — comment on commit 447aae489dd1b7b47fc2d7cc027ca73844a76550
File: src/main/scala/shapeless/poly.scala line 72
By retronym:

Hmmm. So I tried the obvious thing first:

```
trait Poly {
/** The type of the case representing this polymorphic value at type `T`. */
type Case0[T] = Case0Aux[this.type, T]

/** The type of the case representing this polymorphic unary function at argument type `T`. */
type Case1[T] = Case1Aux[this.type, T]

/** The type of the case representing this polymorphic binary function at argument types `T` and `U`. */
type Case2[T, U] = Case2Aux[this.type, T, U]

type U <: Any

/** Creates an instance of the case representing this polymorphic value at type `T`. */
def case0[T](v : T) = new Case0[T] {
val value = v
}

/** Creates an instance of the case representing this polymorphic unary function at argument type `T`. */
def case1[T] = new {
def apply[R0 <: U](f : T => R0) = new Case1[T] {
type R = R0
val value = f
}
}
}

object toDouble extends Poly {
type U = Double
implicit def caseInt = case1[Int](_.toDouble)
implicit def caseDouble = case1[Double](x => x)
}
```

So far, so good, it won't allow non-double returning cases.

But leave U unspecified and:

```
[error] C:\code\analytics\analytics-core\src\main\scala\com\efgfp\analytics\core\method\PricingRequest.scala:106: inferred type arguments [Double] do not conform to method apply's type parameter bounds [R0 <: com.efgfp.analytics.core.method.toDouble.U]
[error] implicit def caseInt = case1[Int](_.toDouble)
```

It's a bit awkward. How about providing two versions?

```
trait PolyFixedReturn[R] extends Poly { type U = R }
trait PolyVariableReturn extends Poly { type U = Any }
```