Libraries Digest, Vol 117, Issue 10
Andreas Abel
andreas.abel at ifi.lmu.de
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.
+1.
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:
http://www.haskell.org/pipermail/libraries/2009-June/011836.html
Nov 2011:
http://haskell.1045720.n5.nabble.com/Proposal-add-Control-Monad-whenJust-Monad-m-Maybe-m-m-td5034761.html
Dec 2012:
http://comments.gmane.org/gmane.comp.lang.haskell.libraries/18519
See also Felipe's post at:
https://groups.google.com/forum/?fromgroups=#!topic/haskell-cafe/aWtC8DRfGYs
Cheers,
Andreas
> On Fri, May 10, 2013 at 4:00 PM, Gwern Branwen <gwern at gwern.net> wrote:
>> On Fri, May 10, 2013 at 2:54 PM, Chris Seaton <chris at chrisseaton.com> 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
>> http://www.gwern.net
--
Andreas Abel <>< Du bist der geliebte Mensch.
Theoretical Computer Science, University of Munich
Oettingenstr. 67, D-80538 Munich, GERMANY
andreas.abel at ifi.lmu.de
http://www2.tcs.ifi.lmu.de/~abel/
More information about the Libraries
mailing list