Hey!
I have a pretty usual Selectable
trait implementation and an associated macro to create it:
trait Record extends Selectable:
type In
type Members <: NonEmptyTuple
val all: Members
def selectDynamic(s: String) =
all.toList.find(_.toString.contains(s)).get
object Record:
transparent inline def build[In] = ???
I then want to pass the resulting type to another class:
class Wrapper[R](record: R):
def process(f: R => Output): Result =
known.implementation.using(f(record))
But the problem is that if I instantiate the record and assign it to value:
transparent inline def wrap =
val record = Record.build[T]
new Wrapper(r)
…I’m losing most of type info. It becomes something like:
val res0: Record{type In; type Members} = anon$1@16ef1160
…which is effectively useless in my process
HOF. Without assignment it gives me a working selectable:
transparent inline def wrap = Record.build[T] // No assignment
wrap
val res0: Record {
type In = Insert[?, ?, Foo];
type Members = Tuple2[Insert["first_name", String, Foo], Insert["age", Int, Foo]]
} & Record {
val first_name: Insert["first_name", String, Foo];
val age: Insert["age", Int, Foo]
} = anon$1@16ef1160
I guess my questions are:
- Is it possible to preserve the full type info inside a function?
- Is there a working way to make my
Wrapper.process
a typed function?