A Framework for Differential Calculus on Persistence Diagrams