What is the difference between mapM_ and mapM in Haskell?

后端 未结 4 370
野的像风
野的像风 2021-02-01 16:25

I\'ve already checked Hoogle, http://hackage.haskell.org/package/base-4.7.0.1/docs/Prelude.html#v:mapM, which says that mapM_ ignores the results.

However,

4条回答
  •  北海茫月
    2021-02-01 17:24

    mapM_ ignores the result. This means, that no return value will be returned. You can see this in interactive mode:

    Prelude> mapM (putStrLn . show) [1,2]
    1
    2
    [(),()]
    Prelude> mapM_ (putStrLn . show) [1,2]
    1
    2
    

提交回复
热议问题