Add flipped fmap

Jesper Louis Andersen jesper.louis.andersen at gmail.com
Wed Apr 7 08:34:29 EDT 2010


On Wed, Apr 7, 2010 at 11:13 AM, Bas van Dijk <v.dijk.bas at gmail.com> wrote:

> I would like to propose adding a flipped variant of <$> to Data.Functor:
>
> (<$$>) ∷ Functor f ⇒ f α → (α → β) → f β
> (<$$>) = flip (<$>)
>

It is worth doing some simple statistics: There are 5939 hackage
packages in my git-repo archive. Of these, there are 10 apps which
import Data.Functor directly. The number for Control.Applicative is
418. 'flip\s*<$>' is defined by 6 different packages:

jlouis at jlouis-desktop:~/Projects/hackage$ git grep 'flip\s\+<\$>' |
sed -e 's/:.*$//'
HXQ-0.18.2.tar.gz.dir/HXQ-0.18.2/src/hxml-0.2/LLParsing.hs
HXQ-0.18.2.tar.gz.dir/HXQ-0.18.2/src/hxml-0.2/LLParsing.hs
action-permutations-0.0.0.0.tar.gz.dir/action-permutations-0.0.0.0/Control/Applicative/Permutation.hs
curry-frontend-0.2.9.tar.gz.dir/curry-frontend-0.2.9/src/Curry/Syntax/LLParseComb.lhs
curry-frontend-0.2.9.tar.gz.dir/curry-frontend-0.2.9/src/Curry/Syntax/LLParseComb.lhs
ideas-0.5.8.tar.gz.dir/ideas-0.5.8/src/Text/Parsing.hs
uu-parsinglib-2.3.1.tar.gz.dir/uu-parsinglib-2.3.1/src/Text/ParserCombinators/UU/Derived.hs
uu-parsinglib-2.3.1.tar.gz.dir/uu-parsinglib-2.3.1/src/Text/ParserCombinators/UU/Derived.hs
uu-parsinglib-2.3.1.tar.gz.dir/uu-parsinglib-2.3.1/src/Text/ParserCombinators/UU/Derived.hs
uu-parsinglib-2.3.1.tar.gz.dir/uu-parsinglib-2.3.1/src/Text/ParserCombinators/UU/Derived.hs
uulib-0.9.12.tar.gz.dir/uulib-0.9.12/src/UU/Parsing/Derived.hs
uulib-0.9.12.tar.gz.dir/uulib-0.9.12/src/UU/Parsing/Derived.hs
uulib-0.9.12.tar.gz.dir/uulib-0.9.12/src/UU/Parsing/Derived.hs
uulib-0.9.12.tar.gz.dir/uulib-0.9.12/src/UU/Parsing/Derived.hs

The confounder is: How many packages would have used the flipped
variant had they had access to it. Personally, I wouldn't add it, but
it cannot hurt since only 10 hackage packages would potentially be
affected by the change. For non-hackage packages, if the hackage
packages are taken as a sample, we have 0.1% of the packages affected
(fewer, actually).

-- 
J.


More information about the Libraries mailing list