// Code generated by `mise run codegen:captures`. DO NOT EDIT.

///|
/// Add the next part. The result decodes both values.
pub fn[A, B] Captures1::zip(
  self : Captures1[A],
  next : Captures1[B],
) -> Captures2[A, B] {
  { p1: self, p2: next, }
}

///|
/// A decoder of 2 values. Add a value with `zip`, or make one value with
/// `map`.
pub struct Captures2[A, B] {
  priv p1 : Captures1[A]
  priv p2 : Captures1[B]
}

///|
/// Make one value from the 2 values with `f`. The result decodes the same
/// capture groups, so it can be zipped into a bigger decoder.
pub fn[A, B, T] Captures2::map(
  self : Captures2[A, B],
  f : (A, B) -> T raise,
) -> Captures1[T] {
  let c1 = self.p1.count
  let c2 = self.p2.count
  {
    count: c1 + c2,
    decode: (values, first) => {
      let mut offset = 0
      let v1 = (self.p1.decode)(values[offset:offset + c1], first + offset)
      offset = offset + c1
      let v2 = (self.p2.decode)(values[offset:offset + c2], first + offset)
      f(v1, v2)
    },
  }
}

///|
/// Add the next part. The result decodes 3 values.
pub fn[A, B, C] Captures2::zip(
  self : Captures2[A, B],
  next : Captures1[C],
) -> Captures3[A, B, C] {
  { p1: self.p1, p2: self.p2, p3: next, }
}

///|
/// A decoder of 3 values. Add a value with `zip`, or make one value with
/// `map`.
pub struct Captures3[A, B, C] {
  priv p1 : Captures1[A]
  priv p2 : Captures1[B]
  priv p3 : Captures1[C]
}

///|
/// Make one value from the 3 values with `f`. The result decodes the same
/// capture groups, so it can be zipped into a bigger decoder.
pub fn[A, B, C, T] Captures3::map(
  self : Captures3[A, B, C],
  f : (A, B, C) -> T raise,
) -> Captures1[T] {
  let c1 = self.p1.count
  let c2 = self.p2.count
  let c3 = self.p3.count
  {
    count: c1 + c2 + c3,
    decode: (values, first) => {
      let mut offset = 0
      let v1 = (self.p1.decode)(values[offset:offset + c1], first + offset)
      offset = offset + c1
      let v2 = (self.p2.decode)(values[offset:offset + c2], first + offset)
      offset = offset + c2
      let v3 = (self.p3.decode)(values[offset:offset + c3], first + offset)
      f(v1, v2, v3)
    },
  }
}

///|
/// Add the next part. The result decodes 4 values.
pub fn[A, B, C, D] Captures3::zip(
  self : Captures3[A, B, C],
  next : Captures1[D],
) -> Captures4[A, B, C, D] {
  { p1: self.p1, p2: self.p2, p3: self.p3, p4: next, }
}

///|
/// A decoder of 4 values. Add a value with `zip`, or make one value with
/// `map`.
pub struct Captures4[A, B, C, D] {
  priv p1 : Captures1[A]
  priv p2 : Captures1[B]
  priv p3 : Captures1[C]
  priv p4 : Captures1[D]
}

///|
/// Make one value from the 4 values with `f`. The result decodes the same
/// capture groups, so it can be zipped into a bigger decoder.
pub fn[A, B, C, D, T] Captures4::map(
  self : Captures4[A, B, C, D],
  f : (A, B, C, D) -> T raise,
) -> Captures1[T] {
  let c1 = self.p1.count
  let c2 = self.p2.count
  let c3 = self.p3.count
  let c4 = self.p4.count
  {
    count: c1 + c2 + c3 + c4,
    decode: (values, first) => {
      let mut offset = 0
      let v1 = (self.p1.decode)(values[offset:offset + c1], first + offset)
      offset = offset + c1
      let v2 = (self.p2.decode)(values[offset:offset + c2], first + offset)
      offset = offset + c2
      let v3 = (self.p3.decode)(values[offset:offset + c3], first + offset)
      offset = offset + c3
      let v4 = (self.p4.decode)(values[offset:offset + c4], first + offset)
      f(v1, v2, v3, v4)
    },
  }
}

///|
/// Add the next part. The result decodes 5 values.
pub fn[A, B, C, D, E] Captures4::zip(
  self : Captures4[A, B, C, D],
  next : Captures1[E],
) -> Captures5[A, B, C, D, E] {
  { p1: self.p1, p2: self.p2, p3: self.p3, p4: self.p4, p5: next, }
}

///|
/// A decoder of 5 values. Add a value with `zip`, or make one value with
/// `map`.
pub struct Captures5[A, B, C, D, E] {
  priv p1 : Captures1[A]
  priv p2 : Captures1[B]
  priv p3 : Captures1[C]
  priv p4 : Captures1[D]
  priv p5 : Captures1[E]
}

///|
/// Make one value from the 5 values with `f`. The result decodes the same
/// capture groups, so it can be zipped into a bigger decoder.
pub fn[A, B, C, D, E, T] Captures5::map(
  self : Captures5[A, B, C, D, E],
  f : (A, B, C, D, E) -> T raise,
) -> Captures1[T] {
  let c1 = self.p1.count
  let c2 = self.p2.count
  let c3 = self.p3.count
  let c4 = self.p4.count
  let c5 = self.p5.count
  {
    count: c1 + c2 + c3 + c4 + c5,
    decode: (values, first) => {
      let mut offset = 0
      let v1 = (self.p1.decode)(values[offset:offset + c1], first + offset)
      offset = offset + c1
      let v2 = (self.p2.decode)(values[offset:offset + c2], first + offset)
      offset = offset + c2
      let v3 = (self.p3.decode)(values[offset:offset + c3], first + offset)
      offset = offset + c3
      let v4 = (self.p4.decode)(values[offset:offset + c4], first + offset)
      offset = offset + c4
      let v5 = (self.p5.decode)(values[offset:offset + c5], first + offset)
      f(v1, v2, v3, v4, v5)
    },
  }
}

///|
/// Add the next part. The result decodes 6 values.
pub fn[A, B, C, D, E, F] Captures5::zip(
  self : Captures5[A, B, C, D, E],
  next : Captures1[F],
) -> Captures6[A, B, C, D, E, F] {
  { p1: self.p1, p2: self.p2, p3: self.p3, p4: self.p4, p5: self.p5, p6: next, }
}

///|
/// A decoder of 6 values. Add a value with `zip`, or make one value with
/// `map`.
pub struct Captures6[A, B, C, D, E, F] {
  priv p1 : Captures1[A]
  priv p2 : Captures1[B]
  priv p3 : Captures1[C]
  priv p4 : Captures1[D]
  priv p5 : Captures1[E]
  priv p6 : Captures1[F]
}

///|
/// Make one value from the 6 values with `f`. The result decodes the same
/// capture groups, so it can be zipped into a bigger decoder.
pub fn[A, B, C, D, E, F, T] Captures6::map(
  self : Captures6[A, B, C, D, E, F],
  f : (A, B, C, D, E, F) -> T raise,
) -> Captures1[T] {
  let c1 = self.p1.count
  let c2 = self.p2.count
  let c3 = self.p3.count
  let c4 = self.p4.count
  let c5 = self.p5.count
  let c6 = self.p6.count
  {
    count: c1 + c2 + c3 + c4 + c5 + c6,
    decode: (values, first) => {
      let mut offset = 0
      let v1 = (self.p1.decode)(values[offset:offset + c1], first + offset)
      offset = offset + c1
      let v2 = (self.p2.decode)(values[offset:offset + c2], first + offset)
      offset = offset + c2
      let v3 = (self.p3.decode)(values[offset:offset + c3], first + offset)
      offset = offset + c3
      let v4 = (self.p4.decode)(values[offset:offset + c4], first + offset)
      offset = offset + c4
      let v5 = (self.p5.decode)(values[offset:offset + c5], first + offset)
      offset = offset + c5
      let v6 = (self.p6.decode)(values[offset:offset + c6], first + offset)
      f(v1, v2, v3, v4, v5, v6)
    },
  }
}

///|
/// Add the next part. The result decodes 7 values.
pub fn[A, B, C, D, E, F, G] Captures6::zip(
  self : Captures6[A, B, C, D, E, F],
  next : Captures1[G],
) -> Captures7[A, B, C, D, E, F, G] {
  {
    p1: self.p1,
    p2: self.p2,
    p3: self.p3,
    p4: self.p4,
    p5: self.p5,
    p6: self.p6,
    p7: next,
  }
}

///|
/// A decoder of 7 values. Add a value with `zip`, or make one value with
/// `map`.
pub struct Captures7[A, B, C, D, E, F, G] {
  priv p1 : Captures1[A]
  priv p2 : Captures1[B]
  priv p3 : Captures1[C]
  priv p4 : Captures1[D]
  priv p5 : Captures1[E]
  priv p6 : Captures1[F]
  priv p7 : Captures1[G]
}

///|
/// Make one value from the 7 values with `f`. The result decodes the same
/// capture groups, so it can be zipped into a bigger decoder.
pub fn[A, B, C, D, E, F, G, T] Captures7::map(
  self : Captures7[A, B, C, D, E, F, G],
  f : (A, B, C, D, E, F, G) -> T raise,
) -> Captures1[T] {
  let c1 = self.p1.count
  let c2 = self.p2.count
  let c3 = self.p3.count
  let c4 = self.p4.count
  let c5 = self.p5.count
  let c6 = self.p6.count
  let c7 = self.p7.count
  {
    count: c1 + c2 + c3 + c4 + c5 + c6 + c7,
    decode: (values, first) => {
      let mut offset = 0
      let v1 = (self.p1.decode)(values[offset:offset + c1], first + offset)
      offset = offset + c1
      let v2 = (self.p2.decode)(values[offset:offset + c2], first + offset)
      offset = offset + c2
      let v3 = (self.p3.decode)(values[offset:offset + c3], first + offset)
      offset = offset + c3
      let v4 = (self.p4.decode)(values[offset:offset + c4], first + offset)
      offset = offset + c4
      let v5 = (self.p5.decode)(values[offset:offset + c5], first + offset)
      offset = offset + c5
      let v6 = (self.p6.decode)(values[offset:offset + c6], first + offset)
      offset = offset + c6
      let v7 = (self.p7.decode)(values[offset:offset + c7], first + offset)
      f(v1, v2, v3, v4, v5, v6, v7)
    },
  }
}

///|
/// Add the next part. The result decodes 8 values.
pub fn[A, B, C, D, E, F, G, H] Captures7::zip(
  self : Captures7[A, B, C, D, E, F, G],
  next : Captures1[H],
) -> Captures8[A, B, C, D, E, F, G, H] {
  {
    p1: self.p1,
    p2: self.p2,
    p3: self.p3,
    p4: self.p4,
    p5: self.p5,
    p6: self.p6,
    p7: self.p7,
    p8: next,
  }
}

///|
/// A decoder of 8 values. Add a value with `zip`, or make one value with
/// `map`.
pub struct Captures8[A, B, C, D, E, F, G, H] {
  priv p1 : Captures1[A]
  priv p2 : Captures1[B]
  priv p3 : Captures1[C]
  priv p4 : Captures1[D]
  priv p5 : Captures1[E]
  priv p6 : Captures1[F]
  priv p7 : Captures1[G]
  priv p8 : Captures1[H]
}

///|
/// Make one value from the 8 values with `f`. The result decodes the same
/// capture groups, so it can be zipped into a bigger decoder.
pub fn[A, B, C, D, E, F, G, H, T] Captures8::map(
  self : Captures8[A, B, C, D, E, F, G, H],
  f : (A, B, C, D, E, F, G, H) -> T raise,
) -> Captures1[T] {
  let c1 = self.p1.count
  let c2 = self.p2.count
  let c3 = self.p3.count
  let c4 = self.p4.count
  let c5 = self.p5.count
  let c6 = self.p6.count
  let c7 = self.p7.count
  let c8 = self.p8.count
  {
    count: c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8,
    decode: (values, first) => {
      let mut offset = 0
      let v1 = (self.p1.decode)(values[offset:offset + c1], first + offset)
      offset = offset + c1
      let v2 = (self.p2.decode)(values[offset:offset + c2], first + offset)
      offset = offset + c2
      let v3 = (self.p3.decode)(values[offset:offset + c3], first + offset)
      offset = offset + c3
      let v4 = (self.p4.decode)(values[offset:offset + c4], first + offset)
      offset = offset + c4
      let v5 = (self.p5.decode)(values[offset:offset + c5], first + offset)
      offset = offset + c5
      let v6 = (self.p6.decode)(values[offset:offset + c6], first + offset)
      offset = offset + c6
      let v7 = (self.p7.decode)(values[offset:offset + c7], first + offset)
      offset = offset + c7
      let v8 = (self.p8.decode)(values[offset:offset + c8], first + offset)
      f(v1, v2, v3, v4, v5, v6, v7, v8)
    },
  }
}

///|
/// Add the next part after 8 values. The 8 values fold
/// into one tuple, so the result is a `Captures2` of that tuple and the next
/// value. Zipping can continue with no limit.
pub fn[A, B, C, D, E, F, G, H, X] Captures8::zip(
  self : Captures8[A, B, C, D, E, F, G, H],
  next : Captures1[X],
) -> Captures2[(A, B, C, D, E, F, G, H), X] {
  self.map((a, b, c, d, e, f, g, h) => (a, b, c, d, e, f, g, h)).zip(next)
}