Proposal: add $> to Data.Functor
Ben Franksen
ben.franksen at online.de
Sun Dec 8 01:06:26 UTC 2013
Data.Functor has <$> and <$, but not $>, which should be a flipped version
of <$, analogous to <*>, <*, and *> in Control.Applicative. I was astonished
to see that Data.Functor doesn't have it so I had to write it myself. Then I
looked on hackage and found it defined in comonad package (also re-exported
from semigroupoids). One (seemingly unmaintained, last version Apr 2012)
package named iterIO has it, too.
infixl 4 $>
-- | Replace the contents of a functor uniformly with a constant value.
($>) :: Functor f => f b -> a -> f a
($>) = flip (<$)
I propose to add this to Data.Functor; mostly because I think users expect
it there (again by analogy with Applicative), even though it is trivial to
write (but then writing <$ is trivial, too).
Cheers
Ben
--
"Make it so they have to reboot after every typo." -- Scott Adams
More information about the Libraries
mailing list