[Haskell-cafe] monad . comonad = id

Jan Christiansen jac at informatik.uni-kiel.de
Fri May 8 06:47:45 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. As I do not  
know the underlying theory I thought I simply ask the masters.

Is there a formal verification for this intuition? That is, are there  
always corresponding instances for monad and comonad such that the  
following laws are satisfied?

   extract . return == id

   join . duplicate == id

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))

Obviously we can define return x = [x]. But I do not know how to  
define join.

Cheers, Jan

More information about the Haskell-Cafe mailing list