propensive / contextual

Statically-checked string interpolation in Scala
https://soundness.dev/contextual/
251 stars 23 forks source link

allow running a validation phase with a compiletime type #34

Closed fommil closed 6 years ago

fommil commented 7 years ago

I have the usecase where we are using contextual to generate "keys" for a nested logging framework. We are using contextual to ensure that the keys are alphanumeric.

We also have generic derivation of ADTs, e.g. to generate the keys from the case class fields.

However, although we have the fields of the case classes, we can't currently run the contextualize validation phase on those keys so we are falling back to hacks :sob: (e.g. runtime exceptions)

It would be good to be able to pass a Name <: Symbol through a contextualize validation phase so we can get a compilation failure if a field that is invalid. No interpolation is needed, it's just a String that we're validating.