Efficient and Sound Differentiable Programming in a Functional Array-Processing Language