Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Function

Lean: Hale.Base.Function | Haskell: Data.Function

Overview

Standard function combinators: on, applyTo (&), const (K combinator), flip (C combinator).

API Mapping

LeanHaskellKind
Function.ononCombinator
Function.applyTo(&)Combinator
Function.constconstCombinator
Function.flipflipCombinator

Instances

None (standalone functions).

Proofs & Guarantees

  • on_apply(f.on g) x y = f (g x) (g y)
  • applyTo_applyx.applyTo f = f x
  • const_applyFunction.const a b = a
  • flip_flipflip (flip f) = f (involution)
  • flip_applyFunction.flip f x y = f y x

Example

-- Compare strings by length
Function.on (· + ·) String.length "hi" "hello"
-- => 7