
Hi, On 08.05.2009, at 13:14, Miguel Mitrofanov wrote:
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.
I thought there is some kind of duality between monads and comonads in category theory. Does this "only" refer to the types of the functions or am I totally wrong here?
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.
I am aware of this. I thought it does satisfy all the laws. Which one have I missed?
Secondly, "[]" is a monad, and there is an instance of Monad class for it. It's working; don't fix it.
I am also aware of this. Perhaps I should have used a data type like data Pointed a = Pointed a [a] but in this case a corresponding duplicate implementation is more complicated. I am very sorry if have asked a stupid question. Cheers, Jan