Class BindExpression


public class BindExpression extends Expression
"$INTERNAL$BIND"(value, targetFunction)

When invoked, the returned function inserts the given value as the leading argument to the targetFunction. The other arguments are passed unchanged.

Bind is fundamentally first class, just like function applications. It requires special treatment from the type system. There is no way to write out the type of `bind`. The return type of `bind` is function. Its type looks somewhat like:

  • X, (X) -> Y => () -> Y
  • X1, (X1, X2) -> Y => (X2) -> Y
  • X1, (X1, X2, X3) -> Y => (X2, X3) -> Y
  • X1, (X1, X2, X3, X4) -> Y => (X2, X3, X4) -> Y
  • ...

Lambda capturing is implemented through desugaring in Trino. This expression facilitates desugaring.