Your problem is that even if the data of the form A <:< B implies that a value of type A can be converted to a value of type B , this does not mean A <: B ... indeed, the main reason for using a type constraint or view binding, but not a limitation of the usual type, it lies precisely in the fact that such a subtype relation is not satisfied.
Therefore, the restriction in StateY , Repr <:< State[Repr] not enough to perform the evaluation of Repr <: State[Repr] using the Observer apply method. Given that you want to reduce the constraint on a parameter of type StateX , the only option is to relax the constraint on a parameter of type of the apply method, respectively. This gives you something like the following, using view binding instead of the usual type binding,
object Observer { def apply[Repr <% State[Repr]](reader : Reader[Repr]) : Observer[Repr] = new Observer[Repr] {} }
or alternatively
object Observer { def apply[Repr](reader : Reader[Repr]) (implicit ev : Repr <:< State[Repr]) : Observer[Repr] = new Observer[Repr] {} }
if you prefer to use restrictions in everything.
source share