I have defined a number of case classes such as
abstract class Foo
case class Bar(s: String) extends Foo
case class Baz(f: Foo) extends Foo
case class FooBar(l: Foo, r:Foo)
that allow me to create complex data, e.g.,
val x = FooBar(Bar("1"), Baz(Bar("2")))
I want to read these type of data from a string, such as
val x = what_to_do_here?("FooBar(Bar("1"), Baz(Bar("2")))")
In a dynamic language I would just call eval.
(Edit: I really do not want to call something like eval in scala)
The solution I came up with in scala was to write a parser. Is there a simpler way to do that?