typelift / Swiftz

Functional programming in Swift
BSD 3-Clause "New" or "Revised" License
3.33k stars 233 forks source link

Implement The Coproduct of Monoids #172

Closed CodaFi closed 9 years ago

CodaFi commented 9 years ago
struct MonoidCoproduct<A : Monoid, B : Monoid> : Monoid {
    let stuff : [Either<A, B>]
}

(Also, think of a better name for this thing).

pthariensflame commented 9 years ago

This should actually be [(A, B)] on the inside, because of monoidal collapse.

CodaFi commented 9 years ago

Strictly alternating pre-products get tricky with strict languages.