[Haskell-cafe] Why aren't there anonymous sum types in Haskell?
wren ng thornton
wren at freegeek.org
Wed Jun 22 03:51:21 CEST 2011
On 6/21/11 6:54 PM, Casey McCann wrote:
> That said, I don't think either retains the tidy algebraic properties
> that disjoint unions and tuples have, so I'm not sure if calling them
> sums and products is actually correct.
I don't think there are any problems. Categorically speaking, a product
of A and B is simply a thing, which we can call Foo, along with two
projections, f :: Foo -> A and oo :: Foo -> B, such that the Foo is the
"closest" thing to A and B.
I chose the funny names intentionally. Nothing in the definition of
products says that there has to be any kind of notion of order between the
components, only that the composite has projections for each component and
that it has no extra junk. Consequently A*B is isomorphic to B*A, which
means they are essentially the same thing. The choice of order is just
For a slightly stronger notion of products we can look to monoidal
categories which have that A*(B*C) is isomorphic to (A*B)*C, again meaning
that they're essentially the same thing.
Outside of category theory, we can look to domain theory (or the
associated CPO categories), but domain products and smash products both
have the same order independence as categorical products.
For coproducts, dually.
 modulo the A:+:A ~ A issue.
 More conventionally called A*B, but remember: that's just a name.
 More traditionally, pi_1 and pi_2, or fst and snd, or...
 That is, for any other Bar with b :: Bar -> A and ar :: Bar -> B,
there is a unique function from Bar to Foo such that everything commutes.
 The clever reader will notice that they are not *exactly* the same
thing, not identical; however, category theorists rarely care about the
differences between isomorphic things unless it's mucking up a proof.
More information about the Haskell-Cafe