# Partial application

### From HaskellWiki

Revision as of 04:54, 14 January 2007 by BrettGiles (Talk | contribs)

Partial application in Haskell involves passing less than the full number of arguments to a function that takes multiple arguments.

## 1 Examples

### 1.1 Simple introduction

For example:

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

addOne

add

->

add :: Int -> (Int -> Int)

This means that add actually takes one argument and returns a function that takes another argument and returns an Int.

### 1.2 Slightly more complicated

What if you have a Higher order function?

For example:

comp2 :: (a -> b) -> (b -> b -> c) -> (a -> a -> c) comp2 f g = (\x y -> g (f x) (f y))

Remembering the maxim that: *Functions are not partial, you can partially apply a function.*

comp2'

comp2' f = (\x y -> add (f x) (f y))

comp2

`comp2' f = comp2 f add`