The cats documentation on FunctionK contains:
Thus natural transformation can be implemented in terms of
FunctionK. This is why a parametric polymorphic functionFunctionK[F, G]is sometimes referred as a natural transformation. However, they are two different concepts that are not isomorphic.
What's an example of a FunctionK which isn't a Natural Transformation (or vice versa)?
It's not clear to me whether this statement is implying F and G need to have Functor instances, for a FunctionK to be a Natural Transformation.
The Wikipedia article on Natural Transformations says that the Commutative Diagram can be written with a Contravariant Functor instead of a Covariant Functor, which to me implies that a Functor instance isn't required?
Alternatively, the statement could be refering to impure FunctionKs, although I'd kind of expect analogies to category theory breaking down in the presence of impurity to be a given; and not need explicitly stating?
You can write down
FunctionK-instances for things that aren't functors at all, neither covariant nor contravariant.For example, given
you could implement a
FunctionK[F, F]byHere, the
Fcannot be considered to be a functor, becauseXappears with both variances. Thus, you get something that's certainly aFunctionK, but the question whether it's a natural transformation isn't even valid to begin with.Note that this example does not depend on whether you take the general CT-definition or the narrow FP-definition of what a "functor" is, the mapping
Fis simply not functorial.