[Haskell-cafe] Partially applied functions

Ozgur Akgun ozgurakgun at gmail.com
Sat Nov 28 10:52:12 EST 2009

Hi cafe,

Is such a thing possible,

add :: Int -> Int -> Int
add x y = x + y

-- a list of partially applied functions
adds = [add 3, add 5, add 7, add 3, add 5, add 8]

-- an example usage of the list
k = map (\ f -> f 10 ) adds

add3s = filter (?) adds -- add3s = [add 3, add 3]
addEvens = filter (?) adds --addEvens = [add 8]

I want to have functions in place of the ? signs. I guess one would need a
way of extracting the applied value from a partially applied function (or
totally, doesn't matter)

I came across such a structure while designing an algotihm and used data
structures to represent functions and solved the problem. But this doesn't
seem very *cute* to me and requires some bolier-plate (if you have a lot of
this structure everywhere) , that's why I am asking for your precious


Ozgur Akgun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091128/c4a10a0f/attachment.html

More information about the Haskell-Cafe mailing list