DEV Community

Discussion on: Partial Application of Functions in Elm

Collapse
 
eljayadobe profile image
Eljay-Adobe

To express the equivalent greeting as a curried function in JavaScript (ES6):

const greeting = (a) => (b) => { return "" + a + ", " + b + "!"; }
const message = greeting("Hello")("world")

I much prefer the Elm syntax. Much cleaner; obviously influenced by OCaml.

Puts functional programming first, and syntactically path of least resistance.

Collapse
 
eljayadobe profile image
Eljay-Adobe

One of my buddies pointed out that it would be cleaner using more ES6-isms:

const greeting = (a) => (b) => { return `${a}, ${b}!`; }
Collapse
 
disfated profile image
disfated

Just to clean this up.

const greeting = a => b => `${a}, ${b}!`