While you will always need to double-check with the components that you are working with, Shimano is pretty good at making their componentry interchangeable. But, there is a catch. What you need to look for are components that share the same gear configuration.
Granted this is the case then you should be fine to mix some components. This can come in handy if you tend to shop with Shimano a lot. They are a pretty reliable company, after all.