Skip to content

ssteele/curry-town

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Curry Town

Currying is a functional programming (FP) paradigm that breaks down functions that take multiple arguments into a sequence of functions each taking only one argument.

Why would you want to do such a thing?

Currying encourages the creation of pure functions with single responsibilities. It increases maintainability and fits within the greater idea of functional programming that seeks to avoid tedious bugs arising from side effects or collisions with application state/context. These are the kind of bugs that tend to crop up in large applications.

This pattern is completely in-line with JavaScript guiding principles and is well established in the language. If you've ever used or written a closure, you've performed basic currying:

const greeting = (message) => {
   return (name) => {
        return `${message} ${name}`;
   }
}
let sayHi = greeting('Hi');
let sayHello = greeting('Hello');

console.log(sayHi('John'));     // Hi John
console.log(sayHello('John'));  // Hello John

This is a sandbox to play around with and learn currying. Here is a helpful resource to learn more about practical currying.

develop

cd curry-town
npm i
npm run watch

Open dist/index.html in your preferred browser.

deploy

npm run build
copy `dist/*` to web server

http://curry-town.steve-steele.com

About

FP curried restaurant bill calculation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published