Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Right, so I must have used the wrong words “sum type” when I should have said “union type”, but I thought the intended meaning was clear.

It doesn’t necessarily need to be inside an Either wrapper, that is an implementation detail, neither does there need to be a typeclass specifically defined for it. For example the new Dotty dialect of Scala has support for union types as I described them [1]. This is nice because it makes union of types an actual union operator, satisfying actual commutativity (A | B) = (B | A) and idempotence (A | A) = A, which Either does not without some extra explicit isomorphisms.

[1]: https://dotty.epfl.ch/docs/reference/new-types/union-types.h...



Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: