Question: I'm having trouble understanding curried and uncurried functions. All the sites I Google'd to try to provide me a definition were unclear to me.

In one example I found them saying that

`max 4 5` is the same as `(max 4) 5`

But I don't understand what they're doing. How can you have a function `(max 4)` when max requires 2 parameters? I'm completely lost.

Answer: 
The trick with Haskell is that functions only take one argument. This seems totally crazy but it actually works.

A haskell function:

```
foo :: Int -> Int -> Int
foo a b = a + b

```

Really means: A function which takes in 1 argument, and then **returns another function which takes one argument**. This is called currying.

So using this, we can really write this function definition like this:

```
foo :: Int -> (Int -> Int) --In math speak: right associative

```

and mean exactly the same thing.

This is actually super useful because we can now write concise code like:

```
foo1 :: Int -> Int
foo1 = foo 1

```

Since function application in haskell is just whitespace, most of the time you can just pretend that curried functions are uncurried (taking more than one argument and just returning a result).

If you really really realllly need uncurried functions: Use tuples.

```
uncFoo :: (Int, Int) -> Int
uncFoo (a, b) = a + b

```

**Edit**

OK so to understand whats going on with partial application consider `bar`

```
bar a b c = [a, b, c]

```

The thing is, the compiler will desugar what you just typed into lambdas like this

```
bar = \a ->
      \b ->
      \c ->
           [a, b, c]

```

This takes advantage of closures (each inner function can 'remember' the arguments to the previous ones.

so when we say `bar 1`, the compiler goes and looks at `bar` and sees the outermost lambda, and applies it giving

```
bar 1 = \b ->
        \c ->
             [1, b, c]

```

If we say `bar 1 2`

```
bar 1 2 = \c ->
                [1, 2, c]

```

If what I mean when I say "apply" is hazy, then it may help to know that I really mean [beta reduction](http://en.wikipedia.org/wiki/Lambda_calculus#.CE.B2-reduction) from lambda calculus.
Depending on your background, you may find this paper enlightening: **[How to Make a Fast Curry: Push/Enter vs Eval Apply](http://research.microsoft.com/en-us/um/people/simonpj/Papers/eval-apply/index.htm)**. While it's true that multi-argument functions can be understood as functions which bind a single parameter and return another function: `max = (\a -> (\b -> if a > b then a else b))`, the actual implementation is quite a bit more efficient.

If the compiler knows statically that `max` requires two arguments, the compiler will always translate `max 4 5` by pushing the two arguments on the stack (or in registers) and then invoking `max`. This is essentially the same as how a C compiler would translate `max(4, 5)`.

On the other hand, if for instance `max` is an argument to a higher-order function, the compiler may not know statically how many arguments `max` takes. Perhaps in one instance it takes three, so `max 4 5` is a partial application, or perhaps in another it takes only one and `max 4` generates a new function to which `5` is applied. The paper discusses the two common approaches to handling the case where the arity isn't known statically.