Are there languages that have first class associative product / sum types? ie ((a,b),c) = (a,(b,c)) = (a, b, c)
a|(b|c) = (a|b)|c = a|b|c
Conversation
Sum types: Typescript, Flow, Ceylon, Dotty
Product types: Not sure - afaik, Idris, Agda, and Lean's sum types associate to the right only
1
1
I dunno, associative sums would be kind of hard to work with if they were positional only. Row polymorphism + union operator could work.
2
woops: s/sums/products/
2
Positional, as opposed to path navigation, like caaddr cdaddr silliness in Lisp?
1
Positional in terms of tuples vs records
1
Same as usual way with n-tuples? Pattern matching, _1, _2, etc.
1
Replying to
I think the mistake is seeing `(,)` as an operator. in fact they are a whole bunch of hard-wired data constructors: `(,)`, `(,,)`, `(,,,)`…
Bleh, I mean 'type' constructors - confusing because Haskell overloads types and values :P
Think you *might* be forced to add a subtyping relation at some stage to the type system in order to get it to work. Could be wrong though.
1
Show replies

