▲ | bananaflag 3 days ago | |
I always thought "algebraic" sounds unscary because in high school / undergraduate, algebra feels easier than analysis. Now, "analytic data types", that would be something. | ||
▲ | taeric 2 days ago | parent | next [-] | |
Apologies, I missed this yesterday. It isn't that it is scary. It is that it connotes something about equations and such. It is literally the name of the class people learn how to symbolically solve quadratic equations and such. I was saying in another thread that I think this would be a lot more obvious if people actually did algebra on the types. But we don't. At least, I can't recall ever seeing it done. Closest I've seen is in places where people have to do so to justify the naming here. And I want to be clear, I specifically mean using + and * with types. And not that it can be done. Is it done? | ||
▲ | thechao 3 days ago | parent | prev | next [-] | |
Right. So, there's a unit type: the type that the sum of returns the other type, i.e.,
So that means there's an identity type for the product type operator:
I.e., the type that you can "multiply" by that doesn't give you a two-field tuple, but just returns the single-field tuple. If "1" is a type, then we can build a sum-type with it:
Ok. Cool. But! If we can "add 1", then we should be able to remove "1", right? That kinda implies that "-1" exists:
But, that also implies that we can allow a product type whose result is the "-1" type?
OH NOES! | ||
▲ | adastra22 3 days ago | parent | prev [-] | |
Why not just “struct” or “record” and “enum” or “variant”? |