type ConvertibleTo[A] = concept x
convert(x) is A
proc convert(x: int): string = $x
echo 5 is ConvertibleTo[string] # true
Now, I want to define a function that takes a ConvertibleTo[A], where A is left generic. I would like to do something like the following, but it does not work
proc printAs[A, B: ConvertibleTo[A]](x: B) =
echo $(convert(x))
printAs[string, int](5)
The Nim compiler complains that A in the type signature is not a known identifier.
Similar issues can arise when using static[T]. One may want to have a signature such as
proc foo[A, X: static[A]](...)
Again, the A identifier in static[A] is unbound.
Does anyone know how to work around this limitation? Is it something that will eventually be valid?