[Haskell-cafe] monad . comonad = id
Miguel Mitrofanov
miguelimo38 at yandex.ru
Fri May 8 07:14:50 EDT 2009
> I have a question regarding the connection between monads and comonads.
> I always thought of the comonad operations as being the inverse
> operations of the corresponding monad functions.
That's not true.
> If this is the case I would like to know what the corresponding monad
> for the following comond could be. This comonad treats lists as pointed
> sets where the first element is focused.
>
> instance Comonad [] where
> extract = head
> duplicate xs = init (zipWith (++) (tails xs) (inits xs))
First of all, this is NOT a comonad. The term "comonad" doesn't refer just to instances of Comonad class, it refers to instances that satisfy
several laws.
Secondly, "[]" is a monad, and there is an instance of Monad class for it. It's working; don't fix it.
More information about the Haskell-Cafe
mailing list