3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

これはどうにかなりませんかねえ

Last updated at Posted at 2012-03-16

Monad m => Maybe (m (Maybe b))という型がついている物体の、二つのMaybeをエレガントに統合する方法もとむ

MainRand.hs
recMapM :: forall a b m. (Data a, Data b, Monad m) => (b -> m b) -> a -> m a
recMapM f x = do
  let recurse = gmapM (recMapM f) x
  case cast x of
    Nothing -> recurse
    Just bx -> do
      z <- f bx
      case cast z of
        Nothing -> recurse
        Just az -> return az

c.f.
http://d.hatena.ne.jp/nushio/20120104
http://d.hatena.ne.jp/nushio/20120105

3
3
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?