Calculus for categories