Implement product type in Scala with generic update function working on its parts
问题 In Scala, I need to create a product type & that represents a compound value, e.g.: val and: String & Int & User & ... = ??? I.e. and should have a String part and an Int part and a User parts inside. This is similar to Scala with keyword: val and: String with Int with User with ... = ??? Having such product type I need a way to, having a function A => A , apply it to some product value and get that product back with A part altered. It implies that each type in product must be unique - that's