Implement flexible target specification

See commit message.
This seems indicative of the type system being able to help us.