In the following example
val concat = "right".narrow
def extract[s <: String](x: s)(implicit witness: Witness.Aux[s]): String = witness.value
Error: could not find implicit value for parameter
This is a failure of type inference ... you'll find that,
will work as you expect.
That's not particularly helpful, as I imagine you want to infer the singleton type from the value argument to
extract. shapeless provides an implicit conversion to
Witness types, so the following might work in your context,
def extract(witness: Witness.Lt[String]): String = witness.value
This will accept both literal
Strings and narrowed values.