Skip to content

flip vs Function.swap #36902

@Komyyy

Description

@Komyyy
-- Defined in `Init.Core`
def flip {α β : Sort*} {γ : Sort*} (f : α → β → γ) : β → α → φ :=
  fun b a ↦ f a b

-- Defined in `Mathlib.Logic.Function.Defs`
abbrev Function.swap {α β : Sort*} {φ : α → β → Sort*} (f : Π x y, φ x y) : Π y x, φ x y :=
  fun y x ↦ f x y

These are almost the same, and both have a non-negligible number of related APIs(flip: 72, Function.swap: 165).
These should be unified.

Personally, I think these should be unified to flip, since it is defined in the core library, and Function.swap is easily confused with Prod.swap.

Updated: α and β in flip is Sort*, not Type*.

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