Scala 3 primitives for typelevel and meta programming?

Since Scala 3 will eliminate whitebox macros, there is a need for an alternative mechanism that effectively computes new types. Over the last months, we have looked into possible candidates. We don’t have a conclusion yet, but the current state of discussion is summarized here



May be it is possible to have the ability to define return types for methods of Dynamic

    for (rs <- new ASelect {
      //We want that there will be no need to define columns
      val id = asNLong("id")
      val city = asString("city")
      //next 50 columns :)) 

           select a.address_id AS id , from address a
             where a.address_id =$idp
    }) {

We can make

ASelect  extends Dynamic

But it has no sense if we do not know the return type of such methods like ‘id’ and ‘city’.

I will be glad to write

ASelect ("""
           select a.address_id AS id , from address a
             where a.address_id =$idp


ASelect ("""
           select a.address_id AS id , from address a
             where a.address_id =$idp
      //and hide it with idea plugin :))

I’m a bit disappointed that refinement types are a low priority. They don’t strike me as a particularly esoteric feature. To be able to compile time check that a value is in the correct subset of the unrefined type’s values.

if there are not common solution, would it be better to use plain java interfaces to enject anonymous types?
I think such decision has several advantages:

  • it completely separate declaration from implementation, so implementation can be made later
  • interfaces can be generated\processed at any time.
  • interfaces can be processed by any jvm tools(asm for example)

May be, such approach more difficult to write extension.
But, Ide will be able to support it more easily(it is only declaration)
And it will be much better than nothing.

AFAIK anonymous/structural types aren’t going anywhere. Whitebox macros served a different purpose - perform arbitrary compile-time code that can generate an expression with a type that’s determined by the macro itself, not known before the call. This has enabled type system extensions and programs that are impossible or too costly to do with implicits.

Sorry, if it is obviously.
How currently anonymous/structural types can be injected in scala 3, without whitebox macros?

It is clear.
For me it will be enough if it works only for string interpolation.
Of course whitebox macros is better. But it is better than nothing.

It seems whitebox macros is going off
So, I just do not know how I can implement sqlj in scala3 now. We every day do some unwanted work and we can’t use white box macros because

  • it has bad IDE support
  • it is going off

And scala just cannot replace sql in some area.
The sql dsl will be always more bad. It will never be supported such IDE like dbeaver.
I can only hope that the situation will change.

We had had a hope that one day whitebox macros would not be experimental it would have good ide support and so on.
We have waited for

It’s ironic. :slight_smile: