All Downloads are FREE. Search and download functionalities are using the official Maven repository.

harness.core.Zip.scala Maven / Gradle / Ivy

package harness.core

trait Zip[In1, In2] {
  type Out

  def zip(in1: In1, in2: In2): Out
  def unzip(out: Out): (In1, In2)
}
object Zip extends ZipLowPriority1 {

  type Out[In1, In2, O] = Zip[In1, In2] { type Out = O }

  def apply[In1, In2](implicit zip: Zip[In1, In2]): Zip[In1, In2] = zip

  implicit def zipLeftId[_1]: Zip.Out[Unit, _1, _1] =
    new Zip[Unit, _1] {
      override type Out = _1
      override def zip(in1: Unit, in2: _1): _1 = in2
      override def unzip(out: _1): (Unit, _1) = ((), out)
    }

}

trait ZipLowPriority1 extends ZipLowPriority2 {

  implicit def zipRightId[_1]: Zip.Out[_1, Unit, _1] =
    new Zip[_1, Unit] {
      override type Out = _1
      override def zip(in1: _1, in2: Unit): _1 = in1
      override def unzip(out: _1): (_1, Unit) = (out, ())
    }

}

trait ZipLowPriority2 extends ZipLowPriority3 {

  // format: off

  implicit def zip3[_1, _2, _3]: Zip.Out[(_1, _2), _3, (_1, _2, _3)] =
    new Zip[(_1, _2), _3] {
      override type Out = (_1, _2, _3)
      override def zip(in1: (_1, _2), in2: _3): Out = (in1._1, in1._2, in2)
      override def unzip(out: Out): ((_1, _2), _3) = ((out._1, out._2), out._3)
    }

  implicit def zip4[_1, _2, _3, _4]: Zip.Out[(_1, _2, _3), _4, (_1, _2, _3, _4)] =
    new Zip[(_1, _2, _3), _4] {
      override type Out = (_1, _2, _3, _4)
      override def zip(in1: (_1, _2, _3), in2: _4): Out = (in1._1, in1._2, in1._3, in2)
      override def unzip(out: Out): ((_1, _2, _3), _4) = ((out._1, out._2, out._3), out._4)
    }

  implicit def zip5[_1, _2, _3, _4, _5]: Zip.Out[(_1, _2, _3, _4), _5, (_1, _2, _3, _4, _5)] =
    new Zip[(_1, _2, _3, _4), _5] {
      override type Out = (_1, _2, _3, _4, _5)
      override def zip(in1: (_1, _2, _3, _4), in2: _5): Out = (in1._1, in1._2, in1._3, in1._4, in2)
      override def unzip(out: Out): ((_1, _2, _3, _4), _5) = ((out._1, out._2, out._3, out._4), out._5)
    }

  implicit def zip6[_1, _2, _3, _4, _5, _6]: Zip.Out[(_1, _2, _3, _4, _5), _6, (_1, _2, _3, _4, _5, _6)] =
    new Zip[(_1, _2, _3, _4, _5), _6] {
      override type Out = (_1, _2, _3, _4, _5, _6)
      override def zip(in1: (_1, _2, _3, _4, _5), in2: _6): Out = (in1._1, in1._2, in1._3, in1._4, in1._5, in2)
      override def unzip(out: Out): ((_1, _2, _3, _4, _5), _6) = ((out._1, out._2, out._3, out._4, out._5), out._6)
    }

  implicit def zip7[_1, _2, _3, _4, _5, _6, _7]: Zip.Out[(_1, _2, _3, _4, _5, _6), _7, (_1, _2, _3, _4, _5, _6, _7)] =
    new Zip[(_1, _2, _3, _4, _5, _6), _7] {
      override type Out = (_1, _2, _3, _4, _5, _6, _7)
      override def zip(in1: (_1, _2, _3, _4, _5, _6), in2: _7): Out = (in1._1, in1._2, in1._3, in1._4, in1._5, in1._6, in2)
      override def unzip(out: Out): ((_1, _2, _3, _4, _5, _6), _7) = ((out._1, out._2, out._3, out._4, out._5, out._6), out._7)
    }

  implicit def zip8[_1, _2, _3, _4, _5, _6, _7, _8]: Zip.Out[(_1, _2, _3, _4, _5, _6, _7), _8, (_1, _2, _3, _4, _5, _6, _7, _8)] =
    new Zip[(_1, _2, _3, _4, _5, _6, _7), _8] {
      override type Out = (_1, _2, _3, _4, _5, _6, _7, _8)
      override def zip(in1: (_1, _2, _3, _4, _5, _6, _7), in2: _8): Out = (in1._1, in1._2, in1._3, in1._4, in1._5, in1._6, in1._7, in2)
      override def unzip(out: Out): ((_1, _2, _3, _4, _5, _6, _7), _8) = ((out._1, out._2, out._3, out._4, out._5, out._6, out._7), out._8)
    }

  implicit def zip9[_1, _2, _3, _4, _5, _6, _7, _8, _9]: Zip.Out[(_1, _2, _3, _4, _5, _6, _7, _8), _9, (_1, _2, _3, _4, _5, _6, _7, _8, _9)] =
    new Zip[(_1, _2, _3, _4, _5, _6, _7, _8), _9] {
      override type Out = (_1, _2, _3, _4, _5, _6, _7, _8, _9)
      override def zip(in1: (_1, _2, _3, _4, _5, _6, _7, _8), in2: _9): Out = (in1._1, in1._2, in1._3, in1._4, in1._5, in1._6, in1._7, in1._8, in2)
      override def unzip(out: Out): ((_1, _2, _3, _4, _5, _6, _7, _8), _9) = ((out._1, out._2, out._3, out._4, out._5, out._6, out._7, out._8), out._9)
    }

  implicit def zip10[_1, _2, _3, _4, _5, _6, _7, _8, _9, _10]: Zip.Out[(_1, _2, _3, _4, _5, _6, _7, _8, _9), _10, (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10)] =
    new Zip[(_1, _2, _3, _4, _5, _6, _7, _8, _9), _10] {
      override type Out = (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10)
      override def zip(in1: (_1, _2, _3, _4, _5, _6, _7, _8, _9), in2: _10): Out = (in1._1, in1._2, in1._3, in1._4, in1._5, in1._6, in1._7, in1._8, in1._9, in2)
      override def unzip(out: Out): ((_1, _2, _3, _4, _5, _6, _7, _8, _9), _10) = ((out._1, out._2, out._3, out._4, out._5, out._6, out._7, out._8, out._9), out._10)
    }

  implicit def zip11[_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11]: Zip.Out[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10), _11, (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11)] =
    new Zip[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10), _11] {
      override type Out = (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11)
      override def zip(in1: (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10), in2: _11): Out = (in1._1, in1._2, in1._3, in1._4, in1._5, in1._6, in1._7, in1._8, in1._9, in1._10, in2)
      override def unzip(out: Out): ((_1, _2, _3, _4, _5, _6, _7, _8, _9, _10), _11) = ((out._1, out._2, out._3, out._4, out._5, out._6, out._7, out._8, out._9, out._10), out._11)
    }

  implicit def zip12[_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12]: Zip.Out[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11), _12, (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12)] =
    new Zip[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11), _12] {
      override type Out = (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12)
      override def zip(in1: (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11), in2: _12): Out = (in1._1, in1._2, in1._3, in1._4, in1._5, in1._6, in1._7, in1._8, in1._9, in1._10, in1._11, in2)
      override def unzip(out: Out): ((_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11), _12) = ((out._1, out._2, out._3, out._4, out._5, out._6, out._7, out._8, out._9, out._10, out._11), out._12)
    }

  implicit def zip13[_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13]: Zip.Out[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12), _13, (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13)] =
    new Zip[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12), _13] {
      override type Out = (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13)
      override def zip(in1: (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12), in2: _13): Out = (in1._1, in1._2, in1._3, in1._4, in1._5, in1._6, in1._7, in1._8, in1._9, in1._10, in1._11, in1._12, in2)
      override def unzip(out: Out): ((_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12), _13) = ((out._1, out._2, out._3, out._4, out._5, out._6, out._7, out._8, out._9, out._10, out._11, out._12), out._13)
    }

  implicit def zip14[_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14]: Zip.Out[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13), _14, (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14)] =
    new Zip[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13), _14] {
      override type Out = (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14)
      override def zip(in1: (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13), in2: _14): Out = (in1._1, in1._2, in1._3, in1._4, in1._5, in1._6, in1._7, in1._8, in1._9, in1._10, in1._11, in1._12, in1._13, in2)
      override def unzip(out: Out): ((_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13), _14) = ((out._1, out._2, out._3, out._4, out._5, out._6, out._7, out._8, out._9, out._10, out._11, out._12, out._13), out._14)
    }

  implicit def zip15[_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15]: Zip.Out[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14), _15, (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15)] =
    new Zip[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14), _15] {
      override type Out = (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15)
      override def zip(in1: (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14), in2: _15): Out = (in1._1, in1._2, in1._3, in1._4, in1._5, in1._6, in1._7, in1._8, in1._9, in1._10, in1._11, in1._12, in1._13, in1._14, in2)
      override def unzip(out: Out): ((_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14), _15) = ((out._1, out._2, out._3, out._4, out._5, out._6, out._7, out._8, out._9, out._10, out._11, out._12, out._13, out._14), out._15)
    }

  implicit def zip16[_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16]: Zip.Out[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15), _16, (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16)] =
    new Zip[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15), _16] {
      override type Out = (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16)
      override def zip(in1: (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15), in2: _16): Out = (in1._1, in1._2, in1._3, in1._4, in1._5, in1._6, in1._7, in1._8, in1._9, in1._10, in1._11, in1._12, in1._13, in1._14, in1._15, in2)
      override def unzip(out: Out): ((_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15), _16) = ((out._1, out._2, out._3, out._4, out._5, out._6, out._7, out._8, out._9, out._10, out._11, out._12, out._13, out._14, out._15), out._16)
    }

  implicit def zip17[_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17]: Zip.Out[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16), _17, (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17)] =
    new Zip[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16), _17] {
      override type Out = (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17)
      override def zip(in1: (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16), in2: _17): Out = (in1._1, in1._2, in1._3, in1._4, in1._5, in1._6, in1._7, in1._8, in1._9, in1._10, in1._11, in1._12, in1._13, in1._14, in1._15, in1._16, in2)
      override def unzip(out: Out): ((_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16), _17) = ((out._1, out._2, out._3, out._4, out._5, out._6, out._7, out._8, out._9, out._10, out._11, out._12, out._13, out._14, out._15, out._16), out._17)
    }

  implicit def zip18[_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18]: Zip.Out[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17), _18, (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18)] =
    new Zip[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17), _18] {
      override type Out = (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18)
      override def zip(in1: (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17), in2: _18): Out = (in1._1, in1._2, in1._3, in1._4, in1._5, in1._6, in1._7, in1._8, in1._9, in1._10, in1._11, in1._12, in1._13, in1._14, in1._15, in1._16, in1._17, in2)
      override def unzip(out: Out): ((_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17), _18) = ((out._1, out._2, out._3, out._4, out._5, out._6, out._7, out._8, out._9, out._10, out._11, out._12, out._13, out._14, out._15, out._16, out._17), out._18)
    }

  implicit def zip19[_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19]: Zip.Out[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18), _19, (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19)] =
    new Zip[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18), _19] {
      override type Out = (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19)
      override def zip(in1: (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18), in2: _19): Out = (in1._1, in1._2, in1._3, in1._4, in1._5, in1._6, in1._7, in1._8, in1._9, in1._10, in1._11, in1._12, in1._13, in1._14, in1._15, in1._16, in1._17, in1._18, in2)
      override def unzip(out: Out): ((_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18), _19) = ((out._1, out._2, out._3, out._4, out._5, out._6, out._7, out._8, out._9, out._10, out._11, out._12, out._13, out._14, out._15, out._16, out._17, out._18), out._19)
    }

  implicit def zip20[_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20]: Zip.Out[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19), _20, (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20)] =
    new Zip[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19), _20] {
      override type Out = (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20)
      override def zip(in1: (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19), in2: _20): Out = (in1._1, in1._2, in1._3, in1._4, in1._5, in1._6, in1._7, in1._8, in1._9, in1._10, in1._11, in1._12, in1._13, in1._14, in1._15, in1._16, in1._17, in1._18, in1._19, in2)
      override def unzip(out: Out): ((_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19), _20) = ((out._1, out._2, out._3, out._4, out._5, out._6, out._7, out._8, out._9, out._10, out._11, out._12, out._13, out._14, out._15, out._16, out._17, out._18, out._19), out._20)
    }

  implicit def zip21[_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21]: Zip.Out[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20), _21, (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21)] =
    new Zip[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20), _21] {
      override type Out = (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21)
      override def zip(in1: (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20), in2: _21): Out = (in1._1, in1._2, in1._3, in1._4, in1._5, in1._6, in1._7, in1._8, in1._9, in1._10, in1._11, in1._12, in1._13, in1._14, in1._15, in1._16, in1._17, in1._18, in1._19, in1._20, in2)
      override def unzip(out: Out): ((_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20), _21) = ((out._1, out._2, out._3, out._4, out._5, out._6, out._7, out._8, out._9, out._10, out._11, out._12, out._13, out._14, out._15, out._16, out._17, out._18, out._19, out._20), out._21)
    }

  implicit def zip22[_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22]: Zip.Out[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21), _22, (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22)] =
    new Zip[(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21), _22] {
      override type Out = (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22)
      override def zip(in1: (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21), in2: _22): Out = (in1._1, in1._2, in1._3, in1._4, in1._5, in1._6, in1._7, in1._8, in1._9, in1._10, in1._11, in1._12, in1._13, in1._14, in1._15, in1._16, in1._17, in1._18, in1._19, in1._20, in1._21, in2)
      override def unzip(out: Out): ((_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21), _22) = ((out._1, out._2, out._3, out._4, out._5, out._6, out._7, out._8, out._9, out._10, out._11, out._12, out._13, out._14, out._15, out._16, out._17, out._18, out._19, out._20, out._21), out._22)
    }

  // format: on

}

trait ZipLowPriority3 {

  implicit def zip2[_1, _2]: Zip.Out[_1, _2, (_1, _2)] =
    new Zip[_1, _2] {
      override type Out = (_1, _2)
      override def zip(in1: _1, in2: _2): Out = (in1, in2)
      override def unzip(out: Out): (_1, _2) = out
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy