#4189: Add (<.>) operator (generalizing (.) to Functor)

David Menendez dave at zednenem.com
Mon Aug 2 10:52:21 EDT 2010


On Sun, Aug 1, 2010 at 9:52 AM, Maciej Marcin Piechotka
<uzytkownik2 at gmail.com> wrote:
> The proposal is to add (<.>) function to Data.Functor/Control.Applicative:
> (<.>) :: (b -> c) -> (a -> f b) -> a -> f c
> f <.> g = fmap f . g -- (<.>) = (.) . fmap
>
> In intend it is related to <$> in the same way as (.) is related to $:
> (a . b . c) d = a $ b $ c $ d
> (a <.> b <.> c) d = a <$> b <$> c <$> d

I'm not convinced. "fmap f . g" isn't that much longer than "f <.> g"
and requires no new combinators.

I'd argue that "fmap f . fmap g . h" is better style, since it's
obvious that this should be rewritten as "fmap (f . g) . h". In the
example above, "a <$> b <$> c <$> d" is best transformed to "a . b . c
<$> d".

-- 
Dave Menendez <dave at zednenem.com>
<http://www.eyrie.org/~zednenem/>


More information about the Libraries mailing list