FuncType - v0.60.3
    Preparing search index...

    Function reduceWiden

    • Runtime-safe reduce over an array whose element type A may be narrower than the accumulator type B. Centralizes the single as unknown as B cast that's otherwise spread across every container's implementation.

      Safety: the cast is sound because the Widen<A, B> type-level constraint at the public API layer guarantees A <: B. When that holds, A values flowing into the callback are valid B values at runtime — exactly what Scala's [B >: A] provides.

      Type Parameters

      • A
      • B

      Parameters

      • arr: readonly A[]

        source array of A values

      • op: (b: B, a: B) => B

        accumulator operation typed over B (where B is A or a supertype)

      Returns B

      the folded value, typed as B