Blog Logo
TAGS

Contravariant functors as invariant functors

This article is part of a series of articles about invariant functors. It explains that all contravariant functors are also invariant functors, even if thats of no practical use. The article shows a few examples of Haskell and C# code for using invmap with a predicate to map the Integral predicate to an Enum predicate, and demonstrates how to evaluate various durations. While this is hardly useful, it shows that its still possible. Unless you have an API that requires an Invariant instance, its also redundant, because you could just have used contramap with the predicate.