The difficulty of giving a type to fmap
is that it is parameterized by a higher-kinded type variable, the container type. So beyond being a simple polymorphic function, like say, map
on lists:
map :: (a -> b) -> List a -> List b
fmap
generalizes this to work on any container, as well as any element type:
fmap :: Functor (f :: * -> *) => (a -> b) -> f a -> f b
The problem in C# is that f
is a higher-kinded type variable (it is a type function). Since C# doesn't support higher kinds, you'll be out of luck writing this directly, think.