I agree that mandatory parentheses around the argument types makes it more readable. This should also make it easier to extend the syntax in the future with optional named arguments, e.g. `(int, str, foo: bool) -> int`. This way you would be able to literally copy-paste a function def to use as type annotation or vice versa.

On Thu, Jun 10, 2021 at 4:31 AM Mehdi Drissi via Typing-sig <typing-sig@python.org> wrote:
I dislike the syntax of (str, int, int -> int). This can be read as (str, int, int) -> int or as tuple[str, int, int -> int]. The second is how some languages (haskell) would read it as.

One question is it fine to nest callables and how does associativity/precedence work for this? int -> int -> bool fine? That's a fairly common pattern in function languages and it'd be nice to stay similar to them. I think of -> as binding weakly and that int -> int -> bool == int -> (int -> bool) (right associativity). Right associativity is needed if you want curry/uncurrying to not need a lot of parentheses.

I weakly prefer -> over =>, but either is a great improvement over Callable[] stacks. Also while keyword/other callable details would be nice, I'd like some simple solution like this for the most common easy cases. Any solution that supports more complex callables I'd want to allow something as simple as int -> bool to not need more stuff.
_______________________________________________
Typing-sig mailing list -- typing-sig@python.org
To unsubscribe send an email to typing-sig-leave@python.org
https://mail.python.org/mailman3/lists/typing-sig.python.org/
Member address: dmrtzn@gmail.com