1

I am looking at this akka-http docs example (which links to akka-http test code):

Marshalling

This is actually a test from github code MarshalSpec.scala. My question is, where is the implicit Marshaller imported here? I am looking at imports, and I couldn't find it? I tried using IntelliJ to show me implicit imports, but I still couldn't figure this out. Where is the import statement that gets the implicit declaration for a Marshaller that is passed to:

  val entityFuture = Marshal(string).to[MessageEntity]

at line 21? It calls

def to[B](implicit m: Marshaller[A, B], ec: ExecutionContext): Future[B] =

in Marshal.scala and passes an implicit m: Marshaller, which I can't pinpoint.

1 Answers1

0

Marshaller extends PredefinedToEntityMarshallers , which provides marshalling from String.

But, why does Marshaller comes with its own implicits ? It's because scala search for implicits in the implicit scope of type arguments : Where does Scala look for implicits?

So, Marshaller comes with its own Marshallers ready to use :)

C4stor
  • 7,629
  • 4
  • 25
  • 43
  • Aaah, the companion object of the type!!! I forgot this and was trying to find it in the current scope. `object Marshaller extends GenericMarshallers with PredefinedToEntityMarshallers with PredefinedToResponseMarshallers with PredefinedToRequestMarshallers { .... ` – Ahmet Sevki Jul 12 '17 at 17:35