Replies: 1 comment 1 reply
-
Hi Darren, thanks for the feedback and for putting up with our extremely breaking changes! Syntactic sugar for partial application This is definitely on the roadmap. As you suggest, having a "placeholder" symbol in argument position seem like the way to go. We already use New function application syntax
Yes, this is confusing. In the new syntax, The main reason to keep application-via-juxtaposition at all was to handle trailing continuations without having closing parens many lines down:
I initially tried just adopting the convention of writing functions like Meanwhile I was also trying to figure out how to handle a "pipe" operator. Unix-style pipelines are such a nice way to write programs when the main data flow is a chain. If everythig is curried we can make an ordinary infix operator like But both problems go away if we're willing to treat So that's where I ended up. I know it's a bit complicated but it's purely syntactic, and I think it handles those three dataflow styles pretty well:
A lot of program text ends up being about routing data between functions. So function application seems like a good place to spend some of our syntactic sugar budget. That said, we now have six different ways to write function application: parens, infix ops, pipe, juxtaposition, dollar, and dot-method access. And then we have named optional args and currying syntax on top of that! Have we gone too far? Currying some things by convetion I totally agree with you about |
Beta Was this translation helpful? Give feedback.
-
I've updated all of the Dex examples in my logistic regression repo and FP crash course. It all went reasonably smoothly, and I generally prefer the new syntax, but it did throw up a couple of issues.
First, it turns out that I use partial application a lot. eg. I would typically do something like:
which now doesn't work. Obviously I can use a lambda for this:
But that's not quite as clean. In Scala you could partially apply a function like this with something like:
or
The errors I get from Dex suggest that this might be on the roadmap? Something like this would be good.
But irrespective of this, some functions are probably better explicitly curried. eg. I would have thought that
grad
would be better curried by default.Similarly, for any random functions (including the
draw
function in the stats library), it might make sense to always have the key curried off separately at the end of the type signature. This way the partially applied function represents the random variable that can be mapped over keys. But actually, this throws up something else I didn't quite get. I can define a random function as described. eg.I can partially apply this, and map it over keys as expected.
I can also apply it directly using parenthetical syntax
But I can't using the "old" syntax
since this gives an error. I expected this to work due to tight left binding. Am I misunderstanding something?
Beta Was this translation helpful? Give feedback.
All reactions