[Haskell-cafe] Re: [Haskell-beginners] map question

wren ng thornton wren at freegeek.org
Wed Oct 21 01:17:21 EDT 2009


minh thu wrote:
> Something I wonder from time to time if it would be a good thing or
> not is to allow
>   a `f g` b
> to mean
>   f g a b

This comes up from time to time, though it is often met with stern 
disapproval because it can easily lead to loss of clarity. There is a 
valid alternative, though it's not quite as pretty:

     ($a) (f g...) b c... == f g... a b c...



With even less prettiness, this can also be generalized for other 
numbers of prefix arguments:

     (            ($a) f) b c... == f a b c...
     (      ($b) $($a) f) c d... == f a b c d...
     (($c) $($b) $($a) f) d e... == f a b c d e...

And if anyone wanted to use this sort of pattern frequently, I'm sure 
there's some decent way to clean it up ala Matt Hellige's pointless 
trick[1] or ala Oleg's polyvariadic trick[2].


[1] http://matt.immute.net/content/pointless-fun
[2] http://okmij.org/ftp/Haskell/polyvariadic.html

-- 
Live well,
~wren


More information about the Haskell-Cafe mailing list