
Hi, Am Mittwoch, den 17.02.2016, 15:21 +0300 schrieb Kosyrev Serge:
Does this monster
liftA2 (<$) id (guard ∘ f)
really stand for
\x -> if f x then Just x else Nothing
?
Is there really no simpler "compact" representation for this trivial idea in Haskell?
I vaguely remember a discussion about adding a combinator doing that to the libray, and some googling turned out that there was a proposal 6 years ago by... me: https://ghc.haskell.org/trac/ghc/ticket/3446 (Well, not quite, the type was justIf :: a -> Bool -> Just a and not justIf :: a -> (a -> Bool) -> Just a and this shows that there are probably too many variants to warrant an addition of some or all of them to the standard library). The corresponding discussion on the libraries¹ list discussed some of the variants, and also turned up an even older equivalent proposal by Henning Thielemann² from 12 years ago. Greetings, Joachim ¹ https://mail.haskell.org/pipermail/libraries/2009-August/012413.html ² https://mail.haskell.org/pipermail/libraries/2004-July/002381.html -- Joachim “nomeata” Breitner mail@joachim-breitner.de • https://www.joachim-breitner.de/ XMPP: nomeata@joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F Debian Developer: nomeata@debian.org