> In particular, if fmap is an expensive operation, it is likely better to use liftA2 than to (fmap over the structure and then use <*>)(emphasis and parens added).

Consider any data constructor that has a strict spine and look at

f <$> m <*> n

This has to walk `m` twice. Once for the fmap on the first argument, and once for the <*>, but the liftA2 version can walk `m` once fusing things together.

-Edward 

On Tue, Jan 30, 2018 at 4:42 AM, Damien BIHEL <biheldamien@gmail.com> wrote:
In the documentation here it's written that for some functors liftA2 has better performance than fmap. Does anyone have any examples ?

Regards,

--
Damien Bihel
R&D (Research & Development) Engineer at ELRA (European Language Resources Association)
E-Mail: biheldamien@gmail.com

_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell