With the new purity inference proposal the idea is to have ? be a postfix operator with lower precedence than function calling. I propose we do the same with the prefix operators - and ! to have consistency. Concretely this means something like -foo x is equivalent to -(foo x), instead of (-foo) x which it is now
I think that would be useful in the specific case where foo is a function call
for example, I think these situations are different:
answer = -foo x
answer = blah -foo x
in the first example, it's more useful to parse it as -(foo x) because parsing it as (-foo) x will always result in a type mismatch
in the second example, parsing it as blah (-(foo x)) would be strange because it would be introducing a function call where otherwise there wouldn't be one, so I think that one should stay as blah (-foo) x
I didn't think about the second case. I don't know if having the first become -(foo x) and the second blah (-foo) x would be a real issue though.
That said, how would the following parse with ? in the new proposal?
answer = blah foo? x
I think it is the same issue again. As long as we are consistent with both I think anything is fine
yeah that's a good point! I hadn't thought about what we should do in that scenario
I think the two options are again
(blah foo)? xblah (foo?) xI think 2 would be way more desired. It does need to be handled differently though
However I feel you wouldn't often have a variable with a result like this. Either it would be handled with for example a when ... is, or the ? operator will have been used before, when foo was defined. If this assumption is correct, then arguments would almost never need a ?. The exception here is when you calculate an argument inline like foo (bar baz?) x). But obviously, the ? must already be in parentheses here
Last updated: Jun 16 2026 at 16:19 UTC