Generalizing map?

David Feuer david.feuer at gmail.com
Fri Mar 13 13:44:40 UTC 2015


We need to be very careful to make sure we don't break list fusion.
map is one of relatively few functions that are both "good consumers"
and "good producers". This makes it especially sensitive to anything
affecting simplification. Making map be fmap means that it will not be
recognized as the thing that should fuse until later in the process,
and we want to be sure that doesn't kill all the benchmarks.

-- 
David Feuer
If you like my advice, please hire me.

On Fri, Mar 13, 2015 at 5:32 AM, Fumiaki Kinoshita <fumiexcel at gmail.com> wrote:
> A dozen of functions like concat, foldr, mapM, have been generalized through
> BBP.
>
> Then, why do we leave `map` just for lists? Obviously `map` can be
> generalized, so
>
> map :: Functor f => (a -> b) -> f a -> f b
> map = fmap
>
> The current definition of `map` looks too special to be a special case of
> mapM (map f = runIdentity . mapM (Identity . f)).
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>


More information about the Libraries mailing list