I'm trying to implement function downpairs which takes monad of pairs and transform it into pair of monad

My current implementation is

import Control.Monad
import Control.Arrow
import Data.Maybe

downpair :: (Monad m) => m (a, b) -> (m a, m b)
downpair = ((return . fst =<<) &&& (return . snd =<<)) 

main = do
    print $ downpair $ Just ("Hello", "World")

Is there way to implement downpair in more compact maner?

PS Sorry for my poor English


1 Answer 1


(return . fst =<<) can be replaced by fmap fst. Your definition then becomes

downpair = fmap fst &&& fmap snd

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.