title: Auto-Inferring a higher-kinded Aux Parameter from an Argument
body: <p>On an earlier SO post I asked how to create use the Aux pattern with a higher kinded type (<a href="https://stackoverflow.com/questions/55411471/summon-aux-for-higher-kinded-type-without-reference-to-the-original">here</a>, that had a great reply!). Now based on the reply, I am trying to take the abstraction a little but further and have the actual generic parameter be inferred from an argument's type. Trouble is, it seems having trouble differentiating <code>X</code> from <code>X.type</code>. Here's my code:</p>
  
  <pre><code>// The are types that I want to convert to various things
  sealed trait ConversionType
  trait CaseA extends ConversionType
  object CaseA extends CaseA // In this case, convert to an optional
  trait CaseB extends ConversionType
  object CaseB extends CaseB // In this case, convert to a future etc...
  
  trait Converter[Prefix] {
    type Paramd[_]
    def create[N](n:N): Paramd[N]
  }
  
  // Create the mechanism to convert from the cases, only doing case A for now...
  object Converter {
    type Aux[Prefix, Ret[_]] = Converter[Prefix] { type Paramd[N] = Ret[N] }
  
    // Shouldn't `Prefix` be automatically inferred?
    def apply[Prefix](prefix:Prefix)(implicit p:Converter[Prefix]): Aux[Prefix, p.Paramd] = p
  
    implicit def makeOptionParamd: Aux[CaseA, Option] =
      new Converter[CaseA] {
        type Paramd[N] = Option[N]
        override def create[N](n:N): Paramd[N] = Option[N](n)
      }
  }
  
  // This works
  val v = Converter.apply[CaseA](CaseA).create("test")
  // **** This breaks! Why? ****
  val vv = Converter.apply(CaseA).create("test")
  </code></pre>
  
  <p>The following errors occour on the broken line above:</p>
  
  <pre><code>Error:(135, 29) could not find implicit value for parameter p: Test.this.Converter[Test.this.CaseA.type]
      val vv = Converter.apply(CaseA).create("test")
  
  Error:(135, 29) not enough arguments for method apply: (implicit p: Test.this.Converter[SchemaMaker.this.CaseA.type])Test.this.Converter.Aux[SchemaMaker.this.CaseA.type,p.Paramd] in object Converter.
  Unspecified value parameter p.
      val vv = Converter.apply(CaseA).create("test")
  </code></pre>
  
  <p>So the compiler doesn't connect the dots between the object <code>CaseA</code> and the type <code>CaseA</code>? Is there any way to fix this?</p>