Skip to content

Partial Application: Stage 1 #32

Description

@jamiebuilds

Champion: @rbuckton
Repo: https://github.com/rbuckton/proposal-partial-application
Slides: https://docs.google.com/presentation/d/1GSnqtT1jHbilIAwCuaK2yjKNj0y6cLfJNisZDig3Nm8/edit?usp=sharing
First presented at the Sept 2017 meeting

Example

const addOne = add(1, ?); // apply from the left
addOne(2); // 3

const addTen = add(?, 10); // apply from the right
addTen(2); // 12

// with pipeline
let newScore = player.score
  |> add(7, ?)
  |> clamp(0, 100, ?); // shallow stack, the pipe to `clamp` is the same frame as the pipe to `add`.

const maxGreaterThanZero = Math.max(0, ...);
maxGreaterThanZero(1, 2); // 2
maxGreaterThanZero(-1, -2); // 0

Syntax

f(x, ?)           // partial application from left
f(x, ...)         // partial application from left with rest
f(?, x)           // partial application from right
f(..., x)         // partial application from right with rest
f(?, x, ?)        // partial application for any arg
f(..., x, ...)    // partial application for any arg with rest

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions