DmytroMitin / AUXify

Introduces macro/meta annotations @ aux, @ self, @ instance, @ apply, @ delegated, @ syntax and String-based type class LabelledGeneric
Apache License 2.0
28 stars 3 forks source link

Support extends DepFn1[C] #30

Open DmytroMitin opened 5 years ago

DmytroMitin commented 5 years ago
  /*@aux*/ @instance /*@delegated*/
  trait FlattenAndDeduplicate[C <: Coproduct] extends DepFn1[C]{
    type Out <: Coproduct
//    def apply(t: C): Out
  }
  object FlattenAndDeduplicate {
    type Aux[C <: Coproduct, Out0 <: Coproduct] = FlattenAndDeduplicate[C] { type Out = Out0 }
//    def instance[C <: Coproduct, Out0 <: Coproduct](f: C => Out0): Aux[C, Out0] = new FlattenAndDeduplicate[C] {
//      override type Out = Out0
//      override def apply(t: C): Out0 = f(t)
//    }

    object identityPoly extends Poly1 {
      implicit def identityCase[A]: Case.Aux[A, A] = at(identity)
    }

    implicit def mkFlattenAndDeduplicate[C <: Coproduct, C_flatten <: Coproduct](implicit
      flatMap: FlatMap.Aux[C, identityPoly.type, C_flatten],
      dedup: Deduplicate[C_flatten],
    ): Aux[C, dedup.Out] = instance(c => dedup(flatMap(c)))
  }
Error:(53, 39) no arguments allowed for nullary method instance: ()App165.FlattenAndDeduplicate[C]{type Out = Out0$macro$1}
    ): Aux[C, dedup.Out] = instance(c => dedup(flatMap(c)))