functor approach to definining differentiable functions