On Thu, Apr 24, 2008 at 6:06 PM, Twan van Laarhoven <twanvl@gmail.com> wrote:
Cale Gibbard wrote:
Hello,
In keeping with my small but seemingly extremely controversial suggestions for changes to the Prelude, here's a suggestion which I think is elegant and worth considering for the Haskell' Prelude:
Rename fmap to map (like it was in Haskell 1.4), and define (.) as a synonym for it.
One thing I fear (though that fear may be irrational) is that you get code that looks like "(.) . ((.) . (.) .)". To me, and I expect to many people, map and composition are different things, and used in different ways. If both are written as a dot it will take extra mental effort to decipher the meaning of a program. The potential for writing code that resembles the worst outputs of the @pl lambdabot plugin also becomes larger.
I'd much rather keep composition and functor map separate. I'm still not entirely sure that generalizing (.) to other morphisms in the Category class is a good idea. Function composition gets used a *lot*, and I imagine we'd loose a lot of inlining if it became a class method.
Secondly, I am really fond of the Applicative notation <$>, which goes great together with <*>. A lighter notation would be nice, but I see no good way to do that. (Perhaps we need to add syntactic sugar for idiom brackets?)
As much as I like Applicative, I dislike the name "<*>". To me, it makes more sense to use "<$>" for <*>, since it's application of wrapped functions. I've used "$^" as a synonym for fmap (because it's lifted application). It would be nice to have sugar for idiom brackets. You can simulate them with a class, but the result typically doesn't stand out enough visually as being special syntax. -- Dave Menendez <dave@zednenem.com> <http://www.eyrie.org/~zednenem/>