Possible Duplicate:
Update operations on a Scala Case Class
This question came to me this evening.
I have two instantiated case classes of the same type.
case class Foo(a : Option[String], b : Option[String], c : Option[String])
Lets call the instantiated classes A and B.
val a = Foo(a=Some("foo"), b=Some("bar"), c=Some("baz"))
val b = Foo(a=None, b=Some("etch"), c=None)
I'm wondering if its possible to update case class A with B in a single operation in a generic way.
val c = b *oper* a // Foo(a=Some("foo"), b=Some("etch"), c=Some("baz"))
with parameters that are set as None ignored. Ideally the operation should also be generic so it can act on any type of case class.
I have some intuition that it might be possible to do this with Scalaz by converting the class into a tuple/list first and converting back to a class after the operation is complete - perhaps using the ApplicativeBuilder? Any ideas?