mlhaufe / brevity

Brevity is a library that enables Feature-Oriented Programming (FOP) and solves the expression problem in a manner that makes data and operation declarations trivial to define and compose.
GNU Affero General Public License v3.0
1 stars 0 forks source link

Partial Application of traits #41

Closed mlhaufe closed 1 year ago

mlhaufe commented 1 year ago

Partial application of traits:

const add3 = Trait(Number, {  
  _: (a, b, c) => a + b + c 
})

add3(1, 2, 3) === 6
add3(_, 2, 3)(1) === 6
add3(1, _, 3)(2) === 6
add3(1, 2, _)(3) === 6
add3(1, _, _)(2, 3) === 6
add3(_, 2, _)(1, 3) === 6
add3(_, _, 3)(1, 2) === 6
add3(_, _, _)(1, 2, 3) === 6
add3(_, _, _)(_, 2, _)(1, 3) === 6