After months of negotiations with the International Monetary Fund, Pakistan has reached an agreement on a $6bn loan package.