Libraries Digest, Vol 117, Issue 10

Andreas Abel andreas.abel at
Fri May 10 22:04:21 CEST 2013

On 10.05.13 9:30 PM, Felipe Almeida Lessa wrote:
> IMNSHO, I think we should just add
> -- | @whenJust = 'for_'@.  Executes the given action
> -- when @Just@, execute nothing if @Nothing at .
> whenJust :: Monad m => Maybe a -> (a -> m ()) -> m ()
> whenJust = for_
> to Data.Maybe.  Even if it's duplicating a functionality, it's a good
> name that has been reinvented by many people.  Its docs may mention
> for_ and teach the user that for_ is more generic etc.  People looking
> for whenJust *will* look at Data.Maybe.  We don't lose much by adding
> this function.


whenJust seems to be canonical and is reinvented again and again.  We 
can add it now or have the next discussion in 6 month or a year.

Previous discussions:

June 2009:

Nov 2011:

Dec 2012:

See also Felipe's post at:!topic/haskell-cafe/aWtC8DRfGYs


> On Fri, May 10, 2013 at 4:00 PM, Gwern Branwen <gwern at> wrote:
>> On Fri, May 10, 2013 at 2:54 PM, Chris Seaton <chris at> wrote:
>>> Perhaps we should have a dummy module in Hackage that includes commonly
>>> searched for functions, but instead of actually implementing them the
>>> documentation would say don't use this and suggest an alternative and
>>> explains why. Then you could find them in Hoogle and Hackage seems to be
>>> highly ranked on Google so they'd be found there as well.
>> Or expand hlint to catch whenJust like constructs and suggest use of
>> the alternative? We already did that for when 'void' was added, put in
>> a suggestion looking for things like '>> return ()'
>> --
>> gwern

Andreas Abel  <><      Du bist der geliebte Mensch.

Theoretical Computer Science, University of Munich
Oettingenstr. 67, D-80538 Munich, GERMANY

andreas.abel at

More information about the Libraries mailing list