[Haskell] is $ a no-op?

Cale Gibbard cgibbard at gmail.com
Wed Oct 13 19:48:01 EDT 2004


On Wed, 13 Oct 2004 18:06:01 +0100, Malcolm Wallace
<malcolm.wallace at cs.york.ac.uk> wrote:
> "Jacques Carette" <carette at mcmaster.ca> writes:
> 
> > > -- |Apply list of functions to some value, returning list of results.
> > > --  It's kind of like an converse map.
> > > flist :: [a->b] -> a -> [b]
> > > flist fs a = map ($ a) fs
> >
> > I have attempted, unsuccessfully, to write flist above in a point-free
> > manner.  Is it possible?
> 
>     flist = flip (map . (flip ($)))
> 

Note that if you define

swing :: (((a -> b) -> b) -> c -> d) -> c -> a -> d
swing f = flip (f . flip ($))

then you can get this sort of effect uniformly in a number of situations:

swing map :: forall a b. [a -> b] -> a -> [b]
swing any :: forall a. [a -> Bool] -> a -> Bool
swing foldr :: forall a b. b -> a -> [a -> b -> b] -> b


More information about the Haskell mailing list