by adamddev1 · 2w ago · 0 comments
Missing currying feels a little to me like walking in FP land with one leg cut off.
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?See the relevant docs: https://tour.gleam.run/everything/#functions-function-captur...
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,
Plenty of practical reasons for currying, but the biggest (imo) is for use with the pipe operator.
If they don't have partial application now, what are the odds they'll have it in the future?
An alternative is providing variations on a function that "bundle" sets of arguments, and then making the bundle the first parameter, but that only makes sense when the "bundles" occur together a lot.