Search code examples
functional-programmingprogramming-languages

A functional programming language with a higher-order function similar to Haskell's flip but uncurried


Is there any functional programming language whose functions are not automatically curried, which has a built-in or library higher-order function that takes a function of the form (AxB)->C and returns an equivalent function of the form (BxA)->C? This is similar to Haskell's flip function.


Solution

  • In "Homotopy Type Theory" in 1.4 on page 26 the function for the curried version is called "swap":

    swap: Π(A:U)Π(B:U)Π(C:U) (A -> B -> C) -> (B -> A -> C)
    
    swap(A, B, C, g)(b, a) := λb.λa.g(a)(b)
    

    I don't know why you would want to have a separate name for the uncurried version, what's the difference anyway...