I have this lame attempt:
fmap2 :: (Functor f, Functor g) => (a -> b) -> f (g a) -> f (g b)
fmap2 f f2 = (fmap2 f . fmap f2)
It is supposed to work like this:
fmap2 negate [[1,2], [3]] -- Returns [[-1,-2],[-3]]
fmap2 head [Just "abc",Nothing,Just "def"] -- Returns [Just 'a',Nothing,Just 'e']
Note, that this is an exercise. (I gave it a try for like 1,5 hours, yet did not found any solution.)
Q: What am I doing wrong there?
When you get stuck in something like this, I'd recommend using type holes as they drive you in the right direction
If you try to compile this code,
ghcwill notice the_somethingand will propose you a type for itWe know that
_somethingneeds to have typeg a -> g bgivenFunctor g. Hence: