
Herbert Valerio Riedel wrote:
On 2013-12-08 at 02:06:26 +0100, Ben Franksen wrote:
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).
fyi, this has been suggested a few months ago as part of
http://comments.gmane.org/gmane.comp.lang.haskell.libraries/18952
and as a matter of fact has been already implemented in base-4.7.0.0:
https://github.com/ghc/packages-base/blob/master/Data/Functor.hs#L36-L40
Thanks, I'm glad the proposal has been obsoleted in this way. Count it as a +1 after the fact ;-) Cheers Ben -- "Make it so they have to reboot after every typo." -- Scott Adams