#4189: Add (<.>) operator (generalizing (.) to Functor)
Henning Thielemann
lemming at henning-thielemann.de
Mon Aug 2 12:44:43 EDT 2010
On Mon, 2 Aug 2010, David Menendez wrote:
> 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.
'f' and 'g' might be infix expressions. Depending on the precedence we had
to compare
"fmap (f) . g" with "f <.> g"
or
"fmap (f) . (g)" with "f <.> g"
.
> 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".
I am also happy with
fmap f . fmap g . h
and
a . b . c <$> d
.
More information about the Libraries
mailing list