I misinterpreted what you meant when you said

> automatically creating the corresponding Julia type as needed

and thought you meant it was a problem of type-specification. Instead, it sounds like it's a problem of instances. Either of your solutions sounds fine to me.