Given the following from fp-course:
class Functor f where
(<$>) ::
(a -> b)
-> f a
-> f b
class Functor f => Extend f where
(<<=) ::
(f a -> b)
-> f a
-> f b
I defined <$$> as so:
(<$$>) ::
Comonad f =>
(a -> b)
-> f a
-> f b
(<$$>) f fa = f <$> fa
However, I'm interested to know if there's another way to implement <$$> without using <$>. Is there? If so, please show it!
You need the
extractmethod ofComonad;Extendisn't enough to get away withoutfmap.This is basically how
liftWis implemented inControl.Comonad.Note also that you need
<<=(orextend);extractandduplicatearen't sufficient. The situation is similar to that ofBindandMonad; you can implementfmapusing>>=andpure, but not using>>=alone and not usingjoinandpure.