Haskell and algebra

Frank Atanassow franka@cs.uu.nl
Mon, 11 Aug 2003 18:56:13 +0200


Gustavo Villavicencio wrote:
> Frank Atanassow said:

>>What do you mean by a "fork"?

>  So, the question is, if i have
> 
>  f : A -> T B and g : A -> T C
> 
> where T is a monad, i.e. an endofunctor, can i combine f and g as
> 
>  <f,g> : A -> T (BxC)
> 
> knowing that T involves side effects?

I guess you are asking: if category C has finite products, and T is a 
strong monad on C, does the Kleisli category have finite products? The 
answer, I imagine, is "not in general", but "yes" if the monad is 
commutative.

   pair :: (a -> m b) -> (a -> m c) -> (a -> m (b,c))
   pair f g a = do b <- f a
                   c <- g a
                   return (b, c)

You need to pick an order for the first two actions.

I haven't done the proof, though.

Regards,
Frank