Remix.run Logo
▲ kaoD 9 hours ago

I never liked currying. It feels more theoretically elegant than practically useful.

IMO it is hard to read (unless you're very familiar with the functions at hand), produces type errors that are not easy to follow (oops, I forgot the last arg), and is too rigid (I often need to partially apply arguments in non left-to-right order).

I never understood why partial application via "slots" isn't more common though (I just made up the term, not sure if this has a name). Like Clojure's:

    #(f %2 "foo" %1 "bar")
    ;; same as
    (fn [a b] (f b "foo" a "bar"))
Does Gleam have something like that?
▲nchagnet 8 hours ago | parent | next [-]

Yes Gleam allows you to do f(arg, _)

See the relevant docs: https://tour.gleam.run/everything/#functions-function-captur...

▲riffraff an hour ago | parent [-]

But that's a single argument right?

Seems more limiting than the closure way. Scala allows multiple _ but in turn that doesn't allow changing ordering.

TBH, I feel this stuff is not really worth it,

▲yladiz 28 minutes ago | parent [-]

I think the single hole version is a good compromise compared to actual currying or multiple holes, since it's strictly better than something like first or last argument threading (e.g. ->, ->> in Clojure), easier to reason about than currying, and in my experience most of the time you'll only be dealing with one argument to pass piping anyway. Anonymous functions are fine for the cases you need more flexibility.

▲senderista 3 hours ago | parent | prev [-]

Are there any physicists out there who are reminded of abstract index notation for tensors?