| Start |
|---|
| Sections Sectioning is a concise way to partially apply arguments to infix operators. For example, if we want to write a function which adds "ing" to the end of a word we can use a section to succinctly define a function. Notice how we have partially applied the second argument. Normally, we can only partially apply the arguments in the specified order. We can also use left sectioning to partially apply the first argument. We could equivalently write this using normal prefix partial application: A Note on SubtractionBeginners often incorrectly section negation. This does not work as |
| Partially Applied Adding Function We can use partial application to "lock" the first argument. After applying one argument we are left with a function which expects one more argument before returning the result. We can then use |
| Returning a Partially Applied Function Returning partially applied functions is one technique to write concise code. In this example (+x) is a partially applied function. Notice that the second parameter to the add function does not need to be specified in the function definition. The result of calling RemarksLet's clear up some misconceptions that beginners might make. You may have encountered functions such as: Beginners will typically view Indeed, Consider the type signature of
The confusion stems from the fact that in mathematics and many, other, common programming languages, we are allowed to have functions that take multiple arguments. However, in Haskell, functions can only take one argument and they can return either values such as |
Read Article
https://develop.horje.com/learn/1434/reference