
4 Jun
2009
4 Jun
'09
3:54 a.m.
Dear Haskellers, I happened to defined a function whenJust whose definition is like this:
whenJust :: (Monad m) => (a -> m ()) -> Maybe a -> m () whenJust = maybe (return ())
while I was writing a fun utility to upload to hackage. I had a strong feeling that someone must have defined this already, so I used Hayoo, and I did find it: XMonad.Core.whenJust :: Monad m => Maybe a -> (a -> m ()) -> m () The argument order is different I believe it is dong the same thing. Shouldn't we add add whenJust to more general library regarding Monad and Maybe, so that we can used it as a standard idiom? I think its much more readable writing "maybe (return ())" or "flip (maybe (return ()))". -- Ahn, Ki Yung