【问题标题】:Function to map Maybes to a monad将 Maybes 映射到 monad 的函数
【发布时间】:2012-01-12 14:02:18
【问题描述】:

我经常使用maybe (return ()) someFunc someMaybe 形式的表达式。

在 hoogle 上搜索函数 Monad m => (a -> m ()) -> Maybe a -> m () 不会产生特定结果。没有这个库函数吗?

【问题讨论】:

    标签: haskell monads standard-library


    【解决方案1】:

    您可以为此使用Data.Foldable 中的mapM_forM_。另见the recent discussion on the librariers mailing list

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-16
      • 2020-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多