[Haskell-cafe] The difference between ($) and application

Andres Loeh andres at cs.uu.nl
Tue Dec 14 12:16:26 EST 2004


> Date: Tue, 14 Dec 2004 10:24:15 -0500
> From: Andrew Pimlott <andrew at pimlott.net>
> Subject: Re: [Haskell-cafe] The difference between ($) and application
> 
> On Tue, Dec 14, 2004 at 11:23:24AM +0100, Henning Thielemann wrote:
> > 
> > On Tue, 14 Dec 2004, Andrew Pimlott wrote:
> > 
> > > (Of course, it's still useful, by itself or in a slice, as a higher-order
> > > operator.)
> > 
> > You can also use 'id' in this cases, right?
> 
> I'm thinking of things like
> 
>     zipWith ($)
>     map ($ x)

You can indeed use

zipWith id
map (`id` x)

instead. Look at the types:

id  :: a         ->  a
($) :: (a -> b)  ->  (a -> b)

The function ($) is the identity function, 
restricted to functions.

Nevertheless, I find using ($) in such a situation 
more descriptive than using id.

Cheers,
  Andres


More information about the Haskell-Cafe mailing list