E4117

E4117#

Function with labelled arguments can only be applied directly.

This means you cannot pass a function with labelled arguments as an argument to another function.

Erroneous example#

///|
pub fn accumulate(acc~ : Int, value : Int) -> Int {
  acc + value
}

///|
test {
  let xs = [1, 2, 3, 4, 5]
  let sum = xs.fold(init=0, accumulate)
  //                       ^~~~~~~~~~~~
  // Error: Function with labelled arguments can only be applied directly.
}

Use Partial Applications to create a function value without labelled arguments.

Suggestion#

///|
pub fn accumulate(acc~ : Int, value : Int) -> Int {
  acc + value
}

///|
test {
  let xs = [1, 2, 3, 4, 5]
  let sum = xs.fold(init=0, fn(acc, value) { accumulate(acc~, value) })
  inspect(sum, content="15")
}