Skip to content

Pipeline Placeholders #75

@gilbert

Description

@gilbert

I'd like to explore an alternative to the partial application proposal that would only be used in conjunction with the pipeline operator.

There has been discussion around using ? as a placeholder for functions with multiple arguments. Consider the readme example:

let person = { score: 25 };

let newScore = person.score
  |> double
  |> (_ => add(7, _))
  |> (_ => boundScore(0, 100, _));

newScore //=> 57

If the ? were to be built into the pipeline operator, we could rewrite the example to the following:

let newScore = person.score
  |> double
  |> add(7, ?)
  |> boundScore(0, 100, ?);

and since this placeholder is scoped to the pipeline operator, it has the potential to be more expressive:

let ex1 = person |> double(?.score);
let ex2 = person.score |> add(?, ?);

and potentially allow member expressions?

let x = 10 |> f |> ?.foo |> g;

On the other hand, any sort of ? placeholder might have people let write strange things like
x |> f(? ? ? : 10). Is this problematic?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions