Structural Foundations For Differentiable Programming