Timeline for Sum Types vs Polymorphism
Current License: CC BY-SA 3.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 24 at 5:11 | comment | added | got trolled too much this week | Actually, for more detailed discussion why type inference is hard with subtyping langdev.stackexchange.com/a/2279 | |
| Aug 24 at 4:57 | comment | added | got trolled too much this week | The latter has a nice discussion why it's a hard problem for type inference. Which is in some ways related to the issue of shape ('hidden class') inference that JS engines do (for perf rather than correctness-enforcing reasons.) | |
| Aug 24 at 4:48 | comment | added | got trolled too much this week | Several people/systems came up with the idea of extensible sum types. Including Ocaml 4 (rel ~2012) ocaml.org/manual/5.3/extensiblevariants.html And a bunch in Haskell apparenlty reddit.com/r/haskell/comments/l432gn/… | |
| Mar 28, 2023 at 19:16 | comment | added | forresthopkinsa | It must be noted that "unions vs polymorphism" is a false dichotomy. Unions are a type of polymorphism; just a different kind than you'd usually find in OOP. Interfaces and Liskov substitution are used for subtype (aka inclusion) polymorphism. On the other hand, when the "consumer has to consider" the possible cases (e.g. when you find yourself doing pattern-matching) this is an example of ad-hoc polymorphism. | |
| Mar 21, 2018 at 11:56 | vote | accept | Patrick D | ||
| Mar 12, 2018 at 18:06 | comment | added | VisualMelon | @FilipMilovanović aye, I've not been very precise there. I was trying to avoid getting into the 'triangle' of dependencies with interfaces (consumer -> interface <- implementer/type) rather than the 'linear' dependencies with a union (consumer -> union -> types), because I'm really only trying to express where the 'decision' making is going on (e.g. where do we define what to do if we are presented with this type) | |
| Mar 12, 2018 at 17:55 | comment | added | Filip Milovanović | "an interface defines some stuff the type has to implement, and the union defines some stuff the consumer has to consider" - you don't have to look at interfaces that way. A component can define a required interface - what some other component has to implement; and a provided interface - one that a consumer component has to consider (i.e., be programmed against). | |
| Mar 12, 2018 at 17:51 | history | edited | VisualMelon | CC BY-SA 3.0 |
added 383 characters in body
|
| Mar 12, 2018 at 17:44 | comment | added | jk. | related to the penultimate paragraph: en.wikipedia.org/wiki/Expression_problem | |
| Mar 12, 2018 at 17:28 | history | answered | VisualMelon | CC BY-SA 3.0 |