I am asking myself what would be the view bound equivalent to
(implicit conv: String => A)
My first attempt was to simply declare the type parameter A as follows:
[String <% A]
But the Scala compiler complains with "not found: type A".
Any suggestions?
That is not a view bound. A view bound says that a type parameter
Ais bounded in that it can be viewed (converted to) as a typeB. What you have inverted type and type parameter, so it doesn't qualify.To make things more clear, a bound is a limit on a "free" type -- a type parameter. For example:
So a view bound is also a limit -- one imposed through a very different mechanism. As such, it can only be imposed on a type parameter, not on a type.
Surely, saying
String => Amust exist is also a kind of bound, but not one that has a name or syntactic sugar for.