In Functional Programming, what is a functor?

I’ve come across the term ‘Functor’ a few times while reading various articles on functional programming, but the authors typically assume the reader already understands the term. Looking around on the web has provided either excessively technical descriptions (see the Wikipedia article) or incredibly vague descriptions (see the section on Functors at this ocaml-tutorial website).

Can someone kindly define the term, explain its use, and perhaps provide an example of how Functors are created and used?

Edit: While I am interested in the theory behind the term, I am less interested in the theory than I am in the implementation and practical use of the concept.

Edit 2: Looks like there is some cross-terminoligy going on: I’m specifically referring to the Functors of functional programming, not the function objects of C++.

18 Answers
18

Leave a Comment