propensive / contextual

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

How does type embedding work? #46

Closed xylo closed 3 years ago

xylo commented 5 years ago

I really like to use your lib to do syntax checks on SQL/HQL queries. However, my queries are not pure strings, but rather interpolated strings with parameters, e.g.:

val id = 1
val query = q"from User where id = $id"

Would that be possible with contextual? Is there any working example for such an interpolated string with arguments? So far I could only find the section Embedded Types on https://propensive.com/opensource/contextual/#a-simple-example, but that's only very few information about how this works, and the example is unfortunately incomplete. A complete example would already help a lot.

xylo commented 5 years ago

Alternatively you could also give an example how to convert a normal Scala string interpolation into a contextual string interpolation. That would be great.