Like the good programmers that we are, we declare our interface at the top of our file. Our interface, that is, our contract, has only one function, Map. Our IntFunctor type accepts a func(int) int function and returns another IntFunctor.
What? It returns an IntFunctor? What is that, and how did it print correctly?
Let's have a look at src/functor/ints.go:
package functorimport ( "fmt")type IntFunctor interface { Map(f func(int) int) IntFunctor}
One feature of a functor is that it applies that f function inside its container. Now, what is a container?
type intBox struct { ints []int}
That's our functor's container. We'll call it a box, because a box is a container, and since we are good, lazy programmers, we prefer names that ...