fork download
  1. mapMM :: Monad m => (a -> m b) -> [a] -> m [b]
  2. mapMM _f [] = pure []
  3. mapMM f (x:xs) = do
  4. y <- f x
  5. ys <- mapMM f xs
  6. pure $ y:ys
  7.  
  8. p :: Int -> Maybe Int
  9. p 1488 = Nothing
  10. p x = Just x
  11.  
  12. main = do
  13. print $ mapMM Just [1, 2, 1488, 3]
  14. print $ mapM Just [1, 2, 1488, 3]
  15. print $ mapMM p [1, 2, 1488, 3]
  16. print $ mapM p [1, 2, 1488, 3]
  17. print $ mapMM p []
  18. print $ mapM p []
  19.  
Success #stdin #stdout 0s 4404KB
stdin
Standard input is empty
stdout
Just [1,2,1488,3]
Just [1,2,1488,3]
Nothing
Nothing
Just []
Just []