@[inline]
def
Data.Function.on
{β : Sort u_1}
{γ : Sort u_2}
{α : Sort u_3}
(f : β → β → γ)
(g : α → β)
(x y : α)
:
γ
The on combinator lifts a binary function through a unary projection:
$$(\texttt{on}\; f\; g)\; x\; y \;=\; f\,(g\,x)\,(g\,y)$$
Commonly used to compare or combine values by a derived key,
e.g., on compare String.length compares strings by length.
Equations
- Data.Function.on f g x y = f (g x) (g y)
Instances For
@[inline]
Flip of function application (Haskell's (&) operator):
$$\texttt{applyTo}\; x\; f \;=\; f\,x$$
Useful for piping a value through a chain of transformations.
Equations
- Data.Function.applyTo x f = f x
Instances For
@[inline]
The constant combinator $K$:
$$\texttt{const}\; a\; b \;=\; a$$
Ignores its second argument and always returns the first. In combinatory logic this is the $K$ combinator.
Equations
- Data.Function.const a x✝ = a
Instances For
@[inline]
def
Data.Function.flip
{α : Sort u_1}
{β : Sort u_2}
{γ : Sort u_3}
(f : α → β → γ)
(b : β)
(a : α)
:
γ
Flip the argument order of a binary function:
$$\texttt{flip}\; f\; b\; a \;=\; f\; a\; b$$
In combinatory logic this is the $C$ combinator.
Equations
- Data.Function.flip f b a = f a b