You can just write a bash script that will do:
cabal install --constraint='bar == v'
for all the values of 'v' (0.1, 0.2, 1.2.5.1, ...) you are interested in. You can be aware of all the existing versions just using the directory listing in
http://hackage.haskell.org/packages/archive/containers/ (for the 'containers' package in this case) or by using cabal-install cleverly maybe?
I just saw 'cabal info containers' gives a list of available versions, up to a point... after which it says "(and 4 others)". So maybe go see how 'cabal info' does this? But all in all, this should give you enough to work out a nice solution.