[Haskell-cafe] Partial application

Dougal Stanton ithika at gmail.com
Thu Jan 18 04:46:34 EST 2007


Quoth phiroc at free.fr, nevermore,
> could someone please give me an example of the "partial application" of the
> following curried function:
> 
> add' :: Int -> Int -> Int
> add' a b = a + b
> 
> Normally, add' 1 should work, but it doesn't.

I think this is what you mean. If not, then please advice. This is typed
into a vanilla ghci prompt, no extra modules loaded or flags switched
on. There is no smoke and mirrors at work ;-)

(The ':: Int' constrains the type of b, and therefore all the other
numbers, but doesn't affect the function application.)

> Prelude> let add' a b = a + b :: Int
> Prelude> let f = add' 1
> Prelude> f 2
> 3

Is this what you wanted? Perhaps you tried this but mistyped something?

Regards,

D.
-- 
Dougal Stanton <ithika at gmail.com>
<http://brokenhut.livejournal.com>
Word attachments considered harmful.


More information about the Haskell-Cafe mailing list