A Case Against Currying

27 points by fanf


apropos

(Automatic) currying also causes serious issues with ownership-style systems. Jane Street is/was considering adding a special non-curried function arrow to OCaml, just because of how much it would simplify their "Oxidizing OCaml" system...

fanf

See also the recent Coalton article in which they too decided against currying.

manuel

There's a Scheme version of such an explicit currying operator: https://srfi.schemers.org/srfi-26/srfi-26.html, e.g.

(cut + 1 <>) is the same as (lambda (x) (+ 1 x))

(And, Scheme being a serious language, it's implemented in the language itself in 20 lines.)

ettolrach

Dependent types are famously immensely difficult to work with and make type inference undecidable, so even when you're working in a language with this capability, it's best to avoid dependent types in function parameters.

we could argue about the first point, but type inference is also undecidable in any language with generics (since System F's typechecking/inference is undecidable) which is basically all commonly typed languages nowadays except C, so i don't see why that's a reason not to use dependent types

dpc_pw

I don't have a strong opinions on this as I don't deal with currying languages on a daily basis, but to me it always seemed like a case of noticing a special case and running with it too far. Kind of like nulls.

jkarni

There are other arguments in favor of currying that didn't get mentioned:

With these points added, I'd say the balance is "if your language is functional and frequently polymorphic, curried functions are great". And that is in fact where currying gets most often used!

Two other small points: